aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2021-01-07 16:41:25 -0800
committerJohn MacFarlane <jgm@berkeley.edu>2021-01-07 16:42:05 -0800
commit327e1428c5cdcb62beef6d2e00ab6f1d699256f0 (patch)
tree12a1127d8000477be335c67cefe2f9e073f04c7f
parentc0d8b186d142eb5e9f845de0a4ebcadd04c32dce (diff)
downloadpandoc-327e1428c5cdcb62beef6d2e00ab6f1d699256f0.tar.gz
gfm/commonmark writer: implement start number on ordered lists.
Previously they always started at 1, but according to the spec the start number is respected. Closes #7009.
-rw-r--r--src/Text/Pandoc/Writers/Markdown.hs5
-rw-r--r--test/command/7009.md8
2 files changed, 12 insertions, 1 deletions
diff --git a/src/Text/Pandoc/Writers/Markdown.hs b/src/Text/Pandoc/Writers/Markdown.hs
index c349fd713..1b5c00468 100644
--- a/src/Text/Pandoc/Writers/Markdown.hs
+++ b/src/Text/Pandoc/Writers/Markdown.hs
@@ -674,7 +674,10 @@ blockToMarkdown' opts (BulletList items) = do
contents <- inList $ mapM (bulletListItemToMarkdown opts) items
return $ (if isTightList items then vcat else vsep) contents <> blankline
blockToMarkdown' opts (OrderedList (start,sty,delim) items) = do
- let start' = if isEnabled Ext_startnum opts then start else 1
+ variant <- asks envVariant
+ let start' = if variant == Commonmark || isEnabled Ext_startnum opts
+ then start
+ else 1
let sty' = if isEnabled Ext_fancy_lists opts then sty else DefaultStyle
let delim' = if isEnabled Ext_fancy_lists opts then delim else DefaultDelim
let attribs = (start', sty', delim')
diff --git a/test/command/7009.md b/test/command/7009.md
new file mode 100644
index 000000000..a060c6076
--- /dev/null
+++ b/test/command/7009.md
@@ -0,0 +1,8 @@
+```
+% pandoc -t gfm
+3. a
+4. b
+^D
+3. a
+4. b
+```