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

Nested lists require 4 spaces of indent #3

Closed
waylan opened this issue Apr 21, 2011 · 6 comments
Closed

Nested lists require 4 spaces of indent #3

waylan opened this issue Apr 21, 2011 · 6 comments
Labels
core Related to the core parser code. someday-maybe Approved low priority request.

Comments

@waylan
Copy link
Member

waylan commented Apr 21, 2011

This issue is copied from Ticket 64 of our old bug tracker. It has been copied as-is:

Nested lists do not nest. I've tried:

* Item 1
  * Item A
  * Item B

I get a flat list.

Tried it here too:
http://babelmark.bobtfish.net/?markdown=*+Item+1%0D%0A++*+Item+A%0D%0A++*+Item+B&compare=on&src=4&dest=4

Comments

By Waylan 7/1/10

Actually nested lists work fine when you indent with 4 spaces (I changed the title to better fit the actual situation). I realize that the Perl implementation works with 2 spaces of indent, but the fact is the syntax rules make no mention of any nested lists whatsoever and all other types of blocks require 4 spaces so Python-Markdown is consistent and requires 4 spaces for all types of nests content in lists (at least the first line of each block must be nested 4 spaces).

Unless someone can convince me otherwise, I'm considering this a bug in the perl implementation (and all other implementations that have copied its behavior). This will be marked wontfix in a few days. Please take any discussions on the matter to the mailing list.

@waylan
Copy link
Member Author

waylan commented Jul 21, 2011

If you wan this you can do:

markdown.markdown(text, tab_length=2)

This will work just fine. Of course, you will also need to use 2 spaces for indenting code blocks and everything else. The thing is, the entire parser relies on this variable being set. We can't use one figure some places and other other places.

I'm closing this WONTFIX.

@waylan waylan closed this as completed Jul 21, 2011
@nidico
Copy link

nidico commented Nov 17, 2014

This is very unfortunate. As written in this issue, 2 spaces are assumed to be the standard for nested lists (e.g. github does that; but the markdown syntax description leaves this open), 4 spaces for code blocks.

As #364 shows, this confuses many people. I didn't expect that all - I thought nested lists were simply not working, or I needed an empty line between indentation levels or I couldn't mix * and - symbols or something. Unnecessary confusion.

If it's not possible to do this in the parser, I consider this a parser bug.

As a short term workaround, the tab_length=2 is okay, but I think this should be the default.

@waylan
Copy link
Member Author

waylan commented Nov 18, 2014

Python-Markdown's behavior is _NOT_ a bug (and not up for debate). As I clearly state in #364:

The syntax rules clearly state:

List items may consist of multiple paragraphs. Each subsequent paragraph in a list item must be indented by either 4 spaces or one tab.

To me, any behavior which differs from that is a bug.

The word "must" leaves no room for interpretation. To require anything less that 4 spaces _is a bug_. In fact, for years now, this position has been stated in our documentation.

Yes, this means that almost all other implementations contain a bug. However, I am not going to copy that bug into my implementation. It is a bug. Why would I do that? So yes, it is unfortunate... that all the other implementations implement this bug. Perhaps they should stop (for the record, I know why they don't but that is a different discussion).

And while GitHub may be popular, their Markdown implementation is probably one of the farthest from the rules IMO. In the past when I reported a difference between the standard and their behavior, their response was that they didn't care what Markdown does, they were going to do their own thing anyway. So, please don't ever suggest that I should follow GitHub's lead in how to interpret Markdown text. If anything, I would suggest that GitHub stop calling their implementation Markdown.

But, hey, everyone is entitled to their own opinion. If you disagree with me, go create your own extension which implements lists as you want them to work. We provide the API so you can do anything you want. In fact, the Sane Lists extension provides an alternative list parser (which addresses a different issue with lists). No reason why one couldn't exist which implements this bug everyone keeps requesting.

@nidico
Copy link

nidico commented Nov 18, 2014

Thanks for the clarifications and sorry for the annoyance!

@radude
Copy link

radude commented Feb 9, 2018

Made an extension to fix this wontfix.
https://github.com/radude/mdx_truly_sane_lists

Shame on me for this shameless self-promotion

@lydell lydell mentioned this issue Nov 6, 2018
sohrab- added a commit to sohrab-/concourse-tutorial that referenced this issue Jan 29, 2019
sohrab- added a commit to sohrab-/concourse-tutorial that referenced this issue Jan 29, 2019
danihodovic added a commit to danihodovic/wagtail-markdown that referenced this issue Oct 7, 2019
Allows to create nested lists by two spaces.

- item
  - subitem
  - subitem2
- item2

Python-Markdown/markdown#3 (comment)
@mc-ksjet
Copy link

mc-ksjet commented Jul 22, 2023

@waylan

Python-Markdown's behavior is _NOT_ a bug (and not up for debate). As I clearly state in #364:

The syntax rules clearly state:

List items may consist of multiple paragraphs. Each subsequent paragraph in a list item must be indented by either 4 spaces or one tab.

To me, any behavior which differs from that is a bug.

The word "must" leaves no room for interpretation. To require anything less that 4 spaces _is a bug_. In fact, for years now, this position has been stated in our documentation.

Actually, I think that you have misread the syntax rules. The bit you have quoted is specifically for list markers where you are adding a second paragraph, and none of the examples given deal with lists. According to the syntax rules, sublists are not considered a second paragraph as there is no blank line between the list item and the start of the sublist in the markdown.

The syntax rules do not specifically state the size of the indent for sublists, in fact it doesn't mention nested lists at all, so if we're sticking with the syntax rules and consistency, I have no idea why sublists are even implemented in Python-Markdown.

@Python-Markdown Python-Markdown locked as resolved and limited conversation to collaborators Jul 24, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
core Related to the core parser code. someday-maybe Approved low priority request.
Projects
None yet
Development

No branches or pull requests

4 participants