diff options
author | John MacFarlane <jgm@berkeley.edu> | 2018-10-19 23:55:01 -0700 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2018-10-19 23:55:01 -0700 |
commit | c60ac7c9ab157abf5c0c6450b8c130c477cff3c7 (patch) | |
tree | f2402645b0c3fdae6b0246ae25304d9cc6bd07e6 /src/Text | |
parent | eaef8495366f799adefa71d4109a940dfd7d99a2 (diff) | |
download | pandoc-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')
-rw-r--r-- | src/Text/Pandoc/Readers/Man.hs | 20 |
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) |