git.iko.soy/typeable/pandoc
on master help sign in
Reinstated dependence on fancyvrb. It is compatible with examplep.

fancyvrb is needed for verbatim environments in footnotes. git-svn-id: https://pandoc.googlecode.com/svn/trunk@808 788f1e2b-df1e-0410-8736-df70ead52e1b

commitd488dd0f66e14a7728873f31d80b51bab625b442 authorfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> dateSat 28 Jul 2007, 01:40 (19 years ago) parentb29f221
3 files changed+29−13
README+2−1 man/man1/markdown2pdf.1.md+3−3 src/Text/Pandoc/Writers/LaTeX.hs+24−9
README+2−1
@@ -59,7 +59,8 @@ The wrapper script `markdown2pdf` requires
5959 - the following LaTeX packages (available from [CTAN], if they
6060 are not already included in your LaTeX distribution):
6161 + `unicode` (for UTF8 characters)
62− + `examplep` (for verbatim text in footnotes and definition lists)
62+ + `examplep` (for verbatim text in definition lists, etc.)
63+ + `fancyhdr` (for verbatim text in footnotes)
6364 + `graphicx` (for images)
6465 + `array` (for tables)
6566 + `ulem` (for strikeout text)
man/man1/markdown2pdf.1.md+3−3
@@ -29,9 +29,9 @@ output through `iconv`:
2929 iconv -t utf-8 input.txt | pandoc | iconv -f utf-8
3030
3131`markdown2pdf` assumes that the `unicode`, `examplep`, `array`,
32−`graphicx`, and `ulem` packages are in latex's search path. If these
33−packages are not included in your latex setup, they can be obtained from
34−<http://ctan.org>.
32+`fancyvrb`, `graphicx`, and `ulem` packages are in latex's search path.
33+If these packages are not included in your latex setup, they can be
34+ obtained from <http://ctan.org>.
3535
3636# OPTIONS
3737
src/Text/Pandoc/Writers/LaTeX.hs+24−9
@@ -38,17 +38,22 @@ import Data.Char ( isAlphaNum )
3838import qualified Data.Set as S
3939import Control.Monad.State
4040
41−type WriterState = S.Set String -- set of strings to include in header
42− -- constructed based on content of document
41+data WriterState =
42+ WriterState { stIncludes :: S.Set String -- strings to include in header
43+ , stInNote :: Bool } -- @True@ if we're in a note
4344
4445-- | Add line to header.
4546addToHeader :: String -> State WriterState ()
46−addToHeader str = modify (S.insert str)
47+addToHeader str = do
48+ st <- get
49+ let includes = stIncludes st
50+ put st {stIncludes = S.insert str includes}
4751
4852-- | Convert Pandoc to LaTeX.
4953writeLaTeX :: WriterOptions -> Pandoc -> String
5054writeLaTeX options document =
51− evalState (pandocToLaTeX options document) S.empty
55+ evalState (pandocToLaTeX options document) $
56+ WriterState { stIncludes = S.empty, stInNote = False }
5257
5358pandocToLaTeX :: WriterOptions -> Pandoc -> State WriterState String
5459pandocToLaTeX options (Pandoc meta blocks) = do
@@ -75,7 +80,10 @@ latexHeader options (Meta title authors date) = do
7580 then return ""
7681 else do title' <- inlineListToLaTeX title
7782 return $ "\\title{" ++ title' ++ "}\n"
78− extras <- get >>= (return . unlines . S.toList)
83+ extras <- get >>= (return . unlines . S.toList. stIncludes)
84+ let verbatim = if "\\usepackage{fancyvrb}" `isInfixOf` extras
85+ then "\\VerbatimFootnotes % allows verbatim text in footnotes\n"
86+ else ""
7987 let authorstext = "\\author{" ++ (joinWithSep "\\\\"
8088 (map stringToLaTeX authors)) ++ "}\n"
8189 let datetext = if date == ""
@@ -87,7 +95,7 @@ latexHeader options (Meta title authors date) = do
8795 else "\\setcounter{secnumdepth}{0}\n"
8896 let baseHeader = writerHeader options
8997 let header = baseHeader ++ extras
90− return $ header ++ secnumline ++ titletext ++ authorstext ++
98+ return $ header ++ secnumline ++ verbatim ++ titletext ++ authorstext ++
9199 datetext ++ "\\begin{document}\n" ++ maketitle ++ "\n"
92100
93101-- escape things as needed for LaTeX
@@ -120,8 +128,11 @@ blockToLaTeX (Para lst) = (inlineListToLaTeX lst) >>= (return . (++ "\n\n"))
120128blockToLaTeX (BlockQuote lst) = do
121129 contents <- blockListToLaTeX lst
122130 return $ "\\begin{quote}\n" ++ contents ++ "\\end{quote}\n"
123−blockToLaTeX (CodeBlock str) = return $
124− "\\begin{verbatim}\n" ++ str ++ "\n\\end{verbatim}\n"
131+blockToLaTeX (CodeBlock str) = do
132+ st <- get
133+ let verbEnv = if stInNote st then "Verbatim" else "verbatim"
134+ return $ "\\begin{" ++ verbEnv ++ "}\n" ++ str ++
135+ "\n\\end{" ++ verbEnv ++ "}\n"
125136blockToLaTeX (RawHtml str) = return ""
126137blockToLaTeX (BulletList lst) = do
127138 items <- mapM listItemToLaTeX lst
@@ -243,6 +254,10 @@ inlineToLaTeX (Image alternate (source, tit)) = do
243254 addToHeader "\\usepackage{graphicx}"
244255 return $ "\\includegraphics{" ++ source ++ "}"
245256inlineToLaTeX (Note contents) = do
257+ st <- get
258+ put (st {stInNote = True})
246259 contents' <- blockListToLaTeX contents
260+ st <- get
261+ put (st {stInNote = False})
262+ addToHeader "\\usepackage{fancyvrb}"
247263 return $ "\\footnote{" ++ stripTrailingNewlines contents' ++ "}"
248−