git.iko.soy/typeable/pandoc
on master help sign in
Changed LaTeX writer to use the examplep package instead

of fancyvrb. examplep allows verbatim text in places where fancyvrb does not, e.g. definition list terms, and provides for line-breaking of verbatim text. + examplep code put in LaTeX header instead of being dynamically included, since it is frequently used, and people may want to customize the options. + documented dependency on examplep + added texlive-latex-extra as a "Suggested" package in debian/control + use examplep's \Q{} is now used instead of \verb: note that \Q requires backslash- escaping symbols in its scope. + modified README so that the verbatim sections will look good at shorter line lengths. git-svn-id: https://pandoc.googlecode.com/svn/trunk@807 788f1e2b-df1e-0410-8736-df70ead52e1b

commitb29f221cba949934dda402f96b1606cda8ed73a6 authorfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> dateSat 28 Jul 2007, 01:10 (19 years ago) parent4283ce3
7 files changed+59−58
README+36−35 debian/control+1−1 man/man1/markdown2pdf.1.md+1−1 src/Text/Pandoc/Writers/LaTeX.hs+15−17 src/headers/LaTeXHeader+1 src/wrappers/markdown2pdf.in+3−3 web/myheader.tex+2−1
README+36−35
@@ -59,7 +59,7 @@ 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− + `fancyvrb` (for verbatim text in footnotes)
62+ + `examplep` (for verbatim text in footnotes and definition lists)
6363 + `graphicx` (for images)
6464 + `array` (for tables)
6565 + `ulem` (for strikeout text)
@@ -85,7 +85,7 @@ Note that you can specify multiple input files on the command line.
8585`pandoc` will concatenate them all (with blank lines between them)
8686before parsing:
8787
88− pandoc -s chapter1.txt chapter2.txt references.txt > book.html
88+ pandoc -s ch1.txt ch2.txt refs.txt > book.html
8989
9090(The `-s` option here tells `pandoc` to produce a standalone HTML file,
9191with a proper header, rather than a fragment. For more details on this
@@ -167,7 +167,7 @@ may be used in Windows under Cygwin.)
167167 it will be backed up before being overwritten.) An output file
168168 name can be specified explicitly using the `-o` option:
169169
170− markdown2pdf -o "My Book.pdf" chap1.txt chap2.txt chap3.txt
170+ markdown2pdf -o book.pdf chap1 chap2
171171
172172 If no input file is specified, input will be taken from STDIN.
173173 All of `pandoc`'s options will work with `markdown2pdf` as well.
@@ -340,7 +340,8 @@ For further documentation, see the `pandoc(1)` man page.
340340 include the names of input files and any special options passed
341341 after ` -- ` on the command line. So, for example,
342342
343−: pandoc --dump-args -o foo.html -s foo.txt appendix.txt -- -e latin1
343+: pandoc --dump-args -o foo.html -s foo.txt \
344+ appendix.txt -- -e latin1
344345
345346: will cause the following to be printed to STDOUT:
346347
@@ -499,11 +500,13 @@ after the term. The definition consists of one or more block elements
499500
500501 Term *with inline markup*
501502 : Here is the definition. It may
502− contain multiple blocks. Here is some code:
503+ contain multiple blocks. Here is
504+ some code:
503505
504506 : {* my code *}
505507
506− : Here is the third paragraph of this definition.
508+ : Here is the third paragraph of this
509+ definition.
507510
508511If you leave space after the definition (as in the first example above),
509512the definitions will be considered paragraphs. In some output formats,
@@ -537,20 +540,19 @@ Pandoc's markdown allows footnotes, using the following syntax:
537540
538541 Here is a footnote reference,[^1] and another.[^longnote]
539542
540− [^1]: Here is the footnote. It can go anywhere in the document,
541− except in embedded contexts like block quotes or lists.
543+ [^1]: Here is the footnote.
542544
543− [^longnote]: Here's the other note. This one contains multiple
544− blocks.
545+ [^longnote]: Here's one with multiple blocks.
545546
546− Subsequent paragraphs are indented to show that they belong to
547− the previous footnote.
547+ Subsequent paragraphs are indented to show
548+ that they belong to the previous footnote.
548549
549550 { some.code }
550551
551− The whole paragraph can be indented, or just the first line.
552− In this way, multi-paragraph footnotes work just like
553− multi-paragraph list items in markdown.
552+ The whole paragraph can be indented, or
553+ just the first line. In this way,
554+ multi-paragraph footnotes work like
555+ multi-paragraph list items.
554556
555557 This paragraph won't be part of the note, because it isn't indented.
556558
@@ -616,19 +618,20 @@ try widening it in the markdown source.
616618Multiline tables allow headers and table rows to span multiple lines
617619of text. Here is an example:
618620
619− ---------------------------------------------------------------
620− Centered Left Right
621− Header Aligned Aligned Default aligned
622− ---------- --------- ----------- ---------------------------
623− First row 12.0 Example of a row that spans
624− multiple lines.
625−
626− Second row 5.0 Here's another one. Note
627− the blank line between rows.
628− ---------------------------------------------------------------
629−
630− Table: Optional caption. This, too, may span multiple
631− lines.
621+ ----------------------------------------
622+ Centered Left-aligned Right-aligned
623+ Header Header Header
624+ ---------- ------------- --------------
625+ First This is a 12.0
626+ two-line row.
627+
628+ Second This row is 5.0
629+ three lines
630+ long.
631+ ----------------------------------------
632+
633+ Table: Optional caption. This, too,
634+ may span multiple lines.
632635
633636These work like simple tables, but with the following differences:
634637
@@ -734,13 +737,11 @@ derive the identifier from the header text,
734737 - Replace all spaces, dashes, newlines, and hyphens with hyphens.
735738 - Convert all alphabetic characters to lowercase.
736739
737−Thus,
738−
739− Header text Identifier
740− --------------------------------- --- --------------------------------
741− Header identifiers in HTML → `header-identifiers-in-html`
742− *Dogs*?--in *my* house? → `dogs--in-my-house`
743− [HTML], [S5], or [RTF]? → `html-s5-or-rtf`
740+Thus, for example, a heading 'Header identifiers in HTML' will get
741+the identifier `header-identifiers-in-html`, a heading
742+'*Dogs*?--in *my* house?' will get the identifier `dogs--in-my-house`,
743+and a heading '[HTML], [S5], or [RTF]?' will get the identifier
744+`html-s5-or-rtf`.
744745
745746These rules should, in most cases, allow one to determine the identifier
746747from the header text. The exception is when several headers have the
debian/control+1−1
@@ -10,7 +10,7 @@ Package: pandoc
1010Section: text
1111Architecture: any
1212Depends: ${shlibs:Depends}
13−Suggests: texlive-latex-recommended | tetex-extra, tidy, wget | w3m
13+Suggests: texlive-latex-recommended | tetex-extra, texlive-latex-extra, tidy, wget | w3m
1414Description: general markup converter
1515 Pandoc is a Haskell library for converting from one markup format to
1616 another, and a command-line tool that uses this library. It can read
man/man1/markdown2pdf.1.md+1−1
@@ -28,7 +28,7 @@ output through `iconv`:
2828
2929 iconv -t utf-8 input.txt | pandoc | iconv -f utf-8
3030
31−`markdown2pdf` assumes that the `unicode`, `fancyvrb`, `array`,
31+`markdown2pdf` assumes that the `unicode`, `examplep`, `array`,
3232`graphicx`, and `ulem` packages are in latex's search path. If these
3333packages are not included in your latex setup, they can be obtained from
3434<http://ctan.org>.
src/Text/Pandoc/Writers/LaTeX.hs+15−17
@@ -34,6 +34,7 @@ import Text.Pandoc.Definition
3434import Text.Pandoc.Shared
3535import Text.Printf ( printf )
3636import Data.List ( (\\), isInfixOf )
37+import Data.Char ( isAlphaNum )
3738import qualified Data.Set as S
3839import Control.Monad.State
3940
@@ -81,15 +82,12 @@ latexHeader options (Meta title authors date) = do
8182 then ""
8283 else "\\date{" ++ stringToLaTeX date ++ "}\n"
8384 let maketitle = if null title then "" else "\\maketitle\n"
84− let verbatim = if "\\usepackage{fancyvrb}" `isInfixOf` extras
85− then "\\VerbatimFootnotes % allows verbatim text in footnotes\n"
86− else ""
8785 let secnumline = if (writerNumberSections options)
8886 then ""
8987 else "\\setcounter{secnumdepth}{0}\n"
9088 let baseHeader = writerHeader options
9189 let header = baseHeader ++ extras
92− return $ header ++ secnumline ++ verbatim ++ titletext ++ authorstext ++
90+ return $ header ++ secnumline ++ titletext ++ authorstext ++
9391 datetext ++ "\\begin{document}\n" ++ maketitle ++ "\n"
9492
9593-- escape things as needed for LaTeX
@@ -106,11 +104,11 @@ stringToLaTeX = escapeStringUsing latexEscapes
106104 ]
107105
108106-- | Remove all code elements from list of inline elements
109−-- (because it's illegal to have a \\verb inside a command argument)
107+-- (because it's illegal to have verbatim inside some command arguments)
110108deVerb :: [Inline] -> [Inline]
111109deVerb [] = []
112110deVerb ((Code str):rest) =
113− (Str $ stringToLaTeX str):(deVerb rest)
111+ (TeX $ "\\texttt{" ++ stringToLaTeX str ++ "}"):(deVerb rest)
114112deVerb (other:rest) = other:(deVerb rest)
115113
116114-- | Convert Pandoc block element to LaTeX.
@@ -155,7 +153,7 @@ blockToLaTeX (Table caption aligns widths heads rows) = do
155153 AlignCenter -> "\\centering"
156154 AlignDefault -> "\\raggedright") ++
157155 "\\hspace{0pt}}p{" ++ width ++
158− "\\textwidth}")
156+ "\\columnwidth}")
159157 colWidths aligns
160158 let tableBody = "\\begin{tabular}{" ++ colDescriptors ++ "}\n" ++
161159 headers ++ "\\hline\n" ++ concat rows' ++ "\\end{tabular}\n"
@@ -177,7 +175,7 @@ tableRowToLaTeX cols =
177175listItemToLaTeX lst = blockListToLaTeX lst >>= (return . ("\\item "++))
178176
179177defListItemToLaTeX (term, def) = do
180− term' <- inlineListToLaTeX (deVerb term)
178+ term' <- inlineListToLaTeX term
181179 def' <- blockListToLaTeX def
182180 return $ "\\item[" ++ term' ++ "] " ++ def'
183181
@@ -196,27 +194,28 @@ isQuoted _ = False
196194inlineToLaTeX :: Inline -- ^ Inline to convert
197195 -> State WriterState String
198196inlineToLaTeX (Emph lst) = do
199− contents <- inlineListToLaTeX (deVerb lst)
197+ contents <- inlineListToLaTeX lst
200198 return $ "\\emph{" ++ contents ++ "}"
201199inlineToLaTeX (Strong lst) = do
202− contents <- inlineListToLaTeX (deVerb lst)
200+ contents <- inlineListToLaTeX lst
203201 return $ "\\textbf{" ++ contents ++ "}"
204202inlineToLaTeX (Strikeout lst) = do
205− contents <- inlineListToLaTeX (deVerb lst)
203+ contents <- inlineListToLaTeX lst
206204 addToHeader "\\usepackage[normalem]{ulem}"
207205 return $ "\\sout{" ++ contents ++ "}"
208206inlineToLaTeX (Superscript lst) = do
209− contents <- inlineListToLaTeX (deVerb lst)
207+ contents <- inlineListToLaTeX lst
210208 return $ "\\textsuperscript{" ++ contents ++ "}"
211209inlineToLaTeX (Subscript lst) = do
212− contents <- inlineListToLaTeX (deVerb lst)
210+ contents <- inlineListToLaTeX lst
213211 -- oddly, latex includes \textsuperscript but not \textsubscript
214212 -- so we have to define it:
215213 addToHeader "\\newcommand{\\textsubscript}[1]{\\ensuremath{_{\\scriptsize\\textrm{#1}}}}"
216214 return $ "\\textsubscript{" ++ contents ++ "}"
217−inlineToLaTeX (Code str) = return $ "\\verb" ++ [chr] ++ stuffing ++ [chr]
218− where stuffing = str
219− chr = (('`':(enumFromTo '!' '~')) \\ stuffing) !! 0
215+inlineToLaTeX (Code str) = return $ "\\Q{" ++ stuffing ++ "}"
216+ where stuffing = concatMap (\c -> if isAlphaNum c
217+ then [c]
218+ else ['\\',c]) str
220219inlineToLaTeX (Quoted SingleQuote lst) = do
221220 contents <- inlineListToLaTeX lst
222221 let s1 = if (not (null lst)) && (isQuoted (head lst)) then "\\," else ""
@@ -244,7 +243,6 @@ inlineToLaTeX (Image alternate (source, tit)) = do
244243 addToHeader "\\usepackage{graphicx}"
245244 return $ "\\includegraphics{" ++ source ++ "}"
246245inlineToLaTeX (Note contents) = do
247− addToHeader "\\usepackage{fancyvrb}"
248246 contents' <- blockListToLaTeX contents
249247 return $ "\\footnote{" ++ stripTrailingNewlines contents' ++ "}"
250248
src/headers/LaTeXHeader+1
@@ -1,5 +1,6 @@
11\documentclass{article}
22\usepackage{ucs}
33\usepackage[utf8x]{inputenc}
4+\usepackage[Q=yes,verbatimenv=yes,pverb-linebreak=no]{examplep}
45\setlength{\parindent}{0pt}
56\setlength{\parskip}{6pt plus 2pt minus 1pt}
src/wrappers/markdown2pdf.in+3−3
@@ -40,9 +40,9 @@ fi
4040 err "${THIS}: Please install the 'unicode' package from CTAN:"
4141 err " http://www.ctan.org/tex-archive/macros/latex/contrib/unicode/"
4242 fi
43− if grep -q "File \`fancyvrb.sty' not found" $texname.log; then
44− err "${THIS}: Please install the 'fancyvrb' package from CTAN:"
45− err " http://www.ctan.org/tex-archive/macros/latex/contrib/fancyvrb/"
43+ if grep -q "File \`examplep.sty' not found" $texname.log; then
44+ err "${THIS}: Please install the 'examplep' package from CTAN:"
45+ err " http://www.ctan.org/tex-archive/macros/latex/contrib/examplep/"
4646 fi
4747 if grep -q "File \`ulem.sty' not found" $texname.log; then
4848 err "${THIS}: Please install the 'ulem' package from CTAN:"
web/myheader.tex+2−1
@@ -1,4 +1,5 @@
1−\documentclass[12pt]{article}
1+\documentclass[twocolumn,11pt]{article}
22\usepackage{txfonts}
3+\usepackage[margin=2cm]{geometry}
34\usepackage{ucs}
45\usepackage[utf8x]{inputenc}