diff options
| author | John MacFarlane <[email protected]> | 2025-07-30 12:32:01 -0700 |
|---|---|---|
| committer | John MacFarlane <[email protected]> | 2025-07-30 12:49:18 -0700 |
| commit | 3e5babbb43666f666bae467f3fd07d6ce06e2133 (patch) | |
| tree | db9127abab6b39b2c9bd249da9947c70061d7c07 | |
| parent | 6dae03f719b4b809a38ff7cc361be3b46447b87d (diff) | |
Fix mistaken attempt to fix #11006.
Update the test so it reflects the right output, and fix the
solution.
Really closes #11006.
| -rw-r--r-- | src/Text/Pandoc/Writers/AsciiDoc.hs | 35 | ||||
| -rw-r--r-- | test/command/11006.md | 20 |
2 files changed, 36 insertions, 19 deletions
diff --git a/src/Text/Pandoc/Writers/AsciiDoc.hs b/src/Text/Pandoc/Writers/AsciiDoc.hs index 333b62a74..fb0ce0db1 100644 --- a/src/Text/Pandoc/Writers/AsciiDoc.hs +++ b/src/Text/Pandoc/Writers/AsciiDoc.hs @@ -416,7 +416,7 @@ bulletListItemToAsciiDoc opts blocks = do let blocksWithTasks = if isLegacy then blocks else (taskListItemToAsciiDoc blocks) - contents <- foldM (addBlock opts) empty blocksWithTasks + contents <- snd <$> foldM (addBlock opts) (False, empty) blocksWithTasks modify $ \s -> s{ bulletListLevel = lev } let marker = text (replicate (lev + 1) '*') return $ marker <> text " " <> listBegin blocksWithTasks <> @@ -433,27 +433,24 @@ taskListItemToAsciiDoc = handleTaskListItem toAd listExt listExt = extensionsFromList [Ext_task_lists] addBlock :: PandocMonad m - => WriterOptions -> Doc Text -> Block -> ADW m (Doc Text) -addBlock opts d b = do + => WriterOptions -> (Bool, Doc Text) -> Block -> ADW m (Bool, Doc Text) +addBlock opts (containsContinuation, d) b = do x <- chomp <$> blockToAsciiDoc opts b return $ case b of BulletList{} - -> case d of - Concat (Concat _ CarriageReturn) (Text 1 "+") - -> d <> blankline <> x -- see #11006 - _ -> d <> cr <> x - OrderedList listAttr _ - -> case d of - Concat (Concat _ CarriageReturn) (Text 1 "+") - | (1, DefaultStyle, _) <- listAttr - -> d <> blankline <> x -- see #11006 - _ -> d <> cr <> x - Para (Math DisplayMath _:_) -> d <> cr <> x - Plain (Math DisplayMath _:_) -> d <> cr <> x - Para{} | isEmpty d -> x - Plain{} | isEmpty d -> x - _ -> d <> cr <> text "+" <> cr <> x + | containsContinuation -> (False, d <> blankline <> x) -- see #11006 + | otherwise -> (False, d <> cr <> x) + OrderedList (start, sty, _) _ + | containsContinuation + , start == 1 + , sty == DefaultStyle -> (False, d <> blankline <> x) -- see #11006 + | otherwise -> (False, d <> cr <> x) + Para (Math DisplayMath _:_) -> (containsContinuation, d <> cr <> x) + Plain (Math DisplayMath _:_) -> (containsContinuation, d <> cr <> x) + Para{} | isEmpty d -> (containsContinuation, x) + Plain{} | isEmpty d -> (containsContinuation, x) + _ -> (True, d <> cr <> text "+" <> cr <> x) listBegin :: [Block] -> Doc Text listBegin blocks = @@ -473,7 +470,7 @@ orderedListItemToAsciiDoc :: PandocMonad m orderedListItemToAsciiDoc opts blocks = do lev <- gets orderedListLevel modify $ \s -> s{ orderedListLevel = lev + 1 } - contents <- foldM (addBlock opts) empty blocks + contents <- snd <$> foldM (addBlock opts) (False, empty) blocks modify $ \s -> s{ orderedListLevel = lev } let marker = text (replicate (lev + 1) '.') return $ marker <> text " " <> listBegin blocks <> contents <> cr diff --git a/test/command/11006.md b/test/command/11006.md index 852256747..585d3556c 100644 --- a/test/command/11006.md +++ b/test/command/11006.md @@ -20,10 +20,21 @@ <ol><li>Nested item</li></ol> </li> </ol> + +<p>With non-default attributes:</p> + +<ol> + <li> + <p>Paragraph one</p> + <p>Paragraph two to force a list continuation</p> + <ol start=5><li>Nested item</li></ol> + </li> +</ol> ^D * Paragraph one + Paragraph two to force a list continuation + ** First nested ** Second nested @@ -32,5 +43,14 @@ How about ordered lists? . Paragraph one + Paragraph two to force a list continuation + +.. Nested item + +With non-default attributes: + +. Paragraph one ++ +Paragraph two to force a list continuation +[start=5] .. Nested item ``` |
