summaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Writers
diff options
context:
space:
mode:
authorfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b>2010-03-13 04:11:24 +0000
committerfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b>2010-03-13 04:11:24 +0000
commit3b9be92492cca7573f9ce79dff099b4d2fa3c56c (patch)
treef26d5f856df472e203645f082782e158fb5d8e2e /src/Text/Pandoc/Writers
parenta35af5db295b0e0c598b1ff68f52fc14a4d3911e (diff)
Use template variables for include-before/after.
* These options now imply -s; previously they worked also in fragment mode. * Users can now adjust position of include-before and include-after text in the templates. * Default position of include-before moved back (as it originally was) before table of contents. * Resolves Issue #217. git-svn-id: https://pandoc.googlecode.com/svn/trunk@1883 788f1e2b-df1e-0410-8736-df70ead52e1b
Diffstat (limited to 'src/Text/Pandoc/Writers')
-rw-r--r--src/Text/Pandoc/Writers/ConTeXt.hs8
-rw-r--r--src/Text/Pandoc/Writers/Docbook.hs7
-rw-r--r--src/Text/Pandoc/Writers/HTML.hs4
-rw-r--r--src/Text/Pandoc/Writers/LaTeX.hs8
-rw-r--r--src/Text/Pandoc/Writers/Man.hs6
-rw-r--r--src/Text/Pandoc/Writers/Markdown.hs8
-rw-r--r--src/Text/Pandoc/Writers/MediaWiki.hs4
-rw-r--r--src/Text/Pandoc/Writers/OpenDocument.hs7
-rw-r--r--src/Text/Pandoc/Writers/RST.hs7
-rw-r--r--src/Text/Pandoc/Writers/RTF.hs4
-rw-r--r--src/Text/Pandoc/Writers/Texinfo.hs8
11 files changed, 11 insertions, 60 deletions
diff --git a/src/Text/Pandoc/Writers/ConTeXt.hs b/src/Text/Pandoc/Writers/ConTeXt.hs
index cf8c3cc91..b1e3acb8f 100644
--- a/src/Text/Pandoc/Writers/ConTeXt.hs
+++ b/src/Text/Pandoc/Writers/ConTeXt.hs
@@ -64,13 +64,7 @@ pandocToConTeXt options (Pandoc (Meta title authors date) blocks) = do
then return ""
else liftM render $ inlineListToConTeXt date
body <- blockListToConTeXt blocks
- let before = if null (writerIncludeBefore options)
- then empty
- else text $ writerIncludeBefore options
- let after = if null (writerIncludeAfter options)
- then empty
- else text $ writerIncludeAfter options
- let main = render $ before $$ body $$ after
+ let main = render body
let context = writerVariables options ++
[ ("toc", if writerTableOfContents options then "yes" else "")
, ("body", main)
diff --git a/src/Text/Pandoc/Writers/Docbook.hs b/src/Text/Pandoc/Writers/Docbook.hs
index 153f93391..63647e3aa 100644
--- a/src/Text/Pandoc/Writers/Docbook.hs
+++ b/src/Text/Pandoc/Writers/Docbook.hs
@@ -65,12 +65,7 @@ writeDocbook opts (Pandoc (Meta tit auths dat) blocks) =
authors = map (authorToDocbook opts) auths
date = inlinesToDocbook opts dat
elements = hierarchicalize blocks
- before = writerIncludeBefore opts
- after = writerIncludeAfter opts
- main = render $
- (if null before then empty else text before) $$
- vcat (map (elementToDocbook opts) elements) $$
- (if null after then empty else text after)
+ main = render $ vcat (map (elementToDocbook opts) elements)
context = writerVariables opts ++
[ ("body", main)
, ("title", render title)
diff --git a/src/Text/Pandoc/Writers/HTML.hs b/src/Text/Pandoc/Writers/HTML.hs
index 2f58c7614..a32d63eaf 100644
--- a/src/Text/Pandoc/Writers/HTML.hs
+++ b/src/Text/Pandoc/Writers/HTML.hs
@@ -105,9 +105,7 @@ pandocToHtml opts (Pandoc (Meta title' authors' date') blocks) = do
blocks' <- liftM toHtmlFromList $ mapM (elementToHtml opts) sects
st <- get
let notes = reverse (stNotes st)
- let before = primHtml $ writerIncludeBefore opts
- let after = primHtml $ writerIncludeAfter opts
- let thebody = before +++ blocks' +++ footnoteSection notes +++ after
+ let thebody = blocks' +++ footnoteSection notes
let math = if stMath st
then case writerHTMLMathMethod opts of
LaTeXMathML (Just url) ->
diff --git a/src/Text/Pandoc/Writers/LaTeX.hs b/src/Text/Pandoc/Writers/LaTeX.hs
index f4375ad8c..3362c1d25 100644
--- a/src/Text/Pandoc/Writers/LaTeX.hs
+++ b/src/Text/Pandoc/Writers/LaTeX.hs
@@ -74,13 +74,7 @@ pandocToLaTeX options (Pandoc (Meta title authors date) blocks) = do
authorsText <- mapM (liftM render . inlineListToLaTeX) authors
dateText <- liftM render $ inlineListToLaTeX date
body <- blockListToLaTeX blocks
- let before = if null (writerIncludeBefore options)
- then empty
- else text $ writerIncludeBefore options
- let after = if null (writerIncludeAfter options)
- then empty
- else text $ writerIncludeAfter options
- let main = render $ before $$ body $$ after
+ let main = render body
st <- get
let context = writerVariables options ++
[ ("toc", if writerTableOfContents options then "yes" else "")
diff --git a/src/Text/Pandoc/Writers/Man.hs b/src/Text/Pandoc/Writers/Man.hs
index df66e17ba..62bb90f8e 100644
--- a/src/Text/Pandoc/Writers/Man.hs
+++ b/src/Text/Pandoc/Writers/Man.hs
@@ -48,10 +48,6 @@ writeMan opts document = evalState (pandocToMan opts document) (WriterState [] F
-- | Return groff man representation of document.
pandocToMan :: WriterOptions -> Pandoc -> State WriterState String
pandocToMan opts (Pandoc (Meta title authors date) blocks) = do
- let before = writerIncludeBefore opts
- let after = writerIncludeAfter opts
- let before' = if null before then empty else text before
- let after' = if null after then empty else text after
titleText <- inlineListToMan opts title
authors' <- mapM (inlineListToMan opts) authors
date' <- inlineListToMan opts date
@@ -66,7 +62,7 @@ pandocToMan opts (Pandoc (Meta title authors date) blocks) = do
body <- blockListToMan opts blocks
notes <- liftM stNotes get
notes' <- notesToMan opts (reverse notes)
- let main = render $ before' $$ body $$ notes' $$ after'
+ let main = render $ body $$ notes'
hasTables <- liftM stHasTables get
let context = writerVariables opts ++
[ ("body", main)
diff --git a/src/Text/Pandoc/Writers/Markdown.hs b/src/Text/Pandoc/Writers/Markdown.hs
index 96c4fd15d..d5f750bd6 100644
--- a/src/Text/Pandoc/Writers/Markdown.hs
+++ b/src/Text/Pandoc/Writers/Markdown.hs
@@ -60,17 +60,11 @@ pandocToMarkdown opts (Pandoc (Meta title authors date) blocks) = do
then tableOfContents opts headerBlocks
else empty
body <- blockListToMarkdown opts blocks
- let before = if null (writerIncludeBefore opts)
- then empty
- else text $ writerIncludeBefore opts
- let after = if null (writerIncludeAfter opts)
- then empty
- else text $ writerIncludeAfter opts
(notes, _) <- get
notes' <- notesToMarkdown opts (reverse notes)
(_, refs) <- get -- note that the notes may contain refs
refs' <- keyTableToMarkdown opts (reverse refs)
- let main = render $ before $+$ body $+$ text "" $+$ notes' $+$ text "" $+$ refs' $+$ after
+ let main = render $ body $+$ text "" $+$ notes' $+$ text "" $+$ refs'
let context = writerVariables opts ++
[ ("toc", render toc)
, ("body", main)
diff --git a/src/Text/Pandoc/Writers/MediaWiki.hs b/src/Text/Pandoc/Writers/MediaWiki.hs
index f22172505..07fddcfb4 100644
--- a/src/Text/Pandoc/Writers/MediaWiki.hs
+++ b/src/Text/Pandoc/Writers/MediaWiki.hs
@@ -53,14 +53,12 @@ writeMediaWiki opts document =
-- | Return MediaWiki representation of document.
pandocToMediaWiki :: WriterOptions -> Pandoc -> State WriterState String
pandocToMediaWiki opts (Pandoc _ blocks) = do
- let before = writerIncludeBefore opts
- let after = writerIncludeAfter opts
body <- blockListToMediaWiki opts blocks
notesExist <- get >>= return . stNotes
let notes = if notesExist
then "\n<references />"
else ""
- let main = before ++ body ++ after ++ notes
+ let main = body ++ notes
let context = writerVariables opts ++
[ ("body", main) ] ++
[ ("toc", "yes") | writerTableOfContents opts ]
diff --git a/src/Text/Pandoc/Writers/OpenDocument.hs b/src/Text/Pandoc/Writers/OpenDocument.hs
index e3ed913d4..347072cf1 100644
--- a/src/Text/Pandoc/Writers/OpenDocument.hs
+++ b/src/Text/Pandoc/Writers/OpenDocument.hs
@@ -166,12 +166,7 @@ writeOpenDocument opts (Pandoc (Meta title authors date) blocks) =
date'' <- inlinesToOpenDocument opts date
doc'' <- blocksToOpenDocument opts blocks
return (doc'', title'', authors'', date'')
- before = writerIncludeBefore opts
- after = writerIncludeAfter opts
- body = (if null before then empty else text before) $$
- doc $$
- (if null after then empty else text after)
- body' = render body
+ body' = render doc
styles = stTableStyles s ++ stParaStyles s ++ stTextStyles s
listStyle (n,l) = inTags True "text:list-style"
[("style:name", "L" ++ show n)] (vcat l)
diff --git a/src/Text/Pandoc/Writers/RST.hs b/src/Text/Pandoc/Writers/RST.hs
index e046c5a81..bcffb0693 100644
--- a/src/Text/Pandoc/Writers/RST.hs
+++ b/src/Text/Pandoc/Writers/RST.hs
@@ -59,10 +59,6 @@ writeRST opts document =
pandocToRST :: Pandoc -> State WriterState String
pandocToRST (Pandoc (Meta tit auth dat) blocks) = do
opts <- liftM stOptions get
- let before = writerIncludeBefore opts
- after = writerIncludeAfter opts
- before' = if null before then empty else text before
- after' = if null after then empty else text after
title <- titleToRST tit
authors <- mapM inlineListToRST auth
date <- inlineListToRST dat
@@ -72,8 +68,7 @@ pandocToRST (Pandoc (Meta tit auth dat) blocks) = do
refs <- liftM (reverse . stLinks) get >>= keyTableToRST
pics <- liftM (reverse . stImages) get >>= pictTableToRST
hasMath <- liftM stHasMath get
- let main = render $ before' $+$ body $+$ notes $+$
- text "" $+$ refs $+$ pics $+$ after'
+ let main = render $ body $+$ notes $+$ text "" $+$ refs $+$ pics
let context = writerVariables opts ++
[ ("body", main)
, ("title", render title)
diff --git a/src/Text/Pandoc/Writers/RTF.hs b/src/Text/Pandoc/Writers/RTF.hs
index b9ef2a29a..c0c3d0536 100644
--- a/src/Text/Pandoc/Writers/RTF.hs
+++ b/src/Text/Pandoc/Writers/RTF.hs
@@ -42,9 +42,7 @@ writeRTF options (Pandoc (Meta title authors date) blocks) =
authorstext = map inlineListToRTF authors
datetext = inlineListToRTF date
spacer = not $ all null $ titletext : datetext : authorstext
- body = writerIncludeBefore options ++
- concatMap (blockToRTF 0 AlignDefault) blocks ++
- writerIncludeAfter options
+ body = concatMap (blockToRTF 0 AlignDefault) blocks
context = writerVariables options ++
[ ("body", body)
, ("title", titletext)
diff --git a/src/Text/Pandoc/Writers/Texinfo.hs b/src/Text/Pandoc/Writers/Texinfo.hs
index db32e5a62..bd77c57bb 100644
--- a/src/Text/Pandoc/Writers/Texinfo.hs
+++ b/src/Text/Pandoc/Writers/Texinfo.hs
@@ -69,13 +69,7 @@ pandocToTexinfo options (Pandoc (Meta title authors date) blocks) = do
let titlePage = not $ all null $ title : date : authors
main <- blockListToTexinfo blocks
st <- get
- let before = if null (writerIncludeBefore options)
- then empty
- else text (writerIncludeBefore options)
- let after = if null (writerIncludeAfter options)
- then empty
- else text (writerIncludeAfter options)
- let body = render $ before $$ main $$ after
+ let body = render main
let context = writerVariables options ++
[ ("body", body)
, ("title", render titleText)