Fix mistaken attempt to fix #11006.

Update the test so it reflects the right output, and fix the
solution.

Really closes #11006.
This commit is contained in:
John MacFarlane
2025-07-30 12:32:01 -07:00
parent 6dae03f719
commit 3e5babbb43
2 changed files with 36 additions and 19 deletions
+16 -19
View File
@@ -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
+20
View File
@@ -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
```