From c9088677faec3758dfeda820fd76933544a1e037 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Wed, 28 Jun 2023 09:04:17 -0700 Subject: [PATCH] DokuWiki writer: fix lists with Div elements. The DokuWiki writer doesn't render Divs specially, so their presence in a list (e.g. because of custom-styles) need not prevent a regular DokuWiki list from being used. (Falling back to raw HTML in this case is pointless because no new information is given.) Closes #8920. --- src/Text/Pandoc/Writers/DokuWiki.hs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Text/Pandoc/Writers/DokuWiki.hs b/src/Text/Pandoc/Writers/DokuWiki.hs index e2d948125856..1450babefa35 100644 --- a/src/Text/Pandoc/Writers/DokuWiki.hs +++ b/src/Text/Pandoc/Writers/DokuWiki.hs @@ -102,7 +102,8 @@ blockToDokuWiki :: PandocMonad m blockToDokuWiki opts (Div _attrs bs) = do contents <- blockListToDokuWiki opts bs - return $ contents <> "\n" + indent <- asks stIndent + return $ contents <> if T.null indent then "\n" else "" blockToDokuWiki opts (Plain inlines) = inlineListToDokuWiki opts inlines @@ -310,6 +311,8 @@ isSimpleList x = isSimpleListItem :: [Block] -> Bool isSimpleListItem [] = True isSimpleListItem [x, CodeBlock{}] | isPlainOrPara x = True +isSimpleListItem (Div _ bs : ys) = -- see #8920 + isSimpleListItem bs && all isSimpleList ys isSimpleListItem (x:ys) | isPlainOrPara x = all isSimpleList ys isSimpleListItem _ = False