diff --git a/src/Text/Pandoc/Writers/Markdown.hs b/src/Text/Pandoc/Writers/Markdown.hs index cd072bdf6..b3bf8ac83 100644 --- a/src/Text/Pandoc/Writers/Markdown.hs +++ b/src/Text/Pandoc/Writers/Markdown.hs @@ -724,13 +724,8 @@ blockToMarkdown' opts (OrderedList (start,sty,delim) items) = do | otherwise = DefaultDelim let attribs = (start', sty', delim') let markers = orderedListMarkers attribs - let markers' = case variant of - Markua -> markers - _ -> map (\m -> if T.length m < 3 - then m <> T.replicate (3 - T.length m) " " - else m) markers contents <- inList $ - zipWithM (orderedListItemToMarkdown opts) markers' items + zipWithM (orderedListItemToMarkdown opts) markers items return $ (if isTightList items then vcat else vsep) contents <> blankline blockToMarkdown' opts (DefinitionList items) = do contents <- inList $ mapM (definitionListItemToMarkdown opts) items @@ -843,15 +838,18 @@ orderedListItemToMarkdown opts marker bs = do let exts = writerExtensions opts contents <- blockListToMarkdown opts $ taskListItemToAscii exts bs variant <- asks envVariant + let beginsWithCodeBlock = case bs of + CodeBlock{} : _ -> True + _ -> False let sps = case writerTabStop opts - T.length marker of - n | n > 0 -> literal $ T.replicate n " " - _ -> literal " " + _ | beginsWithCodeBlock -> 1 -- see #11762 + _ | variant == Markua -> 1 + n | n > 0 -> n + _ -> 1 let ind = if isEnabled Ext_four_space_rule opts then writerTabStop opts - else max (writerTabStop opts) (T.length marker + 1) - let start = case variant of - Markua -> literal marker <> " " - _ -> literal marker <> sps + else T.length marker + sps + let start = literal marker <> literal (T.replicate sps " ") -- remove trailing blank line if item ends with a tight list let contents' = if itemEndsWithTightList bs then chomp contents <> cr diff --git a/test/command/11762.md b/test/command/11762.md new file mode 100644 index 000000000..c9b824e81 --- /dev/null +++ b/test/command/11762.md @@ -0,0 +1,12 @@ +``` +% pandoc -f native -t commonmark | pandoc -f commonmark -t native +[ OrderedList + ( 1 , Decimal , Period ) + [ [ CodeBlock ( "" , [] , [] ) "hi" ] ] +] +^D +[ OrderedList + ( 1 , Decimal , Period ) + [ [ CodeBlock ( "" , [] , [] ) "hi" ] ] +] +``` diff --git a/test/writer.markua b/test/writer.markua index b4d760b1b..a0e2f5c1d 100644 --- a/test/writer.markua +++ b/test/writer.markua @@ -192,7 +192,7 @@ Multiple paragraphs: 1. Item 1, graf one. - Item 1. graf two. The quick brown fox jumped over the lazy dog’s back. + Item 1. graf two. The quick brown fox jumped over the lazy dog’s back. 2. Item 2. @@ -209,9 +209,9 @@ Here’s another: 1. First 2. Second: - * Fee - * Fie - * Foe + * Fee + * Fie + * Foe 3. Third Same thing but with paragraphs: @@ -220,9 +220,9 @@ Same thing but with paragraphs: 2. Second: - * Fee - * Fie - * Foe + * Fee + * Fie + * Foe 3. Third @@ -244,25 +244,25 @@ Same thing but with paragraphs: 3) and now 3 - with a continuation + with a continuation - i. sublist with roman numerals starting with i. - ii. more items - A) a subsublist - B) a subsublist + i. sublist with roman numerals starting with i. + ii. more items + A) a subsublist + B) a subsublist Nesting: D. Upper Alpha - I. Upper Roman. - 1) Decimal start with 1 - a) Lower alpha with paren + I. Upper Roman. + 1) Decimal start with 1 + a) Lower alpha with paren Autonumbering: 1. Autonumber. 2. More. - 1. Nested. + 1. Nested. Should not be a list item: