Vscode-markdown: TOC, nested list - indent per level: 4 spaces or 1 tab is required.

Created on 11 May 2020  ·  9Comments  ·  Source: yzhang-gh/vscode-markdown

TOC has only 2 spaces indent per level. 4 are required

When I wan't to convert markdown to HTML using php-markdown then the 2nd and 3rd level have the same indent. I created a bug there:

https://github.com/michelf/php-markdown/issues/312#event-3320618687

but the bug was closed. The answer:

The Markdown syntax says that nested lists need to be indented by 4 spaces or one tab. The way it actually works with this parser (which mimics the original parser's behavior) is that 1 to 4 spaces count as one indent.

I did not find an option where I can set the indent per level.
Is there an option?
Can you create an option?

This should be an option for all nested lists, not only for the TOC.

How can I reproduce it?

Go to settings and try to find an option :-)

table of contents Question Needs TagFix

All 9 comments

image

And please check markdown.extension.list.indentationSize option.

BTW, just to say that 2~4 spaces are allowed for unordered list item for general Markdown.
https://spec.commonmark.org/0.29/#example-226

Php-Markdown is a Markdown dialect.

Thank you, this works fine!

PHP Markdown has the exact same behavior here as the original Markdown.pl by John Gruber. CommonMark intentionally deviates from the original behavior because it is not that intuitive.

To be fair, parser implementations are all over the place when it comes to handling list indents. The only thing that works reliably across the board is 4-space or 1-tab.

Finally I know, how to create TOC with 4 space indent per level. This works, and this is fine.

@michelf Thanks for the reply.

I didn't intend to say that which one (PHP Markdown or CommonMark) is better. It is just a matter of taste.
(It is just from my perspective that I would prefer a spec that has been fully/widely discussed by the community. _GitHub also allows 2 to 4-spaces indentation._)

And an interesting story: I was a supporter of 4-spaces indentation https://github.com/yzhang-gh/vscode-markdown/issues/155#issuecomment-385157329 https://github.com/yzhang-gh/vscode-markdown/issues/241#issuecomment-406923148. In the early time of this extension, all the indentation is 4 spaces (just because it is easier to implement). But the truth is many people wanted 2 or 3-spaces indentation.

I didn't intend to start a spec "war". That's why this extension is configurable.

spec

And I naively thought there was one (1) or two (2) markdown, namely the one I use in the WIKI in GitHub or Azure DevOps. And then you send this link:

so many different implementations

@yzhang-gh I did not intend this as a blame. Sorry if it was perceived like that. I only wanted to point out that 4 spaces is the most compatible list indentation; but you already knew that apparently.

I indeed think CommonMark's behavior makes more sense when it comes to parsing list indentation. But changing this in PHP Markdown would break backward compatibility with old documents and with John Gruber's original Markdown parser. It's also an interesting thought that the original Markdown with its quirks could have become a minority "dialect", of which PHP Markdown would be an implementation of.

Absolutely agree 🤝.

Was this page helpful?
0 / 5 - 0 ratings