Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move Markdown list parsing closer to CommonMark #3511

Closed
jgm opened this issue Mar 16, 2017 · 4 comments

Comments

Projects
None yet
2 participants
@jgm
Copy link
Owner

commented Mar 16, 2017

Currently we follow the 4-space rule. It would be good to switch to the CommonMark rule for nested list content, which is a bit more complex but allows more flexibility. Well-formatted 4-space rule lists should still work with no changes, but we'd also be able to handle 2-space indented sublists, for example. (See many closed bug reports relating to this...#3125 #2367 #2575 #2210 #1990 #1137 #744 #172 #137 #128.)

There'd be some danger of breakage of existing documents when indented code blocks are used inside list items. Currently these need to be indented 8 spaces relative to the outer list. With the CommonMark rule, the indentation needed depends on where the list content begins after the list marker. So, if you had a list like

- foo

        code

which pandoc currently interprets as

<ul>
<li><p>foo</p>
<pre><code>code</code></pre></li>
</ul>

with the CommonMark rules you'd get

<ul>
<li><p>foo</p>
<pre><code>  code
</code></pre></li>
</ul>

with two extra spaces at the beginning of the code. But if you had

  - foo

        code

you'd be fine, it would render the same.

All in all, I think the risk of breaking some existing documents is outweighed by the benefits of rendering nested lists where people clearly expect them, and reducing unexpected surprises when moving between Markdown implementations.

@jgm jgm added this to the pandoc 2.0 milestone Mar 16, 2017

@jgm

This comment has been minimized.

Copy link
Owner Author

commented Mar 17, 2017

An extension four_space_rule could be added so the old behavior could be selectively enabled.

@jgm jgm modified the milestone: pandoc 2.0 Mar 20, 2017

@jgm

This comment has been minimized.

Copy link
Owner Author

commented Mar 30, 2017

The tricky part of this is dealing with tabs.

@vvasuki

This comment has been minimized.

Copy link

commented Aug 2, 2017

In addition to the four space rule problem, there is also the problematic need to necessarily have a newline before a markdown list begins - please see second section here.

@jgm

This comment has been minimized.

Copy link
Owner Author

commented Aug 9, 2017

@vvasuki you can enable +lists_without_preceding_blankline if you want lists to be able to start without a blank line.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.