git.iko.soy/typeable/pandoc
on master help sign in
Removed unneeded writer options; use template variables instead.
9f126c1fiddlosopher
src/Text/Pandoc/Shared.hs−8
@@ -982,8 +982,6 @@ data WriterOptions = WriterOptions
982 { writerStandalone :: Bool -- ^ Include header and footer
982 { writerStandalone :: Bool -- ^ Include header and footer
983 , writerTemplate :: String -- ^ Template to use in standalone mode
983 , writerTemplate :: String -- ^ Template to use in standalone mode
984 , writerVariables :: [(String, String)] -- ^ Variables to set in template
984 , writerVariables :: [(String, String)] -- ^ Variables to set in template
985− , writerHeader :: String -- ^ Header for the document
986− , writerTitlePrefix :: String -- ^ Prefix for HTML titles
987 , writerTabStop :: Int -- ^ Tabstop for conversion btw spaces and tabs
985 , writerTabStop :: Int -- ^ Tabstop for conversion btw spaces and tabs
988 , writerTableOfContents :: Bool -- ^ Include table of contents
986 , writerTableOfContents :: Bool -- ^ Include table of contents
989 , writerS5 :: Bool -- ^ We're writing S5
987 , writerS5 :: Bool -- ^ We're writing S5
@@ -991,8 +989,6 @@ data WriterOptions = WriterOptions
991 , writerIgnoreNotes :: Bool -- ^ Ignore footnotes (used in making toc)
989 , writerIgnoreNotes :: Bool -- ^ Ignore footnotes (used in making toc)
992 , writerIncremental :: Bool -- ^ Incremental S5 lists
990 , writerIncremental :: Bool -- ^ Incremental S5 lists
993 , writerNumberSections :: Bool -- ^ Number sections in LaTeX
991 , writerNumberSections :: Bool -- ^ Number sections in LaTeX
994− , writerIncludeBefore :: String -- ^ String to include before the body
995− , writerIncludeAfter :: String -- ^ String to include after the body
996 , writerStrictMarkdown :: Bool -- ^ Use strict markdown syntax
992 , writerStrictMarkdown :: Bool -- ^ Use strict markdown syntax
997 , writerReferenceLinks :: Bool -- ^ Use reference links in writing markdown, rst
993 , writerReferenceLinks :: Bool -- ^ Use reference links in writing markdown, rst
998 , writerWrapText :: Bool -- ^ Wrap text to line length
994 , writerWrapText :: Bool -- ^ Wrap text to line length
@@ -1007,8 +1003,6 @@ defaultWriterOptions =
1007 WriterOptions { writerStandalone = False
1003 WriterOptions { writerStandalone = False
1008 , writerTemplate = ""
1004 , writerTemplate = ""
1009 , writerVariables = []
1005 , writerVariables = []
1010− , writerHeader = ""
1011− , writerTitlePrefix = ""
1012 , writerTabStop = 4
1006 , writerTabStop = 4
1013 , writerTableOfContents = False
1007 , writerTableOfContents = False
1014 , writerS5 = False
1008 , writerS5 = False
@@ -1016,8 +1010,6 @@ defaultWriterOptions =
1016 , writerIgnoreNotes = False
1010 , writerIgnoreNotes = False
1017 , writerIncremental = False
1011 , writerIncremental = False
1018 , writerNumberSections = False
1012 , writerNumberSections = False
1019− , writerIncludeBefore = ""
1020− , writerIncludeAfter = ""
1021 , writerStrictMarkdown = False
1013 , writerStrictMarkdown = False
1022 , writerReferenceLinks = False
1014 , writerReferenceLinks = False
1023 , writerWrapText = True
1015 , writerWrapText = True
src/Text/Pandoc/Writers/ConTeXt.hs+37−35
@@ -57,47 +57,49 @@ writeConTeXt options document =
57
57
58pandocToConTeXt :: WriterOptions -> Pandoc -> State WriterState Doc
58pandocToConTeXt :: WriterOptions -> Pandoc -> State WriterState Doc
59pandocToConTeXt options (Pandoc meta blocks) = do
59pandocToConTeXt options (Pandoc meta blocks) = do
60+ return empty -- TODO
60− main <- blockListToConTeXt blocks
61+-- main <- blockListToConTeXt blocks
61− let before = if null (writerIncludeBefore options)
62+-- let before = if null (writerIncludeBefore options)
62− then empty
63+-- then empty
63− else text $ writerIncludeBefore options
64+-- else text $ writerIncludeBefore options
64− let after = if null (writerIncludeAfter options)
65+-- let after = if null (writerIncludeAfter options)
65− then empty
66+-- then empty
66− else text $ writerIncludeAfter options
67+-- else text $ writerIncludeAfter options
67− let body = before $$ main $$ after
68+-- let body = before $$ main $$ after
68− head' <- if writerStandalone options
69+-- head' <- if writerStandalone options
69− then contextHeader options meta
70+-- then contextHeader options meta
70− else return empty
71+-- else return empty
71− let toc = if writerTableOfContents options
72+-- let toc = if writerTableOfContents options
72− then text "\\placecontent\n"
73+-- then text "\\placecontent\n"
73− else empty
74+-- else empty
74− let foot = if writerStandalone options
75+-- let foot = if writerStandalone options
75− then text "\\stoptext\n"
76+-- then text "\\stoptext\n"
76− else empty
77+-- else empty
77− return $ head' $$ toc $$ body $$ foot
78+-- return $ head' $$ toc $$ body $$ foot
78
79
79-- | Insert bibliographic information into ConTeXt header.
80-- | Insert bibliographic information into ConTeXt header.
80contextHeader :: WriterOptions -- ^ Options, including ConTeXt header
81contextHeader :: WriterOptions -- ^ Options, including ConTeXt header
81 -> Meta -- ^ Meta with bibliographic information
82 -> Meta -- ^ Meta with bibliographic information
82 -> State WriterState Doc
83 -> State WriterState Doc
83contextHeader options (Meta title authors date) = do
84contextHeader options (Meta title authors date) = do
85+ return empty -- TODO
84− titletext <- if null title
86+-- titletext <- if null title
85− then return empty
87+-- then return empty
86− else inlineListToConTeXt title
88+-- else inlineListToConTeXt title
87− let authorstext = if null authors
89+-- let authorstext = if null authors
88− then ""
90+-- then ""
89− else if length authors == 1
91+-- else if length authors == 1
90− then stringToConTeXt $ head authors
92+-- then stringToConTeXt $ head authors
91− else stringToConTeXt $ (intercalate ", " $
93+-- else stringToConTeXt $ (intercalate ", " $
92− init authors) ++ " & " ++ last authors
94+-- init authors) ++ " & " ++ last authors
93− let datetext = if date == ""
95+-- let datetext = if date == ""
94− then ""
96+-- then ""
95− else stringToConTeXt date
97+-- else stringToConTeXt date
96− let titleblock = text "\\doctitle{" <> titletext <> char '}' $$
98+-- let titleblock = text "\\doctitle{" <> titletext <> char '}' $$
97− text ("\\author{" ++ authorstext ++ "}") $$
99+-- text ("\\author{" ++ authorstext ++ "}") $$
98− text ("\\date{" ++ datetext ++ "}")
100+-- text ("\\date{" ++ datetext ++ "}")
99− let header = text $ writerHeader options
101+-- let header = text $ writerHeader options
100− return $ header $$ titleblock $$ text "\\starttext\n\\maketitle\n"
102+-- return $ header $$ titleblock $$ text "\\starttext\n\\maketitle\n"
101
103
102-- escape things as needed for ConTeXt
104-- escape things as needed for ConTeXt
103
105
src/Text/Pandoc/Writers/Docbook.hs+20−19
@@ -59,25 +59,26 @@ authorToDocbook name = inTagsIndented "author" $
59-- | Convert Pandoc document to string in Docbook format.
59-- | Convert Pandoc document to string in Docbook format.
60writeDocbook :: WriterOptions -> Pandoc -> String
60writeDocbook :: WriterOptions -> Pandoc -> String
61writeDocbook opts (Pandoc (Meta title authors date) blocks) =
61writeDocbook opts (Pandoc (Meta title authors date) blocks) =
62+ "" -- TODO
62− let head' = if writerStandalone opts
63+-- let head' = if writerStandalone opts
63− then text (writerHeader opts)
64+-- then text (writerHeader opts)
64− else empty
65+-- else empty
65− meta = if writerStandalone opts
66+-- meta = if writerStandalone opts
66− then inTagsIndented "articleinfo" $
67+-- then inTagsIndented "articleinfo" $
67− (inTagsSimple "title" (wrap opts title)) $$
68+-- (inTagsSimple "title" (wrap opts title)) $$
68− (vcat (map authorToDocbook authors)) $$
69+-- (vcat (map authorToDocbook authors)) $$
69− (inTagsSimple "date" (text $ escapeStringForXML date))
70+-- (inTagsSimple "date" (text $ escapeStringForXML date))
70− else empty
71+-- else empty
71− elements = hierarchicalize blocks
72+-- elements = hierarchicalize blocks
72− before = writerIncludeBefore opts
73+-- before = writerIncludeBefore opts
73− after = writerIncludeAfter opts
74+-- after = writerIncludeAfter opts
74− body = (if null before then empty else text before) $$
75+-- body = (if null before then empty else text before) $$
75− vcat (map (elementToDocbook opts) elements) $$
76+-- vcat (map (elementToDocbook opts) elements) $$
76− (if null after then empty else text after)
77+-- (if null after then empty else text after)
77− body' = if writerStandalone opts
78+-- body' = if writerStandalone opts
78− then inTagsIndented "article" (meta $$ body)
79+-- then inTagsIndented "article" (meta $$ body)
79− else body
80+-- else body
80− in render $ head' $$ body' $$ text ""
81+-- in render $ head' $$ body' $$ text ""
81
82
82-- | Convert an Element to Docbook.
83-- | Convert an Element to Docbook.
83elementToDocbook :: WriterOptions -> Element -> Doc
84elementToDocbook :: WriterOptions -> Element -> Doc
src/Text/Pandoc/Writers/HTML.hs+58−57
@@ -88,63 +88,64 @@ writeHtmlString opts =
88
88
89-- | Convert Pandoc document to Html structure.
89-- | Convert Pandoc document to Html structure.
90writeHtml :: WriterOptions -> Pandoc -> Html
90writeHtml :: WriterOptions -> Pandoc -> Html
91−writeHtml opts (Pandoc (Meta tit authors date) blocks) =
91+writeHtml opts (Pandoc (Meta tit authors date) blocks) =
92+ noHtml -- TODO
92− let titlePrefix = writerTitlePrefix opts
93+-- let titlePrefix = writerTitlePrefix opts
93− (topTitle,st) = runState (inlineListToHtml opts tit) defaultWriterState
94+-- (topTitle,st) = runState (inlineListToHtml opts tit) defaultWriterState
94− topTitle'' = stripTags $ showHtmlFragment topTitle
95+-- topTitle'' = stripTags $ showHtmlFragment topTitle
95− topTitle' = titlePrefix ++
96+-- topTitle' = titlePrefix ++
96− (if null topTitle'' || null titlePrefix
97+-- (if null topTitle'' || null titlePrefix
97− then ""
98+-- then ""
98− else " - ") ++ topTitle''
99+-- else " - ") ++ topTitle''
99− metadata = thetitle << topTitle' +++
100+-- metadata = thetitle << topTitle' +++
100− meta ! [httpequiv "Content-Type",
101+-- meta ! [httpequiv "Content-Type",
101− content "text/html; charset=UTF-8"] +++
102+-- content "text/html; charset=UTF-8"] +++
102− meta ! [name "generator", content "pandoc"] +++
103+-- meta ! [name "generator", content "pandoc"] +++
103− (toHtmlFromList $
104+-- (toHtmlFromList $
104− map (\a -> meta ! [name "author", content a]) authors) +++
105+-- map (\a -> meta ! [name "author", content a]) authors) +++
105− (if null date
106+-- (if null date
106− then noHtml
107+-- then noHtml
107− else meta ! [name "date", content date])
108+-- else meta ! [name "date", content date])
108− titleHeader = if writerStandalone opts && not (null tit) &&
109+-- titleHeader = if writerStandalone opts && not (null tit) &&
109− not (writerS5 opts)
110+-- not (writerS5 opts)
110− then h1 ! [theclass "title"] $ topTitle
111+-- then h1 ! [theclass "title"] $ topTitle
111− else noHtml
112+-- else noHtml
112− sects = hierarchicalize blocks
113+-- sects = hierarchicalize blocks
113− toc = if writerTableOfContents opts
114+-- toc = if writerTableOfContents opts
114− then evalState (tableOfContents opts sects) st
115+-- then evalState (tableOfContents opts sects) st
115− else noHtml
116+-- else noHtml
116− (blocks', st') = runState
117+-- (blocks', st') = runState
117− (mapM (elementToHtml opts) sects >>= return . toHtmlFromList)
118+-- (mapM (elementToHtml opts) sects >>= return . toHtmlFromList)
118− st
119+-- st
119− cssLines = stCSS st'
120+-- cssLines = stCSS st'
120− css = if S.null cssLines
121+-- css = if S.null cssLines
121− then noHtml
122+-- then noHtml
122− else style ! [thetype "text/css"] $ primHtml $
123+-- else style ! [thetype "text/css"] $ primHtml $
123− '\n':(unlines $ S.toList cssLines)
124+-- '\n':(unlines $ S.toList cssLines)
124− math = if stMath st'
125+-- math = if stMath st'
125− then case writerHTMLMathMethod opts of
126+-- then case writerHTMLMathMethod opts of
126− LaTeXMathML Nothing ->
127+-- LaTeXMathML Nothing ->
127− primHtml latexMathMLScript
128+-- primHtml latexMathMLScript
128− LaTeXMathML (Just url) ->
129+-- LaTeXMathML (Just url) ->
129− script !
130+-- script !
130− [src url, thetype "text/javascript"] $
131+-- [src url, thetype "text/javascript"] $
131− noHtml
132+-- noHtml
132− JsMath (Just url) ->
133+-- JsMath (Just url) ->
133− script !
134+-- script !
134− [src url, thetype "text/javascript"] $
135+-- [src url, thetype "text/javascript"] $
135− noHtml
136+-- noHtml
136− _ -> noHtml
137+-- _ -> noHtml
137− else noHtml
138+-- else noHtml
138− head' = header $ metadata +++ math +++ css +++
139+-- head' = header $ metadata +++ math +++ css +++
139− primHtml (renderTemplate [] $ writerHeader opts)
140+-- primHtml (renderTemplate [] $ writerHeader opts)
140− notes = reverse (stNotes st')
141+-- notes = reverse (stNotes st')
141− before = primHtml $ writerIncludeBefore opts
142+-- before = primHtml $ writerIncludeBefore opts
142− after = primHtml $ writerIncludeAfter opts
143+-- after = primHtml $ writerIncludeAfter opts
143− thebody = before +++ titleHeader +++ toc +++ blocks' +++
144+-- thebody = before +++ titleHeader +++ toc +++ blocks' +++
144− footnoteSection notes +++ after
145+-- footnoteSection notes +++ after
145− in if writerStandalone opts
146+-- in if writerStandalone opts
146− then head' +++ body thebody
147+-- then head' +++ body thebody
147− else thebody
148+-- else thebody
148
149
149-- | Like Text.XHtml's identifier, but adds the writerIdentifierPrefix
150-- | Like Text.XHtml's identifier, but adds the writerIdentifierPrefix
150prefixedId :: WriterOptions -> String -> HtmlAttr
151prefixedId :: WriterOptions -> String -> HtmlAttr
src/Text/Pandoc/Writers/LaTeX.hs+2−4
@@ -57,15 +57,13 @@ pandocToLaTeX options (Pandoc (Meta title authors date) blocks) = do
57 then return ""
57 then return ""
58 else liftM render $ inlineListToLaTeX title
58 else liftM render $ inlineListToLaTeX title
59 let context = writerVariables options ++
59 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 "")
63 , ("body", main)
61 , ("body", main)
64 , ("title", titletext)
62 , ("title", titletext)
65 , ("authors", intercalate "\\\\" $ map stringToLaTeX authors)
63 , ("authors", intercalate "\\\\" $ map stringToLaTeX authors)
66 , ("date", stringToLaTeX date) ]
64 , ("date", stringToLaTeX date) ]
67 let templ = if writerStandalone options
65 let templ = if writerStandalone options
68− then writerHeader options
66+ then writerTemplate options
69 else "$if(toc)$\\tableofcontents\n$endif$" ++
67 else "$if(toc)$\\tableofcontents\n$endif$" ++
70 "$if(before)$$before$\n$endif$" ++
68 "$if(before)$$before$\n$endif$" ++
71 "$body$$if(after)$$after$\n$endif$"
69 "$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) ([],[])
48-- | Return groff man representation of document.
48-- | Return groff man representation of document.
49pandocToMan :: WriterOptions -> Pandoc -> State WriterState Doc
49pandocToMan :: WriterOptions -> Pandoc -> State WriterState Doc
50pandocToMan opts (Pandoc meta blocks) = do
50pandocToMan opts (Pandoc meta blocks) = do
51+ return empty -- TODO
51− let before = writerIncludeBefore opts
52+-- let before = writerIncludeBefore opts
52− let after = writerIncludeAfter opts
53+-- let after = writerIncludeAfter opts
53− let before' = if null before then empty else text before
54+-- let before' = if null before then empty else text before
54− let after' = if null after then empty else text after
55+-- let after' = if null after then empty else text after
55− (head', foot) <- metaToMan opts meta
56+-- (head', foot) <- metaToMan opts meta
56− body <- blockListToMan opts blocks
57+-- body <- blockListToMan opts blocks
57− (notes, preprocessors) <- get
58+-- (notes, preprocessors) <- get
58− let preamble = if null preprocessors || not (writerStandalone opts)
59+-- let preamble = if null preprocessors || not (writerStandalone opts)
59− then empty
60+-- then empty
60− else text $ ".\\\" " ++ concat (nub preprocessors)
61+-- else text $ ".\\\" " ++ concat (nub preprocessors)
61− notes' <- notesToMan opts (reverse notes)
62+-- notes' <- notesToMan opts (reverse notes)
62− return $ preamble $$ head' $$ before' $$ body $$ notes' $$ foot $$ after'
63+-- return $ preamble $$ head' $$ before' $$ body $$ notes' $$ foot $$ after'
63
64
64-- | Insert bibliographic information into Man header and footer.
65-- | Insert bibliographic information into Man header and footer.
65metaToMan :: WriterOptions -- ^ Options, including Man header
66metaToMan :: WriterOptions -- ^ Options, including Man header
src/Text/Pandoc/Writers/Markdown.hs+22−21
@@ -50,27 +50,28 @@ writeMarkdown opts document =
50-- | Return markdown representation of document.
50-- | Return markdown representation of document.
51pandocToMarkdown :: WriterOptions -> Pandoc -> State WriterState Doc
51pandocToMarkdown :: WriterOptions -> Pandoc -> State WriterState Doc
52pandocToMarkdown opts (Pandoc meta blocks) = do
52pandocToMarkdown opts (Pandoc meta blocks) = do
53+ return empty -- TODO
53− let before = writerIncludeBefore opts
54+-- let before = writerIncludeBefore opts
54− let after = writerIncludeAfter opts
55+-- let after = writerIncludeAfter opts
55− let header = writerHeader opts
56+-- let header = writerHeader opts
56− let before' = if null before then empty else text before
57+-- let before' = if null before then empty else text before
57− let after' = if null after then empty else text after
58+-- let after' = if null after then empty else text after
58− let header' = if null header then empty else text header
59+-- let header' = if null header then empty else text header
59− metaBlock <- metaToMarkdown opts meta
60+-- metaBlock <- metaToMarkdown opts meta
60− let head' = if writerStandalone opts
61+-- let head' = if writerStandalone opts
61− then metaBlock $+$ header'
62+-- then metaBlock $+$ header'
62− else empty
63+-- else empty
63− let headerBlocks = filter isHeaderBlock blocks
64+-- let headerBlocks = filter isHeaderBlock blocks
64− let toc = if writerTableOfContents opts
65+-- let toc = if writerTableOfContents opts
65− then tableOfContents opts headerBlocks
66+-- then tableOfContents opts headerBlocks
66− else empty
67+-- else empty
67− body <- blockListToMarkdown opts blocks
68+-- body <- blockListToMarkdown opts blocks
68− (notes, _) <- get
69+-- (notes, _) <- get
69− notes' <- notesToMarkdown opts (reverse notes)
70+-- notes' <- notesToMarkdown opts (reverse notes)
70− (_, refs) <- get -- note that the notes may contain refs
71+-- (_, refs) <- get -- note that the notes may contain refs
71− refs' <- keyTableToMarkdown opts (reverse refs)
72+-- refs' <- keyTableToMarkdown opts (reverse refs)
72− return $ head' $+$ before' $+$ toc $+$ body $+$ text "" $+$
73+-- return $ head' $+$ before' $+$ toc $+$ body $+$ text "" $+$
73− notes' $+$ text "" $+$ refs' $+$ after'
74+-- notes' $+$ text "" $+$ refs' $+$ after'
74
75
75-- | Return markdown representation of reference key table.
76-- | Return markdown representation of reference key table.
76keyTableToMarkdown :: WriterOptions -> KeyTable -> State WriterState Doc
77keyTableToMarkdown :: WriterOptions -> KeyTable -> State WriterState Doc
src/Text/Pandoc/Writers/MediaWiki.hs+15−14
@@ -52,20 +52,21 @@ writeMediaWiki opts document =
52-- | Return MediaWiki representation of document.
52-- | Return MediaWiki representation of document.
53pandocToMediaWiki :: WriterOptions -> Pandoc -> State WriterState String
53pandocToMediaWiki :: WriterOptions -> Pandoc -> State WriterState String
54pandocToMediaWiki opts (Pandoc _ blocks) = do
54pandocToMediaWiki opts (Pandoc _ blocks) = do
55+ return "" -- TODO
55− let before = writerIncludeBefore opts
56+-- let before = writerIncludeBefore opts
56− let after = writerIncludeAfter opts
57+-- let after = writerIncludeAfter opts
57− let head' = if writerStandalone opts
58+-- let head' = if writerStandalone opts
58− then writerHeader opts
59+-- then writerHeader opts
59− else ""
60+-- else ""
60− let toc = if writerTableOfContents opts
61+-- let toc = if writerTableOfContents opts
61− then "__TOC__\n"
62+-- then "__TOC__\n"
62− else ""
63+-- else ""
63− body <- blockListToMediaWiki opts blocks
64+-- body <- blockListToMediaWiki opts blocks
64− notesExist <- get >>= return . stNotes
65+-- notesExist <- get >>= return . stNotes
65− let notes = if notesExist
66+-- let notes = if notesExist
66− then "\n== Notes ==\n<references />"
67+-- then "\n== Notes ==\n<references />"
67− else ""
68+-- else ""
68− return $ head' ++ before ++ toc ++ body ++ after ++ notes
69+-- return $ head' ++ before ++ toc ++ body ++ after ++ notes
69
70
70-- | Escape special characters for MediaWiki.
71-- | Escape special characters for MediaWiki.
71escapeString :: String -> String
72escapeString :: String -> String
src/Text/Pandoc/Writers/OpenDocument.hs+23−22
@@ -180,28 +180,29 @@ authorToOpenDocument name =
180-- | Convert Pandoc document to string in OpenDocument format.
180-- | Convert Pandoc document to string in OpenDocument format.
181writeOpenDocument :: WriterOptions -> Pandoc -> String
181writeOpenDocument :: WriterOptions -> Pandoc -> String
182writeOpenDocument opts (Pandoc (Meta title authors date) blocks) =
182writeOpenDocument opts (Pandoc (Meta title authors date) blocks) =
183+ "" -- TODO
183− let root = inTags True "office:document-content" openDocumentNameSpaces
184+-- let root = inTags True "office:document-content" openDocumentNameSpaces
184− header = when (writerStandalone opts) $ text (writerHeader opts)
185+-- header = when (writerStandalone opts) $ text (writerHeader opts)
185− title' = case runState (wrap opts title) defaultWriterState of
186+-- title' = case runState (wrap opts title) defaultWriterState of
186− (t,_) -> if isEmpty t then empty else inHeaderTags 1 t
187+-- (t,_) -> if isEmpty t then empty else inHeaderTags 1 t
187− authors' = when (authors /= []) $ vcat (map authorToOpenDocument authors)
188+-- authors' = when (authors /= []) $ vcat (map authorToOpenDocument authors)
188− date' = when (date /= []) $
189+-- date' = when (date /= []) $
189− inParagraphTagsWithStyle "Date" (text $ escapeStringForXML date)
190+-- inParagraphTagsWithStyle "Date" (text $ escapeStringForXML date)
190− meta = when (writerStandalone opts) $ title' $$ authors' $$ date'
191+-- meta = when (writerStandalone opts) $ title' $$ authors' $$ date'
191− before = writerIncludeBefore opts
192+-- before = writerIncludeBefore opts
192− after = writerIncludeAfter opts
193+-- after = writerIncludeAfter opts
193− (doc, s) = runState (blocksToOpenDocument opts blocks) defaultWriterState
194+-- (doc, s) = runState (blocksToOpenDocument opts blocks) defaultWriterState
194− body = (if null before then empty else text before) $$
195+-- body = (if null before then empty else text before) $$
195− doc $$
196+-- doc $$
196− (if null after then empty else text after)
197+-- (if null after then empty else text after)
197− body' = if writerStandalone opts
198+-- body' = if writerStandalone opts
198− then inTagsIndented "office:body" $
199+-- then inTagsIndented "office:body" $
199− inTagsIndented "office:text" (meta $$ body)
200+-- inTagsIndented "office:text" (meta $$ body)
200− else body
201+-- else body
201− styles = stTableStyles s ++ stParaStyles s ++ stTextStyles s
202+-- styles = stTableStyles s ++ stParaStyles s ++ stTextStyles s
202− listStyle (n,l) = inTags True "text:list-style" [("style:name", "L" ++ show n)] (vcat l)
203+-- listStyle (n,l) = inTags True "text:list-style" [("style:name", "L" ++ show n)] (vcat l)
203− listStyles = map listStyle (stListStyles s)
204+-- listStyles = map listStyle (stListStyles s)
204− in render $ header $$ root (generateStyles (styles ++ listStyles) $$ body' $$ text "")
205+-- in render $ header $$ root (generateStyles (styles ++ listStyles) $$ body' $$ text "")
205
206
206withParagraphStyle :: WriterOptions -> String -> [Block] -> State WriterState Doc
207withParagraphStyle :: WriterOptions -> String -> [Block] -> State WriterState Doc
207withParagraphStyle o s (b:bs)
208withParagraphStyle o s (b:bs)
src/Text/Pandoc/Writers/RST.hs+21−20
@@ -57,26 +57,27 @@ writeRST opts document =
57-- | Return RST representation of document.
57-- | Return RST representation of document.
58pandocToRST :: Pandoc -> State WriterState Doc
58pandocToRST :: Pandoc -> State WriterState Doc
59pandocToRST (Pandoc meta blocks) = do
59pandocToRST (Pandoc meta blocks) = do
60+ return empty -- TODO
60− opts <- get >>= (return . stOptions)
61+-- opts <- get >>= (return . stOptions)
61− let before = writerIncludeBefore opts
62+-- let before = writerIncludeBefore opts
62− after = writerIncludeAfter opts
63+-- after = writerIncludeAfter opts
63− header = writerHeader opts
64+-- header = writerHeader opts
64− before' = if null before then empty else text before
65+-- before' = if null before then empty else text before
65− after' = if null after then empty else text after
66+-- after' = if null after then empty else text after
66− header' = if null header then empty else text header
67+-- header' = if null header then empty else text header
67− metaBlock <- metaToRST opts meta
68+-- metaBlock <- metaToRST opts meta
68− let head' = if (writerStandalone opts)
69+-- let head' = if (writerStandalone opts)
69− then metaBlock $+$ header'
70+-- then metaBlock $+$ header'
70− else empty
71+-- else empty
71− body <- blockListToRST blocks
72+-- body <- blockListToRST blocks
72− includes <- get >>= (return . concat . stIncludes)
73+-- includes <- get >>= (return . concat . stIncludes)
73− let includes' = if null includes then empty else text includes
74+-- let includes' = if null includes then empty else text includes
74− notes <- get >>= (notesToRST . reverse . stNotes)
75+-- notes <- get >>= (notesToRST . reverse . stNotes)
75− -- note that the notes may contain refs, so we do them first
76+-- -- note that the notes may contain refs, so we do them first
76− refs <- get >>= (keyTableToRST . reverse . stLinks)
77+-- refs <- get >>= (keyTableToRST . reverse . stLinks)
77− pics <- get >>= (pictTableToRST . reverse . stImages)
78+-- pics <- get >>= (pictTableToRST . reverse . stImages)
78− return $ head' $+$ before' $+$ includes' $+$ body $+$ notes $+$ text "" $+$
79+-- return $ head' $+$ before' $+$ includes' $+$ body $+$ notes $+$ text "" $+$
79− refs $+$ pics $+$ after'
80+-- refs $+$ pics $+$ after'
80
81
81-- | Return RST representation of reference key table.
82-- | Return RST representation of reference key table.
82keyTableToRST :: KeyTable -> State WriterState Doc
83keyTableToRST :: KeyTable -> State WriterState Doc
src/Text/Pandoc/Writers/RTF.hs+12−11
@@ -37,17 +37,18 @@ import Data.Char ( ord, isDigit )
37-- | Convert Pandoc to a string in rich text format.
37-- | Convert Pandoc to a string in rich text format.
38writeRTF :: WriterOptions -> Pandoc -> String
38writeRTF :: WriterOptions -> Pandoc -> String
39writeRTF options (Pandoc meta blocks) =
39writeRTF options (Pandoc meta blocks) =
40+ "" -- TODO
40− let head' = if writerStandalone options
41+-- let head' = if writerStandalone options
41− then rtfHeader (writerHeader options) meta
42+-- then rtfHeader (writerHeader options) meta
42− else ""
43+-- else ""
43− toc = if writerTableOfContents options
44+-- toc = if writerTableOfContents options
44− then tableOfContents $ filter isHeaderBlock blocks
45+-- then tableOfContents $ filter isHeaderBlock blocks
45− else ""
46+-- else ""
46− foot = if writerStandalone options then "\n}\n" else ""
47+-- foot = if writerStandalone options then "\n}\n" else ""
47− body = writerIncludeBefore options ++
48+-- body = writerIncludeBefore options ++
48− concatMap (blockToRTF 0 AlignDefault) blocks ++
49+-- concatMap (blockToRTF 0 AlignDefault) blocks ++
49− writerIncludeAfter options
50+-- writerIncludeAfter options
50− in head' ++ toc ++ body ++ foot
51+-- in head' ++ toc ++ body ++ foot
51
52
52-- | Construct table of contents from list of header blocks.
53-- | Construct table of contents from list of header blocks.
53tableOfContents :: [Block] -> String
54tableOfContents :: [Block] -> String
src/Text/Pandoc/Writers/Texinfo.hs+46−44
@@ -68,56 +68,58 @@ wrapTop (Pandoc (Meta title authors date) blocks) =
68
68
69pandocToTexinfo :: WriterOptions -> Pandoc -> State WriterState Doc
69pandocToTexinfo :: WriterOptions -> Pandoc -> State WriterState Doc
70pandocToTexinfo options (Pandoc meta blocks) = do
70pandocToTexinfo options (Pandoc meta blocks) = do
71+ return empty -- TODO
71− main <- blockListToTexinfo blocks
72+-- main <- blockListToTexinfo blocks
72− head' <- if writerStandalone options
73+-- head' <- if writerStandalone options
73− then texinfoHeader options meta
74+-- then texinfoHeader options meta
74− else return empty
75+-- else return empty
75− let before = if null (writerIncludeBefore options)
76+-- let before = if null (writerIncludeBefore options)
76− then empty
77+-- then empty
77− else text (writerIncludeBefore options)
78+-- else text (writerIncludeBefore options)
78− let after = if null (writerIncludeAfter options)
79+-- let after = if null (writerIncludeAfter options)
79− then empty
80+-- then empty
80− else text (writerIncludeAfter options)
81+-- else text (writerIncludeAfter options)
81− let body = before $$ main $$ after
82+-- let body = before $$ main $$ after
82− -- XXX toc untested
83+-- -- XXX toc untested
83− let toc = if writerTableOfContents options
84+-- let toc = if writerTableOfContents options
84− then text "@contents"
85+-- then text "@contents"
85− else empty
86+-- else empty
86− let foot = if writerStandalone options
87+-- let foot = if writerStandalone options
87− then text "@bye"
88+-- then text "@bye"
88− else empty
89+-- else empty
89− return $ head' $$ toc $$ body $$ foot
90+-- return $ head' $$ toc $$ body $$ foot
90
91
91-- | Insert bibliographic information into Texinfo header.
92-- | Insert bibliographic information into Texinfo header.
92texinfoHeader :: WriterOptions -- ^ Options, including Texinfo header
93texinfoHeader :: WriterOptions -- ^ Options, including Texinfo header
93 -> Meta -- ^ Meta with bibliographic information
94 -> Meta -- ^ Meta with bibliographic information
94 -> State WriterState Doc
95 -> State WriterState Doc
95texinfoHeader options (Meta title authors date) = do
96texinfoHeader options (Meta title authors date) = do
97+ return empty -- TODO
96− titletext <- if null title
98+-- titletext <- if null title
97− then return empty
99+-- then return empty
98− else do
100+-- else do
99− t <- inlineListToTexinfo title
101+-- t <- inlineListToTexinfo title
100− return $ text "@title " <> t
102+-- return $ text "@title " <> t
101− headerIncludes <- get >>= return . S.toList . stIncludes
103+-- headerIncludes <- get >>= return . S.toList . stIncludes
102− let extras = text $ unlines headerIncludes
104+-- let extras = text $ unlines headerIncludes
103− let authorstext = map makeAuthor authors
105+-- let authorstext = map makeAuthor authors
104− let datetext = if date == ""
106+-- let datetext = if date == ""
105− then empty
107+-- then empty
106− else text $ stringToTexinfo date
108+-- else text $ stringToTexinfo date
107−
109+--
108− let baseHeader = case writerHeader options of
110+-- let baseHeader = case writerHeader options of
109− "" -> empty
111+-- "" -> empty
110− x -> text x
112+-- x -> text x
111− let header = text "@documentencoding utf-8" $$ baseHeader $$ extras
113+-- let header = text "@documentencoding utf-8" $$ baseHeader $$ extras
112− return $ text "\\input texinfo" $$
114+-- return $ text "\\input texinfo" $$
113− header $$
115+-- header $$
114− text "@ifnottex" $$
116+-- text "@ifnottex" $$
115− text "@paragraphindent 0" $$
117+-- text "@paragraphindent 0" $$
116− text "@end ifnottex" $$
118+-- text "@end ifnottex" $$
117− text "@titlepage" $$
119+-- text "@titlepage" $$
118− titletext $$ vcat authorstext $$
120+-- titletext $$ vcat authorstext $$
119− datetext $$
121+-- datetext $$
120− text "@end titlepage"
122+-- text "@end titlepage"
121
123
122makeAuthor :: String -> Doc
124makeAuthor :: String -> Doc
123makeAuthor author = text $ "@author " ++ (stringToTexinfo author)
125makeAuthor author = text $ "@author " ++ (stringToTexinfo author)
src/pandoc.hs+20−21
@@ -138,9 +138,6 @@ data Opt = Opt
138 , optTemplate :: String -- ^ Custom template
138 , optTemplate :: String -- ^ Custom template
139 , optVariables :: [(String,String)] -- ^ Template variables to set
139 , optVariables :: [(String,String)] -- ^ Template variables to set
140 , optIncludeInHeader :: String -- ^ File to include in header
140 , 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
144 , optOutputFile :: String -- ^ Name of output file
141 , optOutputFile :: String -- ^ Name of output file
145 , optNumberSections :: Bool -- ^ Number sections in LaTeX
142 , optNumberSections :: Bool -- ^ Number sections in LaTeX
146 , optIncremental :: Bool -- ^ Use incremental lists in S5
143 , optIncremental :: Bool -- ^ Use incremental lists in S5
@@ -177,9 +174,6 @@ defaultOpts = Opt
177 , optTemplate = ""
174 , optTemplate = ""
178 , optVariables = []
175 , optVariables = []
179 , optIncludeInHeader = ""
176 , optIncludeInHeader = ""
180− , optIncludeBeforeBody = ""
181− , optIncludeAfterBody = ""
182− , optTitlePrefix = ""
183 , optOutputFile = "-" -- "-" means stdout
177 , optOutputFile = "-" -- "-" means stdout
184 , optNumberSections = False
178 , optNumberSections = False
185 , optIncremental = False
179 , optIncremental = False
@@ -367,18 +361,28 @@ options =
367 , Option "B" ["include-before-body"]
361 , Option "B" ["include-before-body"]
368 (ReqArg
362 (ReqArg
369 (\arg opt -> do
363 (\arg opt -> do
370− let old = optIncludeBeforeBody opt
371 text <- readFile arg
364 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 })
373 "FILENAME")
372 "FILENAME")
374 "" -- "File to include before document body"
373 "" -- "File to include before document body"
375
374
376 , Option "A" ["include-after-body"]
375 , Option "A" ["include-after-body"]
377 (ReqArg
376 (ReqArg
378 (\arg opt -> do
377 (\arg opt -> do
379− let old = optIncludeAfterBody opt
380 text <- readFile arg
378 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 })
382 "FILENAME")
386 "FILENAME")
383 "" -- "File to include after document body"
387 "" -- "File to include after document body"
384
388
@@ -397,8 +401,10 @@ options =
397
401
398 , Option "T" ["title-prefix"]
402 , Option "T" ["title-prefix"]
399 (ReqArg
403 (ReqArg
400− (\arg opt -> return opt { optTitlePrefix = arg,
404+ (\arg opt -> do
405+ let newvars = ("title-prefix", arg) : optVariables opt
406+ return opt { optVariables = newvars,
401− optStandalone = True })
407+ optStandalone = True })
402 "STRING")
408 "STRING")
403 "" -- "String to prefix to HTML window title"
409 "" -- "String to prefix to HTML window title"
404
410
@@ -549,9 +555,6 @@ main = do
549 , optTableOfContents = toc
555 , optTableOfContents = toc
550 , optTemplate = template
556 , optTemplate = template
551 , optIncludeInHeader = includeHeader
557 , optIncludeInHeader = includeHeader
552− , optIncludeBeforeBody = includeBefore
553− , optIncludeAfterBody = includeAfter
554− , optTitlePrefix = titlePrefix
555 , optOutputFile = outputFile
558 , optOutputFile = outputFile
556 , optNumberSections = numberSections
559 , optNumberSections = numberSections
557 , optIncremental = incremental
560 , optIncremental = incremental
@@ -633,12 +636,10 @@ main = do
633 [("header-includes", includeHeader)] ++
636 [("header-includes", includeHeader)] ++
634 variables
637 variables
635 let writerOptions = WriterOptions { writerStandalone = standalone',
638 let writerOptions = WriterOptions { writerStandalone = standalone',
636− writerTemplate = defaultTemplate,
637− writerVariables = variables',
638− writerHeader = if null template
639+ writerTemplate = if null template
639 then defaultTemplate
640 then defaultTemplate
640 else template,
641 else template,
641− writerTitlePrefix = titlePrefix,
642+ writerVariables = variables',
642 writerTabStop = tabStop,
643 writerTabStop = tabStop,
643 writerTableOfContents = toc &&
644 writerTableOfContents = toc &&
644 writerName' /= "s5",
645 writerName' /= "s5",
@@ -647,8 +648,6 @@ main = do
647 writerIgnoreNotes = False,
648 writerIgnoreNotes = False,
648 writerIncremental = incremental,
649 writerIncremental = incremental,
649 writerNumberSections = numberSections,
650 writerNumberSections = numberSections,
650− writerIncludeBefore = includeBefore,
651− writerIncludeAfter = includeAfter,
652 writerStrictMarkdown = strict,
651 writerStrictMarkdown = strict,
653 writerReferenceLinks = referenceLinks,
652 writerReferenceLinks = referenceLinks,
654 writerWrapText = wrap,
653 writerWrapText = wrap,