Closed stooj closed 7 months ago
Thanks for your suggestion, I'll think about it.
This can be achieved by adding the following line in $HOME/.vimrc
let g:vmt_list_item_char = '1.'
It is strictly not a single character, but the code doesn't actually care.
Then when you invoke :GenTocGFM
in vim:
<!-- vim-markdown-toc GFM -->
1. [Description](#description)
1. [Setup](#setup)
1. [What helloworld affects](#what-helloworld-affects)
Nice. That's a good workaround for now, but although it's great for the html output, quite a lot of staff read the plain text versions, and an auto-incrementing list would be preferable.
Thanks for the workaround, @barrymw
The proposed workaround doesn't work for nested lists as vim-markdown-toc indents nested items by exactly two spaces, however, GitHub Flavoured Markdown (GFM) requires the list marker of a nested list to be exactly under the start of the text of the parent item or farther to the right of it (see e.g. here). This is 2 spaces for single-character markers (e.g. -
or *
), but it's 3 spaces for two-digits markers like 1.
.
For example, vim-markdown-toc would generate the following:
- Item 1
- Subitem 1
- Item2
And:
1. Item 1
1. Subitem 1
1. Item 2
The unordered list if valid GFM, however, the ordered list is not and is rendered incorrectly. To be valid GFM, it would need to be:
1. Item 1
1. Subitem 1
1. Item 2
EDIT to above comment: the number of spaces to indent child items with can actually be specified by setting g:vmt_list_indent_text
as explained in the docs.
For example:
:let g:vmt_list_indent_text = ' '
The above causes child items to be indented by 3 spaces (default is a tab or shiftwidth
number of spaces if expandtab
is set).
In that way, it should be possible to correctly generate any type of ordered nested list.
This issue should probably be closed.
@weibeld Thanks for your comment.
I find a numerically ordered toc more useful than an unordered list; the document has an order and sections are usually arranged in order.
Could we have an option to generate an ordered list instead of an unordered one?
eg: