diff options
author | fiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> | 2007-07-28 18:14:40 +0000 |
---|---|---|
committer | fiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> | 2007-07-28 18:14:40 +0000 |
commit | 1be1f77569a5e4e059cf7b4339d9d8384c8afd74 (patch) | |
tree | 8d0c36fd94078b598f07f2c3e6751ec96285ba49 | |
parent | 9c181f04102aad9c7feead43e3f9237ba86488d4 (diff) | |
download | pandoc-1be1f77569a5e4e059cf7b4339d9d8384c8afd74.tar.gz |
LaTeX writer:
+ No longer using examplep (too many quirks, too hard to install)
+ Instead, using deVerb function for environments that don't support
\verb
+ And fancyvrb for footnotes and verbatim environments in footnotes.
+ Add fancyvrb to header if Code inline occurs in a footnote.
git-svn-id: https://pandoc.googlecode.com/svn/trunk@825 788f1e2b-df1e-0410-8736-df70ead52e1b
-rw-r--r-- | src/Text/Pandoc/Writers/LaTeX.hs | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/src/Text/Pandoc/Writers/LaTeX.hs b/src/Text/Pandoc/Writers/LaTeX.hs index ef96cf7b7..19365a0f5 100644 --- a/src/Text/Pandoc/Writers/LaTeX.hs +++ b/src/Text/Pandoc/Writers/LaTeX.hs @@ -34,7 +34,6 @@ import Text.Pandoc.Definition import Text.Pandoc.Shared import Text.Printf ( printf ) import Data.List ( (\\), isInfixOf ) -import Data.Char ( isAlphaNum ) import qualified Data.Set as S import Control.Monad.State @@ -187,7 +186,7 @@ tableRowToLaTeX cols = listItemToLaTeX lst = blockListToLaTeX lst >>= (return . ("\\item "++)) defListItemToLaTeX (term, def) = do - term' <- inlineListToLaTeX term + term' <- inlineListToLaTeX $ deVerb term def' <- blockListToLaTeX def return $ "\\item[" ++ term' ++ "] " ++ def' @@ -206,28 +205,31 @@ isQuoted _ = False inlineToLaTeX :: Inline -- ^ Inline to convert -> State WriterState String inlineToLaTeX (Emph lst) = do - contents <- inlineListToLaTeX lst + contents <- inlineListToLaTeX $ deVerb lst return $ "\\emph{" ++ contents ++ "}" inlineToLaTeX (Strong lst) = do - contents <- inlineListToLaTeX lst + contents <- inlineListToLaTeX $ deVerb lst return $ "\\textbf{" ++ contents ++ "}" inlineToLaTeX (Strikeout lst) = do - contents <- inlineListToLaTeX lst + contents <- inlineListToLaTeX $ deVerb lst addToHeader "\\usepackage[normalem]{ulem}" return $ "\\sout{" ++ contents ++ "}" inlineToLaTeX (Superscript lst) = do - contents <- inlineListToLaTeX lst + contents <- inlineListToLaTeX $ deVerb lst return $ "\\textsuperscript{" ++ contents ++ "}" inlineToLaTeX (Subscript lst) = do - contents <- inlineListToLaTeX lst + contents <- inlineListToLaTeX $ deVerb lst -- oddly, latex includes \textsuperscript but not \textsubscript -- so we have to define it: addToHeader "\\newcommand{\\textsubscript}[1]{\\ensuremath{_{\\scriptsize\\textrm{#1}}}}" return $ "\\textsubscript{" ++ contents ++ "}" -inlineToLaTeX (Code str) = return $ "\\Q{" ++ stuffing ++ "}" - where stuffing = concatMap (\c -> if isAlphaNum c - then [c] - else ['\\',c]) str +inlineToLaTeX (Code str) = do + st <- get + if stInNote st + then do addToHeader "\\usepackage{fancyvrb}" + else return () + let chr = ((enumFromTo '!' '~') \\ str) !! 0 + return $ "\\verb" ++ [chr] ++ str ++ [chr] inlineToLaTeX (Quoted SingleQuote lst) = do contents <- inlineListToLaTeX lst let s1 = if (not (null lst)) && (isQuoted (head lst)) then "\\," else "" @@ -248,7 +250,7 @@ inlineToLaTeX (HtmlInline str) = return "" inlineToLaTeX (LineBreak) = return "\\\\\n" inlineToLaTeX Space = return " " inlineToLaTeX (Link text (src, tit)) = do - contents <- inlineListToLaTeX text + contents <- inlineListToLaTeX $ deVerb text addToHeader "\\usepackage[breaklinks=true]{hyperref}" return $ "\\href{" ++ src ++ "}{" ++ contents ++ "}" inlineToLaTeX (Image alternate (source, tit)) = do |