git.iko.soy/typeable/pandoc
on master help sign in
Added 'standalone' variable, use in templates.

git-svn-id: https://pandoc.googlecode.com/svn/trunk@1697 788f1e2b-df1e-0410-8736-df70ead52e1b

commit4806628c8d8ef9e696a981e6f47ede2b3a6f4d48 authorfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> dateThu 31 Dec 2009, 01:12 (17 years ago) parent359f110
7 files changed+16−13
README+2 man/man1/pandoc.1.md+2 src/Text/Pandoc/Writers/LaTeX.hs+1−6 src/Text/Pandoc/Writers/Markdown.hs+1−6 src/pandoc.hs+4−1 templates/latex.template+4 templates/markdown.template+2
README+2
@@ -475,6 +475,8 @@ will be replaced by the document title.
475475Some variables are set automatically by pandoc. These vary somewhat
476476depending on the output format, but include:
477477
478+`standalone`
479+: "yes" if the `-s/--standalone` option was specified
478480`before`
479481: contents specified by `-B/--include-before-body`
480482`after`
man/man1/pandoc.1.md+2
@@ -256,6 +256,8 @@ will be replaced by the document title.
256256Some variables are set automatically by pandoc. These vary somewhat
257257depending on the output format, but include:
258258
259+`standalone`
260+: "yes" if the `-s/--standalone` option was specified
259261`before`
260262: contents specified by `-B/--include-before-body`
261263`after`
src/Text/Pandoc/Writers/LaTeX.hs+1−6
@@ -62,12 +62,7 @@ pandocToLaTeX options (Pandoc (Meta title authors date) blocks) = do
6262 , ("title", titletext)
6363 , ("authors", intercalate "\\\\" $ map stringToLaTeX authors)
6464 , ("date", stringToLaTeX date) ]
65− let templ = if writerStandalone options
66− then writerTemplate options
67− else "$if(toc)$\\tableofcontents\n$endif$" ++
68− "$if(before)$$before$\n$endif$" ++
69− "$body$$if(after)$$after$\n$endif$"
70− return $ renderTemplate context templ
65+ return $ renderTemplate context $ writerTemplate options
7166
7267-- escape things as needed for LaTeX
7368
src/Text/Pandoc/Writers/Markdown.hs+1−6
@@ -70,12 +70,7 @@ pandocToMarkdown opts (Pandoc meta blocks) = do
7070 text "" $+$ refs')
7171 , ("titleblock", render head')
7272 ]
73− let templ = if writerStandalone opts
74− then writerTemplate opts
75− else "$if(toc)$$toc$\n$endif$" ++
76− "$if(before)$$before$\n$endif$" ++
77− "$body$$if(after)$$after$\n$endif$"
78− return $ renderTemplate context templ
73+ return $ renderTemplate context $ writerTemplate opts
7974
8075-- | Return markdown representation of reference key table.
8176keyTableToMarkdown :: WriterOptions -> KeyTable -> State WriterState Doc
src/pandoc.hs+4−1
@@ -212,7 +212,10 @@ options =
212212
213213 , Option "s" ["standalone"]
214214 (NoArg
215− (\opt -> return opt { optStandalone = True }))
215+ (\opt -> do
216+ let newvars = ("standalone", "yes") : optVariables opt
217+ return opt { optStandalone = True,
218+ optVariables = newvars }))
216219 "" -- "Include needed header and footer on output"
217220
218221 , Option "o" ["output"]
templates/latex.template+4
@@ -1,3 +1,4 @@
1+$if(standalone)$
12$if(legacy-header)$
23$legacy-header$
34$else$
@@ -48,6 +49,7 @@ $endif$
4849\begin{document}
4950\maketitle
5051
52+$endif$
5153$if(toc)$
5254\tableofcontents
5355$endif$
@@ -58,4 +60,6 @@ $body$
5860$if(after)$
5961$after$
6062$endif$
63+$if(standalone)$
6164\end{document}
65+$endif$
templates/markdown.template+2
@@ -1,9 +1,11 @@
1+$if(standalone)$
12$if(titleblock)$
23$titleblock$
34$endif$
45$if(header-includes)$
56$header-includes$
67$endif$
8+$endif$
79$if(before)$
810$before$
911$endif$