aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Readers/Man.hs
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2018-10-19 23:55:01 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2018-10-19 23:55:01 -0700
commitc60ac7c9ab157abf5c0c6450b8c130c477cff3c7 (patch)
treef2402645b0c3fdae6b0246ae25304d9cc6bd07e6 /src/Text/Pandoc/Readers/Man.hs
parenteaef8495366f799adefa71d4109a940dfd7d99a2 (diff)
downloadpandoc-c60ac7c9ab157abf5c0c6450b8c130c477cff3c7.tar.gz
Man reader: improve treatment of .TH.
This should just add to metadata (title, date, section), and not produce a level-1 header. (That might be done in the template, depending on the output format.)
Diffstat (limited to 'src/Text/Pandoc/Readers/Man.hs')
-rw-r--r--src/Text/Pandoc/Readers/Man.hs20
1 files changed, 8 insertions, 12 deletions
diff --git a/src/Text/Pandoc/Readers/Man.hs b/src/Text/Pandoc/Readers/Man.hs
index 0898b3c6a..e4bf58081 100644
--- a/src/Text/Pandoc/Readers/Man.hs
+++ b/src/Text/Pandoc/Readers/Man.hs
@@ -396,18 +396,14 @@ mcomment = msatisfy isMComment where
parseTitle :: PandocMonad m => ManParser m Blocks
parseTitle = do
(MMacro _ args) <- mmacro "TH"
- if null args
- then return mempty
- else do
- let mantitle = fst $ head args
- modifyState (changeTitle mantitle)
- return $ header 1 $ text mantitle
- where
- changeTitle title pst =
- let meta = stateMeta pst
- metaUp = Meta $ M.insert "title" (MetaString title) (unMeta meta)
- in
- pst {stateMeta = metaUp}
+ let adjustMeta =
+ case map fst args of
+ (x:y:z:_) -> setMeta "title" x . setMeta "section" y . setMeta "date" z
+ [x,y] -> setMeta "title" x . setMeta "section" y
+ [x] -> setMeta "title" x
+ [] -> id
+ modifyState $ \st -> st{ stateMeta = adjustMeta $ stateMeta st }
+ return mempty
parseSkippedContent :: PandocMonad m => ManParser m Blocks
parseSkippedContent = mempty <$ (mcomment <|> memptyLine)