aboutsummaryrefslogtreecommitdiff
path: root/src/Text
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2018-10-19 23:27:04 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2018-10-19 23:27:04 -0700
commit7dd06e96d784b093120e0f8e816c869184613ff9 (patch)
tree22aaada6dd2a00c2f45a7b149cdc04800434a277 /src/Text
parentcfa824b9779225ca13019925c5b3c6b59965b2a3 (diff)
downloadpandoc-7dd06e96d784b093120e0f8e816c869184613ff9.tar.gz
Man reader: Improved header parsing.
- .SH should be level 1, .SS level 2. - The header title can come on the next line.
Diffstat (limited to 'src/Text')
-rw-r--r--src/Text/Pandoc/Readers/Man.hs21
1 files changed, 11 insertions, 10 deletions
diff --git a/src/Text/Pandoc/Readers/Man.hs b/src/Text/Pandoc/Readers/Man.hs
index 4eeeeb825..dfe3b21c7 100644
--- a/src/Text/Pandoc/Readers/Man.hs
+++ b/src/Text/Pandoc/Readers/Man.hs
@@ -72,7 +72,6 @@ data ManToken = MStr RoffStr
| MLine [RoffStr]
| MMaybeLink String
| MEmptyLine
- | MHeader Int [RoffStr]
| MMacro MacroKind [RoffStr]
| MComment String
deriving Show
@@ -299,8 +298,6 @@ lexMacro = do
"BR" -> MMaybeLink joinedArgs
x | x `elem` ["BI", "IB"] -> MStr (joinedArgs, S.fromList [Italic, Bold])
x | x `elem` ["I", "IR", "RI"] -> MStr (joinedArgs, singleton Italic)
- "SH" -> MHeader 2 args
- "SS" -> MHeader 3 args
x | x `elem` [ "P", "PP", "LP", "sp"] -> MEmptyLine
_ -> MMacro macroName args
return tok
@@ -399,11 +396,6 @@ memptyLine = msatisfy isMEmptyLine where
isMEmptyLine MEmptyLine = True
isMEmptyLine _ = False
-mheader :: PandocMonad m => ManParser m ManToken
-mheader = msatisfy isMHeader where
- isMHeader (MHeader _ _) = True
- isMHeader _ = False
-
mmacro :: PandocMonad m => MacroKind -> ManParser m ManToken
mmacro mk = msatisfy isMMacro where
isMMacro (MMacro mk' _) | mk == mk' = True
@@ -524,8 +516,17 @@ parseCodeBlock = try $ do
parseHeader :: PandocMonad m => ManParser m Blocks
parseHeader = do
- (MHeader lvl ss) <- mheader
- return $ header lvl (mconcat $ intersperse B.space $ strToInlines <$> ss)
+ MMacro name args <- mmacro "SH" <|> mmacro "SS"
+ contents <- if null args
+ then do
+ MLine ils <- mline
+ return $ mconcat $ map strToInlines ils
+ else do
+ return $ mconcat
+ $ intersperse B.space
+ $ map strToInlines args
+ let lvl = if name == "SH" then 1 else 2
+ return $ header lvl contents
type ListBuilder = [Blocks] -> Blocks