@@ -87,14 +87,39 @@ plainify = bottomUp go
8787 go (Cite _ cits) = SmallCaps cits
8888 go x = x
8989
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
95+
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
101+
102+plainTitleBlock :: Doc -> [Doc] -> Doc -> Doc
103+plainTitleBlock tit auths dat =
104+ tit <> cr <>
105+ (hcat (intersperse (text "; ") auths)) <> cr <>
106+ dat <> cr
107+
90108-- | Return markdown representation of document.
91109pandocToMarkdown :: WriterOptions -> Pandoc -> State WriterState String
92110pandocToMarkdown opts (Pandoc (Meta title authors date) blocks) = do
93111 title' <- inlineListToMarkdown opts title
94112 authors' <- mapM (inlineListToMarkdown opts) authors
95113 date' <- inlineListToMarkdown opts date
96− let titleblock = isEnabled Ext_pandoc_title_blocks opts &&
97− not (null title && null authors && null date)
114+ isPlain <- gets stPlain
115+ let titleblock = case True of
116+ _ | isPlain ->
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
98123 let headerBlocks = filter isHeaderBlock blocks
99124 let toc = if writerTableOfContents opts
100125 then tableOfContents opts headerBlocks
@@ -113,11 +138,9 @@ pandocToMarkdown opts (Pandoc (Meta title authors date) blocks) = do
113138 let context = writerVariables opts ++
114139 [ ("toc", render colwidth toc)
115140 , ("body", main)
116− , ("title", render colwidth title')
117− , ("date", render colwidth date')
118141 ] ++
119− [ ("titleblock", "yes") | titleblock ] ++
120− [ ("author", render colwidth a) | a <- authors' ]
142+ [ ("titleblock", render colwidth titleblock)
143+ | not (null title && null authors && null date) ]
121144 if writerStandalone opts
122145 then return $ renderTemplate context $ writerTemplate opts
123146 else return main