Skip to content

Commit

Permalink
Allow Bl arguments in any order
Browse files Browse the repository at this point in the history
mdoc(7) somewhat implies that the arguments have to come in a specific
order when present and they often do but they don't always.
  • Loading branch information
silby committed Oct 30, 2024
1 parent d6c38c9 commit b01f539
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions src/Text/Pandoc/Readers/Mdoc.hs
Original file line number Diff line number Diff line change
Expand Up @@ -802,18 +802,19 @@ parseBd = do
emptyMacro "Ed"
return blk

skipListArguments :: PandocMonad m => MdocParser m ()
skipListArguments = do
optional (literal "-width" *> lit)
optional (literal "-offset" *> lit)
optional (literal "-compact")
return ()
skipListArgument :: (PandocMonad m) => MdocParser m ()
skipListArgument =
void $ choice
[ literal "-width" *> lit,
literal "-offset" *> lit,
literal "-compact"
]

parseItemList :: PandocMonad m => MdocParser m Blocks
parseItemList = do
f <- (choice (map literal ["-bullet", "-dash", "-hyphen", "-item"]) $> B.bulletList)
<|> literal "-enum" $> B.orderedList
skipListArguments
many skipListArgument
eol
items <- many bulletItem
return $ f items
Expand All @@ -825,7 +826,7 @@ parseItemList = do
parseDefinitionList :: PandocMonad m => MdocParser m Blocks
parseDefinitionList = do
choice $ map literal ["-hang", "-inset", "-ohang", "-tag"]
skipListArguments
many skipListArgument
eol
items <- many dlItem
return $ B.definitionList items
Expand All @@ -846,7 +847,7 @@ parseDefinitionList = do
parseColumnList :: PandocMonad m => MdocParser m Blocks
parseColumnList = do
literal "-column"
skipListArguments
many skipListArgument
_ <- litsToText -- XXX use the column widths?
eol
rows <- many listRow
Expand Down

0 comments on commit b01f539

Please sign in to comment.