aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Text/Pandoc/Readers/Man.hs21
-rw-r--r--test/Tests/Readers/Man.hs4
-rw-r--r--test/man-reader.native24
3 files changed, 25 insertions, 24 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
diff --git a/test/Tests/Readers/Man.hs b/test/Tests/Readers/Man.hs
index 974dd1cb9..902ed71cc 100644
--- a/test/Tests/Readers/Man.hs
+++ b/test/Tests/Readers/Man.hs
@@ -33,10 +33,10 @@ tests = [
=?> (para $ strong $ emph $ text "foo bar")
, "H1" =:
".SH The header\n"
- =?> header 2 (text "The header")
+ =?> header 1 (text "The header")
, "H2" =:
".SS \"The header 2\""
- =?> header 3 (text "The header 2")
+ =?> header 2 (text "The header 2")
, "Macro args" =:
".B \"single arg with \"\"Q\"\"\""
=?> (para $ strong $ text "single arg with \"Q\"")
diff --git a/test/man-reader.native b/test/man-reader.native
index 1e10e2f11..2f45a60f3 100644
--- a/test/man-reader.native
+++ b/test/man-reader.native
@@ -2,42 +2,42 @@ Pandoc (Meta {unMeta = fromList [("title",MetaString "Pandoc Man tests")]})
[Header 1 ("",[],[]) [Str "Pandoc",Space,Str "Man",Space,Str "tests"]
,Para [Str "This",Space,Str "is",Space,Str "a",Space,Str "set",Space,Str "of",Space,Str "tests",Space,Str "for",Space,Str "pandoc."]
,Para [Str "*",Space,Str "*",Space,Str "*",Space,Str "*",Space,Str "*"]
-,Header 2 ("",[],[]) [Str "Headers"]
-,Header 2 ("",[],[]) [Str "Level",Space,Str "1"]
-,Header 3 ("",[],[]) [Str "Level",Space,Str "2"]
+,Header 1 ("",[],[]) [Str "Headers"]
+,Header 1 ("",[],[]) [Str "Level",Space,Str "1"]
+,Header 2 ("",[],[]) [Str "Level",Space,Str "2"]
,Para [Str "*",Space,Str "*",Space,Str "*",Space,Str "*",Space,Str "*"]
-,Header 2 ("",[],[]) [Str "Paragraphs"]
+,Header 1 ("",[],[]) [Str "Paragraphs"]
,Para [Str "Here's",Space,Str "a",Space,Str "regular",Space,Str "paragraph."]
,Para [Str "Another",Space,Str "paragraph",Space,Str "In",Space,Str "Markdown",Space,Str "1.0.0",Space,Str "and",Space,Str "earlier.",Space,Str "Version",Space,Str "8.",Space,Str "This",Space,Str "line",Space,Str "turns",Space,Str "into",Space,Str "a",Space,Str "list",Space,Str "item.",Space,Str "Because",Space,Str "a",Space,Str "hard-wrapped",Space,Str "line",Space,Str "in",Space,Str "the",Space,Str "middle",Space,Str "of",Space,Str "a",Space,Str "paragraph",Space,Str "looked",Space,Str "like",Space,Str "a",Space,Str "list",Space,Str "item."]
,Para [Str "There",Space,Str "should",Space,Str "be",Space,Str "a",Space,Str "hard",Space,Str "line",Space,Str "break"]
,Para [Str "here."]
,Para [Str "*",Space,Str "*",Space,Str "*",Space,Str "*",Space,Str "*"]
-,Header 2 ("",[],[]) [Str "Block",Space,Str "Quotes"]
+,Header 1 ("",[],[]) [Str "Block",Space,Str "Quotes"]
,Para [Str "Code",Space,Str "in",Space,Str "a",Space,Str "block",Space,Str "quote:"]
,CodeBlock ("",[],[]) "\nsub status {\n print \"working\";\n}"
,Para [Str "A",Space,Str "list:"]
,OrderedList (1,Decimal,Period)
[[Para [Str "item",Space,Str "one"]]
,[Para [Str "item",Space,Str "two"]]]
-,Header 2 ("",[],[]) [Str "Code",Space,Str "Blocks"]
+,Header 1 ("",[],[]) [Str "Code",Space,Str "Blocks"]
,Para [Str "Code:"]
,CodeBlock ("",[],[]) "\n---- (should be four hyphens)\n\nsub status {\n print \"working\";\n}\n"
,Para [Str "And:"]
,CodeBlock ("",[],[]) "\n\tthis code line is indented by one tab"
,Para [Str "*",Space,Str "*",Space,Str "*",Space,Str "*",Space,Str "*"]
-,Header 2 ("",[],[]) [Str "Lists"]
-,Header 3 ("",[],[]) [Str "Unordered"]
+,Header 1 ("",[],[]) [Str "Lists"]
+,Header 2 ("",[],[]) [Str "Unordered"]
,Para [Str "Asterisks:"]
,BulletList
[[Para [Str "asterisk",Space,Str "1"]]
,[Para [Str "asterisk",Space,Str "2"]]
,[Para [Str "asterisk",Space,Str "3"]]]
-,Header 3 ("",[],[]) [Str "Ordered"]
+,Header 2 ("",[],[]) [Str "Ordered"]
,OrderedList (1,Decimal,Period)
[[Para [Str "First"]]
,[Para [Str "Second"]]
,[Para [Str "Third"]]]
-,Header 3 ("",[],[]) [Str "Nested"]
+,Header 2 ("",[],[]) [Str "Nested"]
,BulletList
[[Para [Str "Tab"]
,BulletList
@@ -62,7 +62,7 @@ Pandoc (Meta {unMeta = fromList [("title",MetaString "Pandoc Man tests")]})
,[Para [Str "Fie"]]
,[Para [Str "Foe"]]]]
,[Para [Str "Third"]]]
-,Header 3 ("",[],[]) [Str "different",Space,Str "styles:"]
+,Header 2 ("",[],[]) [Str "different",Space,Str "styles:"]
,OrderedList (1,UpperAlpha,Period)
[[Para [Str "Upper",Space,Str "Alpha"]
,OrderedList (1,UpperRoman,Period)
@@ -72,7 +72,7 @@ Pandoc (Meta {unMeta = fromList [("title",MetaString "Pandoc Man tests")]})
,OrderedList (3,LowerAlpha,OneParen)
[[Para [Str "Lower",Space,Str "alpha",Space,Str "with",Space,Str "paren"]]]]]]]]]
,Para [Str "*",Space,Str "*",Space,Str "*",Space,Str "*",Space,Str "*"]
-,Header 2 ("",[],[]) [Str "Special",Space,Str "Characters"]
+,Header 1 ("",[],[]) [Str "Special",Space,Str "Characters"]
,Para [Str "AT&T",Space,Str "has",Space,Str "an",Space,Str "ampersand",Space,Str "in",Space,Str "their",Space,Str "name."]
,Para [Str "4",Space,Str "<",Space,Str "5."]
,Para [Str "6",Space,Str ">",Space,Str "5."]