git.iko.soy/typeable/pandoc
on master help sign in
Removed unneeded writer options; use template variables instead.

Removed writerIncludeAfter, writerIncludeBefore, writerTitlePrefix, writerHeader. Removed corresponding fields of Options structure in pandoc.hs. The options now set template variables (writerVariables) instead. git-svn-id: https://pandoc.googlecode.com/svn/trunk@1684 788f1e2b-df1e-0410-8736-df70ead52e1b

commit9f126c15cf4d0f6c2ab14167e11336d4f5f8783e authorfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> dateThu 31 Dec 2009, 01:10 (17 years ago) parentc602ed3
13 files changed+289−288
src/Text/Pandoc/Shared.hs−8 src/Text/Pandoc/Writers/ConTeXt.hs+37−35 src/Text/Pandoc/Writers/Docbook.hs+20−19 src/Text/Pandoc/Writers/HTML.hs+58−57 src/Text/Pandoc/Writers/LaTeX.hs+2−4 src/Text/Pandoc/Writers/Man.hs+13−12 src/Text/Pandoc/Writers/Markdown.hs+22−21 src/Text/Pandoc/Writers/MediaWiki.hs+15−14 src/Text/Pandoc/Writers/OpenDocument.hs+23−22 src/Text/Pandoc/Writers/RST.hs+21−20 src/Text/Pandoc/Writers/RTF.hs+12−11 src/Text/Pandoc/Writers/Texinfo.hs+46−44 src/pandoc.hs+20−21
src/Text/Pandoc/Shared.hs−8
@@ -982,8 +982,6 @@ data WriterOptions = WriterOptions
982982 { writerStandalone :: Bool -- ^ Include header and footer
983983 , writerTemplate :: String -- ^ Template to use in standalone mode
984984 , writerVariables :: [(String, String)] -- ^ Variables to set in template
985− , writerHeader :: String -- ^ Header for the document
986− , writerTitlePrefix :: String -- ^ Prefix for HTML titles
987985 , writerTabStop :: Int -- ^ Tabstop for conversion btw spaces and tabs
988986 , writerTableOfContents :: Bool -- ^ Include table of contents
989987 , writerS5 :: Bool -- ^ We're writing S5
@@ -991,8 +989,6 @@ data WriterOptions = WriterOptions
991989 , writerIgnoreNotes :: Bool -- ^ Ignore footnotes (used in making toc)
992990 , writerIncremental :: Bool -- ^ Incremental S5 lists
993991 , writerNumberSections :: Bool -- ^ Number sections in LaTeX
994− , writerIncludeBefore :: String -- ^ String to include before the body
995− , writerIncludeAfter :: String -- ^ String to include after the body
996992 , writerStrictMarkdown :: Bool -- ^ Use strict markdown syntax
997993 , writerReferenceLinks :: Bool -- ^ Use reference links in writing markdown, rst
998994 , writerWrapText :: Bool -- ^ Wrap text to line length
@@ -1007,8 +1003,6 @@ defaultWriterOptions =
10071003 WriterOptions { writerStandalone = False
10081004 , writerTemplate = ""
10091005 , writerVariables = []
1010− , writerHeader = ""
1011− , writerTitlePrefix = ""
10121006 , writerTabStop = 4
10131007 , writerTableOfContents = False
10141008 , writerS5 = False
@@ -1016,8 +1010,6 @@ defaultWriterOptions =
10161010 , writerIgnoreNotes = False
10171011 , writerIncremental = False
10181012 , writerNumberSections = False
1019− , writerIncludeBefore = ""
1020− , writerIncludeAfter = ""
10211013 , writerStrictMarkdown = False
10221014 , writerReferenceLinks = False
10231015 , writerWrapText = True
src/Text/Pandoc/Writers/ConTeXt.hs+37−35
@@ -57,47 +57,49 @@ writeConTeXt options document =
5757
5858pandocToConTeXt :: WriterOptions -> Pandoc -> State WriterState Doc
5959pandocToConTeXt options (Pandoc meta blocks) = do
60− main <- blockListToConTeXt blocks
61− let before = if null (writerIncludeBefore options)
62− then empty
63− else text $ writerIncludeBefore options
64− let after = if null (writerIncludeAfter options)
65− then empty
66− else text $ writerIncludeAfter options
67− let body = before $$ main $$ after
68− head' <- if writerStandalone options
69− then contextHeader options meta
70− else return empty
71− let toc = if writerTableOfContents options
72− then text "\\placecontent\n"
73− else empty
74− let foot = if writerStandalone options
75− then text "\\stoptext\n"
76− else empty
77− return $ head' $$ toc $$ body $$ foot
60+ return empty -- TODO
61+-- main <- blockListToConTeXt blocks
62+-- let before = if null (writerIncludeBefore options)
63+-- then empty
64+-- else text $ writerIncludeBefore options
65+-- let after = if null (writerIncludeAfter options)
66+-- then empty
67+-- else text $ writerIncludeAfter options
68+-- let body = before $$ main $$ after
69+-- head' <- if writerStandalone options
70+-- then contextHeader options meta
71+-- else return empty
72+-- let toc = if writerTableOfContents options
73+-- then text "\\placecontent\n"
74+-- else empty
75+-- let foot = if writerStandalone options
76+-- then text "\\stoptext\n"
77+-- else empty
78+-- return $ head' $$ toc $$ body $$ foot
7879
7980-- | Insert bibliographic information into ConTeXt header.
8081contextHeader :: WriterOptions -- ^ Options, including ConTeXt header
8182 -> Meta -- ^ Meta with bibliographic information
8283 -> State WriterState Doc
8384contextHeader options (Meta title authors date) = do
84− titletext <- if null title
85− then return empty
86− else inlineListToConTeXt title
87− let authorstext = if null authors
88− then ""
89− else if length authors == 1
90− then stringToConTeXt $ head authors
91− else stringToConTeXt $ (intercalate ", " $
92− init authors) ++ " & " ++ last authors
93− let datetext = if date == ""
94− then ""
95− else stringToConTeXt date
96− let titleblock = text "\\doctitle{" <> titletext <> char '}' $$
97− text ("\\author{" ++ authorstext ++ "}") $$
98− text ("\\date{" ++ datetext ++ "}")
99− let header = text $ writerHeader options
100− return $ header $$ titleblock $$ text "\\starttext\n\\maketitle\n"
85+ return empty -- TODO
86+-- titletext <- if null title
87+-- then return empty
88+-- else inlineListToConTeXt title
89+-- let authorstext = if null authors
90+-- then ""
91+-- else if length authors == 1
92+-- then stringToConTeXt $ head authors
93+-- else stringToConTeXt $ (intercalate ", " $
94+-- init authors) ++ " & " ++ last authors
95+-- let datetext = if date == ""
96+-- then ""
97+-- else stringToConTeXt date
98+-- let titleblock = text "\\doctitle{" <> titletext <> char '}' $$
99+-- text ("\\author{" ++ authorstext ++ "}") $$
100+-- text ("\\date{" ++ datetext ++ "}")
101+-- let header = text $ writerHeader options
102+-- return $ header $$ titleblock $$ text "\\starttext\n\\maketitle\n"
101103
102104-- escape things as needed for ConTeXt
103105
src/Text/Pandoc/Writers/Docbook.hs+20−19
@@ -59,25 +59,26 @@ authorToDocbook name = inTagsIndented "author" $
5959-- | Convert Pandoc document to string in Docbook format.
6060writeDocbook :: WriterOptions -> Pandoc -> String
6161writeDocbook opts (Pandoc (Meta title authors date) blocks) =
62− let head' = if writerStandalone opts
63− then text (writerHeader opts)
64− else empty
65− meta = if writerStandalone opts
66− then inTagsIndented "articleinfo" $
67− (inTagsSimple "title" (wrap opts title)) $$
68− (vcat (map authorToDocbook authors)) $$
69− (inTagsSimple "date" (text $ escapeStringForXML date))
70− else empty
71− elements = hierarchicalize blocks
72− before = writerIncludeBefore opts
73− after = writerIncludeAfter opts
74− body = (if null before then empty else text before) $$
75− vcat (map (elementToDocbook opts) elements) $$
76− (if null after then empty else text after)
77− body' = if writerStandalone opts
78− then inTagsIndented "article" (meta $$ body)
79− else body
80− in render $ head' $$ body' $$ text ""
62+ "" -- TODO
63+-- let head' = if writerStandalone opts
64+-- then text (writerHeader opts)
65+-- else empty
66+-- meta = if writerStandalone opts
67+-- then inTagsIndented "articleinfo" $
68+-- (inTagsSimple "title" (wrap opts title)) $$
69+-- (vcat (map authorToDocbook authors)) $$
70+-- (inTagsSimple "date" (text $ escapeStringForXML date))
71+-- else empty
72+-- elements = hierarchicalize blocks
73+-- before = writerIncludeBefore opts
74+-- after = writerIncludeAfter opts
75+-- body = (if null before then empty else text before) $$
76+-- vcat (map (elementToDocbook opts) elements) $$
77+-- (if null after then empty else text after)
78+-- body' = if writerStandalone opts
79+-- then inTagsIndented "article" (meta $$ body)
80+-- else body
81+-- in render $ head' $$ body' $$ text ""
8182
8283-- | Convert an Element to Docbook.
8384elementToDocbook :: WriterOptions -> Element -> Doc
src/Text/Pandoc/Writers/HTML.hs+58−57
@@ -88,63 +88,64 @@ writeHtmlString opts =
8888
8989-- | Convert Pandoc document to Html structure.
9090writeHtml :: WriterOptions -> Pandoc -> Html
91−writeHtml opts (Pandoc (Meta tit authors date) blocks) =
92− let titlePrefix = writerTitlePrefix opts
93− (topTitle,st) = runState (inlineListToHtml opts tit) defaultWriterState
94− topTitle'' = stripTags $ showHtmlFragment topTitle
95− topTitle' = titlePrefix ++
96− (if null topTitle'' || null titlePrefix
97− then ""
98− else " - ") ++ topTitle''
99− metadata = thetitle << topTitle' +++
100− meta ! [httpequiv "Content-Type",
101− content "text/html; charset=UTF-8"] +++
102− meta ! [name "generator", content "pandoc"] +++
103− (toHtmlFromList $
104− map (\a -> meta ! [name "author", content a]) authors) +++
105− (if null date
106− then noHtml
107− else meta ! [name "date", content date])
108− titleHeader = if writerStandalone opts && not (null tit) &&
109− not (writerS5 opts)
110− then h1 ! [theclass "title"] $ topTitle
111− else noHtml
112− sects = hierarchicalize blocks
113− toc = if writerTableOfContents opts
114− then evalState (tableOfContents opts sects) st
115− else noHtml
116− (blocks', st') = runState
117− (mapM (elementToHtml opts) sects >>= return . toHtmlFromList)
118− st
119− cssLines = stCSS st'
120− css = if S.null cssLines
121− then noHtml
122− else style ! [thetype "text/css"] $ primHtml $
123− '\n':(unlines $ S.toList cssLines)
124− math = if stMath st'
125− then case writerHTMLMathMethod opts of
126− LaTeXMathML Nothing ->
127− primHtml latexMathMLScript
128− LaTeXMathML (Just url) ->
129− script !
130− [src url, thetype "text/javascript"] $
131− noHtml
132− JsMath (Just url) ->
133− script !
134− [src url, thetype "text/javascript"] $
135− noHtml
136− _ -> noHtml
137− else noHtml
138− head' = header $ metadata +++ math +++ css +++
139− primHtml (renderTemplate [] $ writerHeader opts)
140− notes = reverse (stNotes st')
141− before = primHtml $ writerIncludeBefore opts
142− after = primHtml $ writerIncludeAfter opts
143− thebody = before +++ titleHeader +++ toc +++ blocks' +++
144− footnoteSection notes +++ after
145− in if writerStandalone opts
146− then head' +++ body thebody
147− else thebody
91+writeHtml opts (Pandoc (Meta tit authors date) blocks) =
92+ noHtml -- TODO
93+-- let titlePrefix = writerTitlePrefix opts
94+-- (topTitle,st) = runState (inlineListToHtml opts tit) defaultWriterState
95+-- topTitle'' = stripTags $ showHtmlFragment topTitle
96+-- topTitle' = titlePrefix ++
97+-- (if null topTitle'' || null titlePrefix
98+-- then ""
99+-- else " - ") ++ topTitle''
100+-- metadata = thetitle << topTitle' +++
101+-- meta ! [httpequiv "Content-Type",
102+-- content "text/html; charset=UTF-8"] +++
103+-- meta ! [name "generator", content "pandoc"] +++
104+-- (toHtmlFromList $
105+-- map (\a -> meta ! [name "author", content a]) authors) +++
106+-- (if null date
107+-- then noHtml
108+-- else meta ! [name "date", content date])
109+-- titleHeader = if writerStandalone opts && not (null tit) &&
110+-- not (writerS5 opts)
111+-- then h1 ! [theclass "title"] $ topTitle
112+-- else noHtml
113+-- sects = hierarchicalize blocks
114+-- toc = if writerTableOfContents opts
115+-- then evalState (tableOfContents opts sects) st
116+-- else noHtml
117+-- (blocks', st') = runState
118+-- (mapM (elementToHtml opts) sects >>= return . toHtmlFromList)
119+-- st
120+-- cssLines = stCSS st'
121+-- css = if S.null cssLines
122+-- then noHtml
123+-- else style ! [thetype "text/css"] $ primHtml $
124+-- '\n':(unlines $ S.toList cssLines)
125+-- math = if stMath st'
126+-- then case writerHTMLMathMethod opts of
127+-- LaTeXMathML Nothing ->
128+-- primHtml latexMathMLScript
129+-- LaTeXMathML (Just url) ->
130+-- script !
131+-- [src url, thetype "text/javascript"] $
132+-- noHtml
133+-- JsMath (Just url) ->
134+-- script !
135+-- [src url, thetype "text/javascript"] $
136+-- noHtml
137+-- _ -> noHtml
138+-- else noHtml
139+-- head' = header $ metadata +++ math +++ css +++
140+-- primHtml (renderTemplate [] $ writerHeader opts)
141+-- notes = reverse (stNotes st')
142+-- before = primHtml $ writerIncludeBefore opts
143+-- after = primHtml $ writerIncludeAfter opts
144+-- thebody = before +++ titleHeader +++ toc +++ blocks' +++
145+-- footnoteSection notes +++ after
146+-- in if writerStandalone opts
147+-- then head' +++ body thebody
148+-- else thebody
148149
149150-- | Like Text.XHtml's identifier, but adds the writerIdentifierPrefix
150151prefixedId :: WriterOptions -> String -> HtmlAttr
src/Text/Pandoc/Writers/LaTeX.hs+2−4
@@ -57,15 +57,13 @@ pandocToLaTeX options (Pandoc (Meta title authors date) blocks) = do
5757 then return ""
5858 else liftM render $ inlineListToLaTeX title
5959 let context = writerVariables options ++
60− [ ("before", writerIncludeBefore options)
61− , ("after", writerIncludeAfter options)
62− , ("toc", if writerTableOfContents options then "yes" else "")
60+ [ ("toc", if writerTableOfContents options then "yes" else "")
6361 , ("body", main)
6462 , ("title", titletext)
6563 , ("authors", intercalate "\\\\" $ map stringToLaTeX authors)
6664 , ("date", stringToLaTeX date) ]
6765 let templ = if writerStandalone options
68− then writerHeader options
66+ then writerTemplate options
6967 else "$if(toc)$\\tableofcontents\n$endif$" ++
7068 "$if(before)$$before$\n$endif$" ++
7169 "$body$$if(after)$$after$\n$endif$"
src/Text/Pandoc/Writers/Man.hs+13−12
@@ -48,18 +48,19 @@ writeMan opts document = render $ evalState (pandocToMan opts document) ([],[])
4848-- | Return groff man representation of document.
4949pandocToMan :: WriterOptions -> Pandoc -> State WriterState Doc
5050pandocToMan opts (Pandoc meta blocks) = do
51− let before = writerIncludeBefore opts
52− let after = writerIncludeAfter opts
53− let before' = if null before then empty else text before
54− let after' = if null after then empty else text after
55− (head', foot) <- metaToMan opts meta
56− body <- blockListToMan opts blocks
57− (notes, preprocessors) <- get
58− let preamble = if null preprocessors || not (writerStandalone opts)
59− then empty
60− else text $ ".\\\" " ++ concat (nub preprocessors)
61− notes' <- notesToMan opts (reverse notes)
62− return $ preamble $$ head' $$ before' $$ body $$ notes' $$ foot $$ after'
51+ return empty -- TODO
52+-- let before = writerIncludeBefore opts
53+-- let after = writerIncludeAfter opts
54+-- let before' = if null before then empty else text before
55+-- let after' = if null after then empty else text after
56+-- (head', foot) <- metaToMan opts meta
57+-- body <- blockListToMan opts blocks
58+-- (notes, preprocessors) <- get
59+-- let preamble = if null preprocessors || not (writerStandalone opts)
60+-- then empty
61+-- else text $ ".\\\" " ++ concat (nub preprocessors)
62+-- notes' <- notesToMan opts (reverse notes)
63+-- return $ preamble $$ head' $$ before' $$ body $$ notes' $$ foot $$ after'
6364
6465-- | Insert bibliographic information into Man header and footer.
6566metaToMan :: WriterOptions -- ^ Options, including Man header
src/Text/Pandoc/Writers/Markdown.hs+22−21
@@ -50,27 +50,28 @@ writeMarkdown opts document =
5050-- | Return markdown representation of document.
5151pandocToMarkdown :: WriterOptions -> Pandoc -> State WriterState Doc
5252pandocToMarkdown opts (Pandoc meta blocks) = do
53− let before = writerIncludeBefore opts
54− let after = writerIncludeAfter opts
55− let header = writerHeader opts
56− let before' = if null before then empty else text before
57− let after' = if null after then empty else text after
58− let header' = if null header then empty else text header
59− metaBlock <- metaToMarkdown opts meta
60− let head' = if writerStandalone opts
61− then metaBlock $+$ header'
62− else empty
63− let headerBlocks = filter isHeaderBlock blocks
64− let toc = if writerTableOfContents opts
65− then tableOfContents opts headerBlocks
66− else empty
67− body <- blockListToMarkdown opts blocks
68− (notes, _) <- get
69− notes' <- notesToMarkdown opts (reverse notes)
70− (_, refs) <- get -- note that the notes may contain refs
71− refs' <- keyTableToMarkdown opts (reverse refs)
72− return $ head' $+$ before' $+$ toc $+$ body $+$ text "" $+$
73− notes' $+$ text "" $+$ refs' $+$ after'
53+ return empty -- TODO
54+-- let before = writerIncludeBefore opts
55+-- let after = writerIncludeAfter opts
56+-- let header = writerHeader opts
57+-- let before' = if null before then empty else text before
58+-- let after' = if null after then empty else text after
59+-- let header' = if null header then empty else text header
60+-- metaBlock <- metaToMarkdown opts meta
61+-- let head' = if writerStandalone opts
62+-- then metaBlock $+$ header'
63+-- else empty
64+-- let headerBlocks = filter isHeaderBlock blocks
65+-- let toc = if writerTableOfContents opts
66+-- then tableOfContents opts headerBlocks
67+-- else empty
68+-- body <- blockListToMarkdown opts blocks
69+-- (notes, _) <- get
70+-- notes' <- notesToMarkdown opts (reverse notes)
71+-- (_, refs) <- get -- note that the notes may contain refs
72+-- refs' <- keyTableToMarkdown opts (reverse refs)
73+-- return $ head' $+$ before' $+$ toc $+$ body $+$ text "" $+$
74+-- notes' $+$ text "" $+$ refs' $+$ after'
7475
7576-- | Return markdown representation of reference key table.
7677keyTableToMarkdown :: WriterOptions -> KeyTable -> State WriterState Doc
src/Text/Pandoc/Writers/MediaWiki.hs+15−14
@@ -52,20 +52,21 @@ writeMediaWiki opts document =
5252-- | Return MediaWiki representation of document.
5353pandocToMediaWiki :: WriterOptions -> Pandoc -> State WriterState String
5454pandocToMediaWiki opts (Pandoc _ blocks) = do
55− let before = writerIncludeBefore opts
56− let after = writerIncludeAfter opts
57− let head' = if writerStandalone opts
58− then writerHeader opts
59− else ""
60− let toc = if writerTableOfContents opts
61− then "__TOC__\n"
62− else ""
63− body <- blockListToMediaWiki opts blocks
64− notesExist <- get >>= return . stNotes
65− let notes = if notesExist
66− then "\n== Notes ==\n<references />"
67− else ""
68− return $ head' ++ before ++ toc ++ body ++ after ++ notes
55+ return "" -- TODO
56+-- let before = writerIncludeBefore opts
57+-- let after = writerIncludeAfter opts
58+-- let head' = if writerStandalone opts
59+-- then writerHeader opts
60+-- else ""
61+-- let toc = if writerTableOfContents opts
62+-- then "__TOC__\n"
63+-- else ""
64+-- body <- blockListToMediaWiki opts blocks
65+-- notesExist <- get >>= return . stNotes
66+-- let notes = if notesExist
67+-- then "\n== Notes ==\n<references />"
68+-- else ""
69+-- return $ head' ++ before ++ toc ++ body ++ after ++ notes
6970
7071-- | Escape special characters for MediaWiki.
7172escapeString :: String -> String
src/Text/Pandoc/Writers/OpenDocument.hs+23−22
@@ -180,28 +180,29 @@ authorToOpenDocument name =
180180-- | Convert Pandoc document to string in OpenDocument format.
181181writeOpenDocument :: WriterOptions -> Pandoc -> String
182182writeOpenDocument opts (Pandoc (Meta title authors date) blocks) =
183− let root = inTags True "office:document-content" openDocumentNameSpaces
184− header = when (writerStandalone opts) $ text (writerHeader opts)
185− title' = case runState (wrap opts title) defaultWriterState of
186− (t,_) -> if isEmpty t then empty else inHeaderTags 1 t
187− authors' = when (authors /= []) $ vcat (map authorToOpenDocument authors)
188− date' = when (date /= []) $
189− inParagraphTagsWithStyle "Date" (text $ escapeStringForXML date)
190− meta = when (writerStandalone opts) $ title' $$ authors' $$ date'
191− before = writerIncludeBefore opts
192− after = writerIncludeAfter opts
193− (doc, s) = runState (blocksToOpenDocument opts blocks) defaultWriterState
194− body = (if null before then empty else text before) $$
195− doc $$
196− (if null after then empty else text after)
197− body' = if writerStandalone opts
198− then inTagsIndented "office:body" $
199− inTagsIndented "office:text" (meta $$ body)
200− else body
201− styles = stTableStyles s ++ stParaStyles s ++ stTextStyles s
202− listStyle (n,l) = inTags True "text:list-style" [("style:name", "L" ++ show n)] (vcat l)
203− listStyles = map listStyle (stListStyles s)
204− in render $ header $$ root (generateStyles (styles ++ listStyles) $$ body' $$ text "")
183+ "" -- TODO
184+-- let root = inTags True "office:document-content" openDocumentNameSpaces
185+-- header = when (writerStandalone opts) $ text (writerHeader opts)
186+-- title' = case runState (wrap opts title) defaultWriterState of
187+-- (t,_) -> if isEmpty t then empty else inHeaderTags 1 t
188+-- authors' = when (authors /= []) $ vcat (map authorToOpenDocument authors)
189+-- date' = when (date /= []) $
190+-- inParagraphTagsWithStyle "Date" (text $ escapeStringForXML date)
191+-- meta = when (writerStandalone opts) $ title' $$ authors' $$ date'
192+-- before = writerIncludeBefore opts
193+-- after = writerIncludeAfter opts
194+-- (doc, s) = runState (blocksToOpenDocument opts blocks) defaultWriterState
195+-- body = (if null before then empty else text before) $$
196+-- doc $$
197+-- (if null after then empty else text after)
198+-- body' = if writerStandalone opts
199+-- then inTagsIndented "office:body" $
200+-- inTagsIndented "office:text" (meta $$ body)
201+-- else body
202+-- styles = stTableStyles s ++ stParaStyles s ++ stTextStyles s
203+-- listStyle (n,l) = inTags True "text:list-style" [("style:name", "L" ++ show n)] (vcat l)
204+-- listStyles = map listStyle (stListStyles s)
205+-- in render $ header $$ root (generateStyles (styles ++ listStyles) $$ body' $$ text "")
205206
206207withParagraphStyle :: WriterOptions -> String -> [Block] -> State WriterState Doc
207208withParagraphStyle o s (b:bs)
src/Text/Pandoc/Writers/RST.hs+21−20
@@ -57,26 +57,27 @@ writeRST opts document =
5757-- | Return RST representation of document.
5858pandocToRST :: Pandoc -> State WriterState Doc
5959pandocToRST (Pandoc meta blocks) = do
60− opts <- get >>= (return . stOptions)
61− let before = writerIncludeBefore opts
62− after = writerIncludeAfter opts
63− header = writerHeader opts
64− before' = if null before then empty else text before
65− after' = if null after then empty else text after
66− header' = if null header then empty else text header
67− metaBlock <- metaToRST opts meta
68− let head' = if (writerStandalone opts)
69− then metaBlock $+$ header'
70− else empty
71− body <- blockListToRST blocks
72− includes <- get >>= (return . concat . stIncludes)
73− let includes' = if null includes then empty else text includes
74− notes <- get >>= (notesToRST . reverse . stNotes)
75− -- note that the notes may contain refs, so we do them first
76− refs <- get >>= (keyTableToRST . reverse . stLinks)
77− pics <- get >>= (pictTableToRST . reverse . stImages)
78− return $ head' $+$ before' $+$ includes' $+$ body $+$ notes $+$ text "" $+$
79− refs $+$ pics $+$ after'
60+ return empty -- TODO
61+-- opts <- get >>= (return . stOptions)
62+-- let before = writerIncludeBefore opts
63+-- after = writerIncludeAfter opts
64+-- header = writerHeader opts
65+-- before' = if null before then empty else text before
66+-- after' = if null after then empty else text after
67+-- header' = if null header then empty else text header
68+-- metaBlock <- metaToRST opts meta
69+-- let head' = if (writerStandalone opts)
70+-- then metaBlock $+$ header'
71+-- else empty
72+-- body <- blockListToRST blocks
73+-- includes <- get >>= (return . concat . stIncludes)
74+-- let includes' = if null includes then empty else text includes
75+-- notes <- get >>= (notesToRST . reverse . stNotes)
76+-- -- note that the notes may contain refs, so we do them first
77+-- refs <- get >>= (keyTableToRST . reverse . stLinks)
78+-- pics <- get >>= (pictTableToRST . reverse . stImages)
79+-- return $ head' $+$ before' $+$ includes' $+$ body $+$ notes $+$ text "" $+$
80+-- refs $+$ pics $+$ after'
8081
8182-- | Return RST representation of reference key table.
8283keyTableToRST :: KeyTable -> State WriterState Doc
src/Text/Pandoc/Writers/RTF.hs+12−11
@@ -37,17 +37,18 @@ import Data.Char ( ord, isDigit )
3737-- | Convert Pandoc to a string in rich text format.
3838writeRTF :: WriterOptions -> Pandoc -> String
3939writeRTF options (Pandoc meta blocks) =
40− let head' = if writerStandalone options
41− then rtfHeader (writerHeader options) meta
42− else ""
43− toc = if writerTableOfContents options
44− then tableOfContents $ filter isHeaderBlock blocks
45− else ""
46− foot = if writerStandalone options then "\n}\n" else ""
47− body = writerIncludeBefore options ++
48− concatMap (blockToRTF 0 AlignDefault) blocks ++
49− writerIncludeAfter options
50− in head' ++ toc ++ body ++ foot
40+ "" -- TODO
41+-- let head' = if writerStandalone options
42+-- then rtfHeader (writerHeader options) meta
43+-- else ""
44+-- toc = if writerTableOfContents options
45+-- then tableOfContents $ filter isHeaderBlock blocks
46+-- else ""
47+-- foot = if writerStandalone options then "\n}\n" else ""
48+-- body = writerIncludeBefore options ++
49+-- concatMap (blockToRTF 0 AlignDefault) blocks ++
50+-- writerIncludeAfter options
51+-- in head' ++ toc ++ body ++ foot
5152
5253-- | Construct table of contents from list of header blocks.
5354tableOfContents :: [Block] -> String
src/Text/Pandoc/Writers/Texinfo.hs+46−44
@@ -68,56 +68,58 @@ wrapTop (Pandoc (Meta title authors date) blocks) =
6868
6969pandocToTexinfo :: WriterOptions -> Pandoc -> State WriterState Doc
7070pandocToTexinfo options (Pandoc meta blocks) = do
71− main <- blockListToTexinfo blocks
72− head' <- if writerStandalone options
73− then texinfoHeader options meta
74− else return empty
75− let before = if null (writerIncludeBefore options)
76− then empty
77− else text (writerIncludeBefore options)
78− let after = if null (writerIncludeAfter options)
79− then empty
80− else text (writerIncludeAfter options)
81− let body = before $$ main $$ after
82− -- XXX toc untested
83− let toc = if writerTableOfContents options
84− then text "@contents"
85− else empty
86− let foot = if writerStandalone options
87− then text "@bye"
88− else empty
89− return $ head' $$ toc $$ body $$ foot
71+ return empty -- TODO
72+-- main <- blockListToTexinfo blocks
73+-- head' <- if writerStandalone options
74+-- then texinfoHeader options meta
75+-- else return empty
76+-- let before = if null (writerIncludeBefore options)
77+-- then empty
78+-- else text (writerIncludeBefore options)
79+-- let after = if null (writerIncludeAfter options)
80+-- then empty
81+-- else text (writerIncludeAfter options)
82+-- let body = before $$ main $$ after
83+-- -- XXX toc untested
84+-- let toc = if writerTableOfContents options
85+-- then text "@contents"
86+-- else empty
87+-- let foot = if writerStandalone options
88+-- then text "@bye"
89+-- else empty
90+-- return $ head' $$ toc $$ body $$ foot
9091
9192-- | Insert bibliographic information into Texinfo header.
9293texinfoHeader :: WriterOptions -- ^ Options, including Texinfo header
9394 -> Meta -- ^ Meta with bibliographic information
9495 -> State WriterState Doc
9596texinfoHeader options (Meta title authors date) = do
96− titletext <- if null title
97− then return empty
98− else do
99− t <- inlineListToTexinfo title
100− return $ text "@title " <> t
101− headerIncludes <- get >>= return . S.toList . stIncludes
102− let extras = text $ unlines headerIncludes
103− let authorstext = map makeAuthor authors
104− let datetext = if date == ""
105− then empty
106− else text $ stringToTexinfo date
107−
108− let baseHeader = case writerHeader options of
109− "" -> empty
110− x -> text x
111− let header = text "@documentencoding utf-8" $$ baseHeader $$ extras
112− return $ text "\\input texinfo" $$
113− header $$
114− text "@ifnottex" $$
115− text "@paragraphindent 0" $$
116− text "@end ifnottex" $$
117− text "@titlepage" $$
118− titletext $$ vcat authorstext $$
119− datetext $$
120− text "@end titlepage"
97+ return empty -- TODO
98+-- titletext <- if null title
99+-- then return empty
100+-- else do
101+-- t <- inlineListToTexinfo title
102+-- return $ text "@title " <> t
103+-- headerIncludes <- get >>= return . S.toList . stIncludes
104+-- let extras = text $ unlines headerIncludes
105+-- let authorstext = map makeAuthor authors
106+-- let datetext = if date == ""
107+-- then empty
108+-- else text $ stringToTexinfo date
109+--
110+-- let baseHeader = case writerHeader options of
111+-- "" -> empty
112+-- x -> text x
113+-- let header = text "@documentencoding utf-8" $$ baseHeader $$ extras
114+-- return $ text "\\input texinfo" $$
115+-- header $$
116+-- text "@ifnottex" $$
117+-- text "@paragraphindent 0" $$
118+-- text "@end ifnottex" $$
119+-- text "@titlepage" $$
120+-- titletext $$ vcat authorstext $$
121+-- datetext $$
122+-- text "@end titlepage"
121123
122124makeAuthor :: String -> Doc
123125makeAuthor author = text $ "@author " ++ (stringToTexinfo author)
src/pandoc.hs+20−21
@@ -138,9 +138,6 @@ data Opt = Opt
138138 , optTemplate :: String -- ^ Custom template
139139 , optVariables :: [(String,String)] -- ^ Template variables to set
140140 , optIncludeInHeader :: String -- ^ File to include in header
141− , optIncludeBeforeBody :: String -- ^ File to include at top of body
142− , optIncludeAfterBody :: String -- ^ File to include at end of body
143− , optTitlePrefix :: String -- ^ Optional prefix for HTML title
144141 , optOutputFile :: String -- ^ Name of output file
145142 , optNumberSections :: Bool -- ^ Number sections in LaTeX
146143 , optIncremental :: Bool -- ^ Use incremental lists in S5
@@ -177,9 +174,6 @@ defaultOpts = Opt
177174 , optTemplate = ""
178175 , optVariables = []
179176 , optIncludeInHeader = ""
180− , optIncludeBeforeBody = ""
181− , optIncludeAfterBody = ""
182− , optTitlePrefix = ""
183177 , optOutputFile = "-" -- "-" means stdout
184178 , optNumberSections = False
185179 , optIncremental = False
@@ -367,18 +361,28 @@ options =
367361 , Option "B" ["include-before-body"]
368362 (ReqArg
369363 (\arg opt -> do
370− let old = optIncludeBeforeBody opt
371364 text <- readFile arg
372− return opt { optIncludeBeforeBody = old ++ text })
365+ let oldvars = optVariables opt
366+ let newvars = case lookup "before" oldvars of
367+ Nothing -> ("before", text) : oldvars
368+ Just b -> ("before", b ++ text) :
369+ filter ((/= "before") . fst)
370+ oldvars
371+ return opt { optVariables = newvars })
373372 "FILENAME")
374373 "" -- "File to include before document body"
375374
376375 , Option "A" ["include-after-body"]
377376 (ReqArg
378377 (\arg opt -> do
379− let old = optIncludeAfterBody opt
380378 text <- readFile arg
381− return opt { optIncludeAfterBody = old ++ text })
379+ let oldvars = optVariables opt
380+ let newvars = case lookup "after" oldvars of
381+ Nothing -> ("after", text) : oldvars
382+ Just a -> ("after", a ++ text) :
383+ filter ((/= "after") . fst)
384+ oldvars
385+ return opt { optVariables = newvars })
382386 "FILENAME")
383387 "" -- "File to include after document body"
384388
@@ -397,8 +401,10 @@ options =
397401
398402 , Option "T" ["title-prefix"]
399403 (ReqArg
400− (\arg opt -> return opt { optTitlePrefix = arg,
401− optStandalone = True })
404+ (\arg opt -> do
405+ let newvars = ("title-prefix", arg) : optVariables opt
406+ return opt { optVariables = newvars,
407+ optStandalone = True })
402408 "STRING")
403409 "" -- "String to prefix to HTML window title"
404410
@@ -549,9 +555,6 @@ main = do
549555 , optTableOfContents = toc
550556 , optTemplate = template
551557 , optIncludeInHeader = includeHeader
552− , optIncludeBeforeBody = includeBefore
553− , optIncludeAfterBody = includeAfter
554− , optTitlePrefix = titlePrefix
555558 , optOutputFile = outputFile
556559 , optNumberSections = numberSections
557560 , optIncremental = incremental
@@ -633,12 +636,10 @@ main = do
633636 [("header-includes", includeHeader)] ++
634637 variables
635638 let writerOptions = WriterOptions { writerStandalone = standalone',
636− writerTemplate = defaultTemplate,
637− writerVariables = variables',
638− writerHeader = if null template
639+ writerTemplate = if null template
639640 then defaultTemplate
640641 else template,
641− writerTitlePrefix = titlePrefix,
642+ writerVariables = variables',
642643 writerTabStop = tabStop,
643644 writerTableOfContents = toc &&
644645 writerName' /= "s5",
@@ -647,8 +648,6 @@ main = do
647648 writerIgnoreNotes = False,
648649 writerIncremental = incremental,
649650 writerNumberSections = numberSections,
650− writerIncludeBefore = includeBefore,
651− writerIncludeAfter = includeAfter,
652651 writerStrictMarkdown = strict,
653652 writerReferenceLinks = referenceLinks,
654653 writerWrapText = wrap,