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.
This commit is contained in:
John MacFarlane 2021-01-07 16:41:25 -08:00
parent c0d8b186d1
commit 327e1428c5
2 changed files with 12 additions and 1 deletions

View file

@ -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')

8
test/command/7009.md Normal file
View file

@ -0,0 +1,8 @@
```
% pandoc -t gfm
3. a
4. b
^D
3. a
4. b
```