@@ -87,14 +87,39 @@ plainify = bottomUp go
87 go (Cite _ cits) = SmallCaps cits
87 go (Cite _ cits) = SmallCaps cits
90+pandocTitleBlock :: Doc -> [Doc] -> Doc -> Doc
91+pandocTitleBlock tit auths dat =
92+ hang 2 (text "% ") tit <> cr <>
93+ hang 2 (text "% ") (hcat (intersperse (text "; ") auths)) <> cr <>
94+ hang 2 (text "% ") dat <> cr
96+mmdTitleBlock :: Doc -> [Doc] -> Doc -> Doc
97+mmdTitleBlock tit auths dat =
98+ hang 8 (text "Title: ") tit <> cr <>
99+ hang 8 (text "Author: ") (hcat (intersperse (text "; ") auths)) <> cr <>
100+ hang 8 (text "Date: ") dat <> cr
102+plainTitleBlock :: Doc -> [Doc] -> Doc -> Doc
103+plainTitleBlock tit auths dat =
105+ (hcat (intersperse (text "; ") auths)) <> cr <>
90-- | Return markdown representation of document.
108-- | Return markdown representation of document.
91pandocToMarkdown :: WriterOptions -> Pandoc -> State WriterState String
109pandocToMarkdown :: WriterOptions -> Pandoc -> State WriterState String
92pandocToMarkdown opts (Pandoc (Meta title authors date) blocks) = do
110pandocToMarkdown opts (Pandoc (Meta title authors date) blocks) = do
93 title' <- inlineListToMarkdown opts title
111 title' <- inlineListToMarkdown opts title
94 authors' <- mapM (inlineListToMarkdown opts) authors
112 authors' <- mapM (inlineListToMarkdown opts) authors
95 date' <- inlineListToMarkdown opts date
113 date' <- inlineListToMarkdown opts date
96− let titleblock = isEnabled Ext_pandoc_title_blocks opts &&
114+ isPlain <- gets stPlain
97− not (null title && null authors && null date)
115+ let titleblock = case True of
117+ plainTitleBlock title' authors' date'
118+ | isEnabled Ext_pandoc_title_block opts ->
119+ pandocTitleBlock title' authors' date'
120+ | isEnabled Ext_mmd_title_block opts ->
121+ mmdTitleBlock title' authors' date'
122+ | otherwise -> empty
98 let headerBlocks = filter isHeaderBlock blocks
123 let headerBlocks = filter isHeaderBlock blocks
99 let toc = if writerTableOfContents opts
124 let toc = if writerTableOfContents opts
100 then tableOfContents opts headerBlocks
125 then tableOfContents opts headerBlocks
@@ -113,11 +138,9 @@ pandocToMarkdown opts (Pandoc (Meta title authors date) blocks) = do
113 let context = writerVariables opts ++
138 let context = writerVariables opts ++
114 [ ("toc", render colwidth toc)
139 [ ("toc", render colwidth toc)
115 , ("body", main)
140 , ("body", main)
116− , ("title", render colwidth title')
117− , ("date", render colwidth date')
119− [ ("titleblock", "yes") | titleblock ] ++
120− [ ("author", render colwidth a) | a <- authors' ]
142+ [ ("titleblock", render colwidth titleblock)
143+ | not (null title && null authors && null date) ]
121 if writerStandalone opts
144 if writerStandalone opts
122 then return $ renderTemplate context $ writerTemplate opts
145 then return $ renderTemplate context $ writerTemplate opts
123 else return main
146 else return main