git.iko.soy/typeable/pandoc
on master help sign in
Restored writerIncludeBefore, writerIncludeAfter.
1f580fbfiddlosopher
src/Text/Pandoc/Shared.hs+4
@@ -984,6 +984,8 @@ data WriterOptions = WriterOptions
984 { writerStandalone :: Bool -- ^ Include header and footer
984 { writerStandalone :: Bool -- ^ Include header and footer
985 , writerTemplate :: String -- ^ Template to use in standalone mode
985 , writerTemplate :: String -- ^ Template to use in standalone mode
986 , writerVariables :: [(String, String)] -- ^ Variables to set in template
986 , writerVariables :: [(String, String)] -- ^ Variables to set in template
987+ , writerIncludeBefore :: String -- ^ Text to include before the body
988+ , writerIncludeAfter :: String -- ^ Text to include after the body
987 , writerTabStop :: Int -- ^ Tabstop for conversion btw spaces and tabs
989 , writerTabStop :: Int -- ^ Tabstop for conversion btw spaces and tabs
988 , writerTableOfContents :: Bool -- ^ Include table of contents
990 , writerTableOfContents :: Bool -- ^ Include table of contents
989 , writerS5 :: Bool -- ^ We're writing S5
991 , writerS5 :: Bool -- ^ We're writing S5
@@ -1005,6 +1007,8 @@ defaultWriterOptions =
1005 WriterOptions { writerStandalone = False
1007 WriterOptions { writerStandalone = False
1006 , writerTemplate = ""
1008 , writerTemplate = ""
1007 , writerVariables = []
1009 , writerVariables = []
1010+ , writerIncludeBefore = ""
1011+ , writerIncludeAfter = ""
1008 , writerTabStop = 4
1012 , writerTabStop = 4
1009 , writerTableOfContents = False
1013 , writerTableOfContents = False
1010 , writerS5 = False
1014 , writerS5 = False
src/Text/Pandoc/Writers/LaTeX.hs+11−2
@@ -52,7 +52,14 @@ writeLaTeX options document =
52
52
53pandocToLaTeX :: WriterOptions -> Pandoc -> State WriterState String
53pandocToLaTeX :: WriterOptions -> Pandoc -> State WriterState String
54pandocToLaTeX options (Pandoc (Meta title authors date) blocks) = do
54pandocToLaTeX options (Pandoc (Meta title authors date) blocks) = do
55− main <- liftM render $ blockListToLaTeX blocks
55+ body <- blockListToLaTeX blocks
56+ let before = if null (writerIncludeBefore options)
57+ then empty
58+ else text $ writerIncludeBefore options
59+ let after = if null (writerIncludeAfter options)
60+ then empty
61+ else text $ writerIncludeAfter options
62+ let main = render $ before $$ body $$ after
56 titletext <- liftM render $ inlineListToLaTeX title
63 titletext <- liftM render $ inlineListToLaTeX title
57 authorsText <- mapM (liftM render . inlineListToLaTeX) authors
64 authorsText <- mapM (liftM render . inlineListToLaTeX) authors
58 dateText <- liftM render $ inlineListToLaTeX date
65 dateText <- liftM render $ inlineListToLaTeX date
@@ -62,7 +69,9 @@ pandocToLaTeX options (Pandoc (Meta title authors date) blocks) = do
62 , ("title", titletext)
69 , ("title", titletext)
63 , ("authors", intercalate "\\\\" authorsText)
70 , ("authors", intercalate "\\\\" authorsText)
64 , ("date", dateText) ]
71 , ("date", dateText) ]
72+ return $ if writerStandalone options
65− return $ renderTemplate context $ writerTemplate options
73+ then renderTemplate context $ writerTemplate options
74+ else main
66
75
67-- escape things as needed for LaTeX
76-- escape things as needed for LaTeX
68
77
src/Text/Pandoc/Writers/Markdown.hs+11−3
@@ -60,17 +60,25 @@ pandocToMarkdown opts (Pandoc meta blocks) = do
60 then tableOfContents opts headerBlocks
60 then tableOfContents opts headerBlocks
61 else empty
61 else empty
62 body <- blockListToMarkdown opts blocks
62 body <- blockListToMarkdown opts blocks
63+ let before = if null (writerIncludeBefore opts)
64+ then empty
65+ else text $ writerIncludeBefore opts
66+ let after = if null (writerIncludeAfter opts)
67+ then empty
68+ else text $ writerIncludeAfter opts
63 (notes, _) <- get
69 (notes, _) <- get
64 notes' <- notesToMarkdown opts (reverse notes)
70 notes' <- notesToMarkdown opts (reverse notes)
65 (_, refs) <- get -- note that the notes may contain refs
71 (_, refs) <- get -- note that the notes may contain refs
66 refs' <- keyTableToMarkdown opts (reverse refs)
72 refs' <- keyTableToMarkdown opts (reverse refs)
73+ let main = render $ before $+$ body $+$ text "" $+$ notes' $+$ text "" $+$ refs' $+$ after
67 let context = writerVariables opts ++
74 let context = writerVariables opts ++
68 [ ("toc", render toc)
75 [ ("toc", render toc)
69− , ("body", render $ body $+$ text "" $+$ notes' $+$
76+ , ("body", main)
70− text "" $+$ refs')
71 , ("titleblock", render head')
77 , ("titleblock", render head')
72 ]
78 ]
79+ if writerStandalone opts
73− return $ renderTemplate context $ writerTemplate opts
80+ then return $ renderTemplate context $ writerTemplate opts
81+ else return main
74
82
75-- | Return markdown representation of reference key table.
83-- | Return markdown representation of reference key table.
76keyTableToMarkdown :: WriterOptions -> KeyTable -> State WriterState Doc
84keyTableToMarkdown :: WriterOptions -> KeyTable -> State WriterState Doc
src/pandoc.hs+12−14
@@ -138,6 +138,8 @@ data Opt = Opt
138 , optTableOfContents :: Bool -- ^ Include table of contents
138 , optTableOfContents :: Bool -- ^ Include table of contents
139 , optTemplate :: String -- ^ Custom template
139 , optTemplate :: String -- ^ Custom template
140 , optVariables :: [(String,String)] -- ^ Template variables to set
140 , optVariables :: [(String,String)] -- ^ Template variables to set
141+ , optBefore :: [String] -- ^ Texts to include before body
142+ , optAfter :: [String] -- ^ Texts to include after body
141 , optOutputFile :: String -- ^ Name of output file
143 , optOutputFile :: String -- ^ Name of output file
142 , optNumberSections :: Bool -- ^ Number sections in LaTeX
144 , optNumberSections :: Bool -- ^ Number sections in LaTeX
143 , optIncremental :: Bool -- ^ Use incremental lists in S5
145 , optIncremental :: Bool -- ^ Use incremental lists in S5
@@ -172,6 +174,8 @@ defaultOpts = Opt
172 , optTableOfContents = False
174 , optTableOfContents = False
173 , optTemplate = ""
175 , optTemplate = ""
174 , optVariables = []
176 , optVariables = []
177+ , optBefore = []
178+ , optAfter = []
175 , optOutputFile = "-" -- "-" means stdout
179 , optOutputFile = "-" -- "-" means stdout
176 , optNumberSections = False
180 , optNumberSections = False
177 , optIncremental = False
181 , optIncremental = False
@@ -383,13 +387,8 @@ options =
383 (ReqArg
387 (ReqArg
384 (\arg opt -> do
388 (\arg opt -> do
385 text <- readFile arg
389 text <- readFile arg
386− let oldvars = optVariables opt
390+ let oldBefore = optBefore opt
387− let newvars = case lookup "before" oldvars of
391+ return opt { optBefore = text : oldBefore })
388− Nothing -> ("before", text) : oldvars
389− Just b -> ("before", b ++ text) :
390− filter ((/= "before") . fst)
391− oldvars
392− return opt { optVariables = newvars })
393 "FILENAME")
392 "FILENAME")
394 "" -- "File to include before document body"
393 "" -- "File to include before document body"
395
394
@@ -397,13 +396,8 @@ options =
397 (ReqArg
396 (ReqArg
398 (\arg opt -> do
397 (\arg opt -> do
399 text <- readFile arg
398 text <- readFile arg
400− let oldvars = optVariables opt
399+ let oldAfter = optAfter opt
401− let newvars = case lookup "after" oldvars of
400+ return opt { optAfter = text : oldAfter })
402− Nothing -> ("after", text) : oldvars
403− Just a -> ("after", a ++ text) :
404− filter ((/= "after") . fst)
405− oldvars
406− return opt { optVariables = newvars })
407 "FILENAME")
401 "FILENAME")
408 "" -- "File to include after document body"
402 "" -- "File to include after document body"
409
403
@@ -572,6 +566,8 @@ main = do
572 , optWriter = writerName
566 , optWriter = writerName
573 , optParseRaw = parseRaw
567 , optParseRaw = parseRaw
574 , optVariables = variables
568 , optVariables = variables
569+ , optBefore = befores
570+ , optAfter = afters
575 , optTableOfContents = toc
571 , optTableOfContents = toc
576 , optTemplate = template
572 , optTemplate = template
577 , optOutputFile = outputFile
573 , optOutputFile = outputFile
@@ -665,6 +661,8 @@ main = do
665 then defaultTemplate
661 then defaultTemplate
666 else template,
662 else template,
667 writerVariables = variables',
663 writerVariables = variables',
664+ writerIncludeBefore = concat befores,
665+ writerIncludeAfter = concat afters,
668 writerTabStop = tabStop,
666 writerTabStop = tabStop,
669 writerTableOfContents = toc &&
667 writerTableOfContents = toc &&
670 writerName' /= "s5",
668 writerName' /= "s5",
templates/context.template−3
@@ -78,8 +78,6 @@ $header-includes$
78
78
79\placecontent
79\placecontent
80
80
81−$before$
82−
83\subject{section oen}
81\subject{section oen}
84
82
85\startitemize[n][stopper=.]
83\startitemize[n][stopper=.]
@@ -106,7 +104,6 @@ footnote
106code
104code
107\stoptyping
105\stoptyping
108}
106}
109−$after$
110
107
111\stoptext
108\stoptext
112
109
templates/docbook.template+2−2
@@ -10,7 +10,7 @@
10 />$header-includes$
10 />$header-includes$
11</head
11</head
12 ><body
12 ><body
13− >$before$
13+ >
14<h1 class="title"
14<h1 class="title"
15 ><span class="math"
15 ><span class="math"
16 ><em
16 ><em
@@ -68,7 +68,7 @@
68 > <a href="#fnref1" class="footnoteBackLink" title="Jump back to footnote 1">&#8617;</a></li
68 > <a href="#fnref1" class="footnoteBackLink" title="Jump back to footnote 1">&#8617;</a></li
69 ></ol
69 ></ol
70 ></div
70 ></div
71− >$after$
71+ >
72</body
72</body
73 ></html
73 ></html
74>
74>
templates/html.template+2−2
@@ -10,7 +10,7 @@
10 />$header-includes$
10 />$header-includes$
11</head
11</head
12 ><body
12 ><body
13− >$before$
13+ >
14<h1 class="title"
14<h1 class="title"
15 ><span class="math"
15 ><span class="math"
16 ><em
16 ><em
@@ -68,7 +68,7 @@
68 > <a href="#fnref1" class="footnoteBackLink" title="Jump back to footnote 1">&#8617;</a></li
68 > <a href="#fnref1" class="footnoteBackLink" title="Jump back to footnote 1">&#8617;</a></li
69 ></ol
69 ></ol
70 ></div
70 ></div
71− >$after$
71+ >
72</body
72</body
73 ></html
73 ></html
74>
74>
templates/latex.template−10
@@ -1,4 +1,3 @@
1−$if(standalone)$
2$if(legacy-header)$
1$if(legacy-header)$
3$legacy-header$
2$legacy-header$
4$else$
3$else$
@@ -49,17 +48,8 @@ $endif$
49\begin{document}
48\begin{document}
50\maketitle
49\maketitle
51
50
52−$endif$
53$if(toc)$
51$if(toc)$
54\tableofcontents
52\tableofcontents
55$endif$
53$endif$
56−$if(before)$
57−$before$
58−$endif$
59$body$
54$body$
60−$if(after)$
61−$after$
62−$endif$
63−$if(standalone)$
64\end{document}
55\end{document}
65−$endif$
templates/man.template+2−2
@@ -10,7 +10,7 @@
10 />$header-includes$
10 />$header-includes$
11</head
11</head
12 ><body
12 ><body
13− >$before$
13+ >
14<h1 class="title"
14<h1 class="title"
15 ><span class="math"
15 ><span class="math"
16 ><em
16 ><em
@@ -68,7 +68,7 @@
68 > <a href="#fnref1" class="footnoteBackLink" title="Jump back to footnote 1">&#8617;</a></li
68 > <a href="#fnref1" class="footnoteBackLink" title="Jump back to footnote 1">&#8617;</a></li
69 ></ol
69 ></ol
70 ></div
70 ></div
71− >$after$
71+ >
72</body
72</body
73 ></html
73 ></html
74>
74>
templates/markdown.template−8
@@ -1,18 +1,10 @@
1−$if(standalone)$
2$if(titleblock)$
1$if(titleblock)$
3$titleblock$
2$titleblock$
4$endif$
3$endif$
5$if(header-includes)$
4$if(header-includes)$
6$header-includes$
5$header-includes$
7$endif$
6$endif$
8−$endif$
9−$if(before)$
10−$before$
11−$endif$
12$if(toc)$
7$if(toc)$
13$toc$
8$toc$
14$endif$
9$endif$
15$body$
10$body$
16−$if(after)$
17−$after$
18−$endif$
templates/mediawiki.template+2−2
@@ -10,7 +10,7 @@
10 />$header-includes$
10 />$header-includes$
11</head
11</head
12 ><body
12 ><body
13− >$before$
13+ >
14<h1 class="title"
14<h1 class="title"
15 ><span class="math"
15 ><span class="math"
16 ><em
16 ><em
@@ -68,7 +68,7 @@
68 > <a href="#fnref1" class="footnoteBackLink" title="Jump back to footnote 1">&#8617;</a></li
68 > <a href="#fnref1" class="footnoteBackLink" title="Jump back to footnote 1">&#8617;</a></li
69 ></ol
69 ></ol
70 ></div
70 ></div
71− >$after$
71+ >
72</body
72</body
73 ></html
73 ></html
74>
74>
templates/opendocument.template+2−2
@@ -10,7 +10,7 @@
10 />$header-includes$
10 />$header-includes$
11</head
11</head
12 ><body
12 ><body
13− >$before$
13+ >
14<h1 class="title"
14<h1 class="title"
15 ><span class="math"
15 ><span class="math"
16 ><em
16 ><em
@@ -68,7 +68,7 @@
68 > <a href="#fnref1" class="footnoteBackLink" title="Jump back to footnote 1">&#8617;</a></li
68 > <a href="#fnref1" class="footnoteBackLink" title="Jump back to footnote 1">&#8617;</a></li
69 ></ol
69 ></ol
70 ></div
70 ></div
71− >$after$
71+ >
72</body
72</body
73 ></html
73 ></html
74>
74>
templates/rst.template−5
@@ -9,8 +9,6 @@
9
9
10$header-includes$
10$header-includes$
11
11
12−$before$
13−
14.. role:: math(raw)
12.. role:: math(raw)
15 :format: html latex
13 :format: html latex
16
14
@@ -39,6 +37,3 @@ footnote [1]_
39
37
40 code
38 code
41
39
42−
43−$after$
44−
templates/rtf.template−2
@@ -9,7 +9,6 @@ $header-includes$
9{\pard \ql \f0 \sa180 \li0 \fi0 \par}
9{\pard \ql \f0 \sa180 \li0 \fi0 \par}
10{\pard \ql \f0 \sa180 \li0 \fi0 \b \fs36 Contents\par}
10{\pard \ql \f0 \sa180 \li0 \fi0 \b \fs36 Contents\par}
11{\pard \ql \f0 \sa0 \li360 \fi-360 \bullet \tx360\tab section oen\sa180\par}
11{\pard \ql \f0 \sa0 \li360 \fi-360 \bullet \tx360\tab section oen\sa180\par}
12−$before$
13{\pard \ql \f0 \sa180 \li0 \fi0 \b \fs36 section oen\par}
12{\pard \ql \f0 \sa180 \li0 \fi0 \b \fs36 section oen\par}
14{\pard \ql \f0 \sa0 \li360 \fi-360 1.\tx360\tab one\par}
13{\pard \ql \f0 \sa0 \li360 \fi-360 1.\tx360\tab one\par}
15{\pard \ql \f0 \sa0 \li720 \fi-360 a.\tx360\tab two\par}
14{\pard \ql \f0 \sa0 \li720 \fi-360 a.\tx360\tab two\par}
@@ -18,7 +17,6 @@ $before$
18{\pard \ql \f0 \sa180 \li0 \fi0 footnote{\super\chftn}{\*\footnote\chftn\~\plain\pard {\pard \ql \f0 \sa180 \li0 \fi0 with code\par}
17{\pard \ql \f0 \sa180 \li0 \fi0 footnote{\super\chftn}{\*\footnote\chftn\~\plain\pard {\pard \ql \f0 \sa180 \li0 \fi0 with code\par}
19{\pard \ql \f0 \sa180 \li0 \fi0 \f1 code\par}
18{\pard \ql \f0 \sa180 \li0 \fi0 \f1 code\par}
20}\par}
19}\par}
21−$after$
22
20
23}
21}
24
22
templates/s5.template+2−2
@@ -271,7 +271,7 @@ window.onload=startup;window.onresize=function(){setTimeout('fontScale()',50);}
271$header-includes$
271$header-includes$
272</head
272</head
273 ><body
273 ><body
274− >$before$
274+ >
275<div class="layout">
275<div class="layout">
276<div id="controls"></div>
276<div id="controls"></div>
277<div id="currentSlide"></div>
277<div id="currentSlide"></div>
@@ -343,7 +343,7 @@ $header-includes$
343 > <a href="#fnref1" class="footnoteBackLink" title="Jump back to footnote 1">&#8617;</a></li
343 > <a href="#fnref1" class="footnoteBackLink" title="Jump back to footnote 1">&#8617;</a></li
344 ></ol
344 ></ol
345 ></div
345 ></div
346− >$after$
346+ >
347</body
347</body
348 ></html
348 ></html
349>
349>
templates/texinfo.template−2
@@ -12,7 +12,6 @@ $header-includes$
12$date$
12$date$
13@end titlepage
13@end titlepage
14@contents
14@contents
15−$before$
16
15
17@node Top
16@node Top
18@top @math{title}
17@top @math{title}
@@ -48,6 +47,5 @@ code
48@end verbatim
47@end verbatim
49}
48}
50
49
51−$after$
52
50
53@bye
51@bye