Skip to content

Commit

Permalink
Add bullet, ordered, and definition lists
Browse files Browse the repository at this point in the history
  • Loading branch information
silby committed Sep 27, 2024
1 parent 2589dbb commit 2147b2f
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions src/Text/Pandoc/Readers/Mdoc.hs
Original file line number Diff line number Diff line change
Expand Up @@ -718,6 +718,45 @@ parseBd = do
emptyMacro "Ed"
return blk

parseItemList :: PandocMonad m => MdocParser m Blocks
parseItemList = do
f <- (choice (map literal ["-bullet", "-dash", "-hyphen", "-item"]) $> B.bulletList)
<|> literal "-enum" $> B.orderedList
optional (literal "-width" *> lit)
optional (literal "-offset" *> lit)
optional (literal "-compact")
eol
items <- many bulletItem
return $ f items
where
bulletItem = do
emptyMacro "It"
mconcat <$> many parseRegularBlock

parseDefinitionList :: PandocMonad m => MdocParser m Blocks
parseDefinitionList = do
choice $ map literal ["-hang", "-inset", "-ohang", "-tag"]
optional (literal "-width" *> lit)
optional (literal "-offset" *> lit)
optional (literal "-compact")
eol
items <- many dlItem
return $ B.definitionList items
where
dlItem = do
macro "It"
dt <- listHead >>= spacify
dd <- mconcat <$> many parseRegularBlock
return (dt, [dd])
-- TODO support Xo/Xc
listHead = many1 ((parseInlineMacro <|> litsAndDelimsToInlines)) <* optional eol

parseBl :: PandocMonad m => MdocParser m Blocks
parseBl = do
macro "Bl"
blk <- parseItemList <|> parseDefinitionList
emptyMacro "El"
return blk

skipBlanks :: PandocMonad m => MdocParser m Blocks
skipBlanks = many1 blank *> mempty
Expand Down Expand Up @@ -746,6 +785,7 @@ parseRegularBlock =
, parsePara
, emptyMacro "Pp" *> mempty
, parseBd
, parseBl
, skipBlanks
]

Expand Down

0 comments on commit 2147b2f

Please sign in to comment.