summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b>2007-07-28 01:40:48 +0000
committerfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b>2007-07-28 01:40:48 +0000
commitd488dd0f66e14a7728873f31d80b51bab625b442 (patch)
tree8794e67a838e6aaa9c5c37dedb9e17b0b2a7ce00
parentb29f221cba949934dda402f96b1606cda8ed73a6 (diff)
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
-rw-r--r--README3
-rw-r--r--man/man1/markdown2pdf.1.md6
-rw-r--r--src/Text/Pandoc/Writers/LaTeX.hs33
3 files changed, 29 insertions, 13 deletions
diff --git a/README b/README
index 0dcedd70f..efef34a1c 100644
--- a/README
+++ b/README
@@ -59,7 +59,8 @@ The wrapper script `markdown2pdf` requires
- the following LaTeX packages (available from [CTAN], if they
are not already included in your LaTeX distribution):
+ `unicode` (for UTF8 characters)
- + `examplep` (for verbatim text in footnotes and definition lists)
+ + `examplep` (for verbatim text in definition lists, etc.)
+ + `fancyhdr` (for verbatim text in footnotes)
+ `graphicx` (for images)
+ `array` (for tables)
+ `ulem` (for strikeout text)
diff --git a/man/man1/markdown2pdf.1.md b/man/man1/markdown2pdf.1.md
index 13f94ee1d..8ec58c423 100644
--- a/man/man1/markdown2pdf.1.md
+++ b/man/man1/markdown2pdf.1.md
@@ -29,9 +29,9 @@ output through `iconv`:
iconv -t utf-8 input.txt | pandoc | iconv -f utf-8
`markdown2pdf` assumes that the `unicode`, `examplep`, `array`,
-`graphicx`, and `ulem` packages are in latex's search path. If these
-packages are not included in your latex setup, they can be obtained from
-<http://ctan.org>.
+`fancyvrb`, `graphicx`, and `ulem` packages are in latex's search path.
+If these packages are not included in your latex setup, they can be
+ obtained from <http://ctan.org>.
# OPTIONS
diff --git a/src/Text/Pandoc/Writers/LaTeX.hs b/src/Text/Pandoc/Writers/LaTeX.hs
index c9c923dae..2d74b9ffa 100644
--- a/src/Text/Pandoc/Writers/LaTeX.hs
+++ b/src/Text/Pandoc/Writers/LaTeX.hs
@@ -38,17 +38,22 @@ import Data.Char ( isAlphaNum )
import qualified Data.Set as S
import Control.Monad.State
-type WriterState = S.Set String -- set of strings to include in header
- -- constructed based on content of document
+data WriterState =
+ WriterState { stIncludes :: S.Set String -- strings to include in header
+ , stInNote :: Bool } -- @True@ if we're in a note
-- | Add line to header.
addToHeader :: String -> State WriterState ()
-addToHeader str = modify (S.insert str)
+addToHeader str = do
+ st <- get
+ let includes = stIncludes st
+ put st {stIncludes = S.insert str includes}
-- | Convert Pandoc to LaTeX.
writeLaTeX :: WriterOptions -> Pandoc -> String
writeLaTeX options document =
- evalState (pandocToLaTeX options document) S.empty
+ evalState (pandocToLaTeX options document) $
+ WriterState { stIncludes = S.empty, stInNote = False }
pandocToLaTeX :: WriterOptions -> Pandoc -> State WriterState String
pandocToLaTeX options (Pandoc meta blocks) = do
@@ -75,7 +80,10 @@ latexHeader options (Meta title authors date) = do
then return ""
else do title' <- inlineListToLaTeX title
return $ "\\title{" ++ title' ++ "}\n"
- extras <- get >>= (return . unlines . S.toList)
+ extras <- get >>= (return . unlines . S.toList. stIncludes)
+ let verbatim = if "\\usepackage{fancyvrb}" `isInfixOf` extras
+ then "\\VerbatimFootnotes % allows verbatim text in footnotes\n"
+ else ""
let authorstext = "\\author{" ++ (joinWithSep "\\\\"
(map stringToLaTeX authors)) ++ "}\n"
let datetext = if date == ""
@@ -87,7 +95,7 @@ latexHeader options (Meta title authors date) = do
else "\\setcounter{secnumdepth}{0}\n"
let baseHeader = writerHeader options
let header = baseHeader ++ extras
- return $ header ++ secnumline ++ titletext ++ authorstext ++
+ return $ header ++ secnumline ++ verbatim ++ titletext ++ authorstext ++
datetext ++ "\\begin{document}\n" ++ maketitle ++ "\n"
-- escape things as needed for LaTeX
@@ -120,8 +128,11 @@ blockToLaTeX (Para lst) = (inlineListToLaTeX lst) >>= (return . (++ "\n\n"))
blockToLaTeX (BlockQuote lst) = do
contents <- blockListToLaTeX lst
return $ "\\begin{quote}\n" ++ contents ++ "\\end{quote}\n"
-blockToLaTeX (CodeBlock str) = return $
- "\\begin{verbatim}\n" ++ str ++ "\n\\end{verbatim}\n"
+blockToLaTeX (CodeBlock str) = do
+ st <- get
+ let verbEnv = if stInNote st then "Verbatim" else "verbatim"
+ return $ "\\begin{" ++ verbEnv ++ "}\n" ++ str ++
+ "\n\\end{" ++ verbEnv ++ "}\n"
blockToLaTeX (RawHtml str) = return ""
blockToLaTeX (BulletList lst) = do
items <- mapM listItemToLaTeX lst
@@ -243,6 +254,10 @@ inlineToLaTeX (Image alternate (source, tit)) = do
addToHeader "\\usepackage{graphicx}"
return $ "\\includegraphics{" ++ source ++ "}"
inlineToLaTeX (Note contents) = do
+ st <- get
+ put (st {stInNote = True})
contents' <- blockListToLaTeX contents
+ st <- get
+ put (st {stInNote = False})
+ addToHeader "\\usepackage{fancyvrb}"
return $ "\\footnote{" ++ stripTrailingNewlines contents' ++ "}"
-