From b5a23f685bba0a2fd292dd477f68d85c36507a1f Mon Sep 17 00:00:00 2001 From: Evan Silberman Date: Thu, 31 Oct 2024 14:25:14 -0700 Subject: [PATCH] Support .It [stuff] Xo Add a command test since these seem annoying to write in the other format. --- src/Text/Pandoc/Readers/Mdoc.hs | 9 ++++----- test/command/mdoc-Bl-tag.md | 24 ++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 5 deletions(-) create mode 100644 test/command/mdoc-Bl-tag.md diff --git a/src/Text/Pandoc/Readers/Mdoc.hs b/src/Text/Pandoc/Readers/Mdoc.hs index 8a4b254df742..a3da8104122a 100644 --- a/src/Text/Pandoc/Readers/Mdoc.hs +++ b/src/Text/Pandoc/Readers/Mdoc.hs @@ -954,16 +954,15 @@ parseDefinitionList = do where dlItem = do macro "It" - dt <- (xoListHead <|> listHead) + dt <- (try xoListHead) <|> parseInline dd <- mconcat <$> many parseRegularBlock return (dt, [dd]) - -- TODO refactor, maybe extract the bodies of - -- lineEnclosure/multilineEnclosure - listHead = parseInline xoListHead = do + before <- option mempty parseInline macro "Xo" optional eol - many1Till parseInlines (emptyMacro "Xc") >>= spacify + after <- many1Till parseInlines (emptyMacro "Xc") + spacify (before:after) parseColumnList :: PandocMonad m => MdocParser m Blocks parseColumnList = do diff --git a/test/command/mdoc-Bl-tag.md b/test/command/mdoc-Bl-tag.md new file mode 100644 index 000000000000..f727cf4adcef --- /dev/null +++ b/test/command/mdoc-Bl-tag.md @@ -0,0 +1,24 @@ +``` +% pandoc -f mdoc -t native +.Bl -tag +.It one +one +.It Xo +two +.Xc +two +.It Em three Xo +three +.Xc +three +.El +^D +[ DefinitionList + [ ( [ Str "one" ] , [ [ Para [ Str "one" ] ] ] ) + , ( [ Str "two" ] , [ [ Para [ Str "two" ] ] ] ) + , ( [ Emph [ Str "three" ] , Space , Str "three" ] + , [ [ Para [ Str "three" ] ] ] + ) + ] +] +```