(This could be an Implementation question – it’s Spec insofar as I’m not sure if what I’m seeing in the implementations follows the spec or not. I don’t think they do.)
As a Markdown editor author, I’m finding the treatment of embedded ordered lists problematic.
For instance, this Markdown…
1. item one
2. item two
3. item three
Will create this html source:
<ol>
<li>item one</li>
<li>item two
3. item three</li>
</ol>
… where 3. is within the same list item as 2.
Rendered (actual):
- item one
- item two 3. item three
Because the numbers don’t matter beyond saying we’re in an ordered list (technically a lie; see below), I would expect this to render as…
Source (desired):
<ol>
<li>item one</li>
<li>item two
<ol>
<li>item three</li>
</ol>
</li>
</ol>
Rendered (desired):
- item one
- item two
- item three
To make things a little more interesting, if 3. item three
starts with 1.
, it renders how I’d expect. (I speculate a little about why, below.)
Markdown:
1. item one
2. item two
1. item three
Source (actual):
<ol>
<li>item one</li>
<li>item two
<ol>
<li>item three</li>
</ol>
</li>
</ol>
Rendered (actual):
- item one
- item two
- item three
That looks good. But I don’t believe the spec requires resetting to 1.
with each indent to create a sublist.
Practical use case
The use case here is that I’ll often have someone with an existing list (with numbers 1, 2, 3, 4 inserted by an auto-numberer) select & “tab over” (hit tab while the lines are selected) one or more items to create a sublist, and if I don’t parse & renumber that selection, I get the run-on line rather than a sublist.
List without indents.
1. item one
2. item sublist
3. item sublist
4. item two
Then select the second and third, and "tab them over…
1. item one
2. item sublist
3. item sublist
4. item two
Ick…
<ol>
<li>item one
2. item sublist
3. item sublist</li>
<li>item two</li>
</ol>
- item one 2. item sublist 3. item sublist
- item two
I’ve started renumbering an ol
if users are mid-list and tab a line over. At some point, I’d like to add logic to fluidly renumber any ordered list, from top to bottom, as indents are made, but this seems more like a nicety than something that should have to happen for the Markdown to be rendered elegantly.
Unordered list behavior
I would argue what we see here with ordered lists isn’t consistent with the treatment of unordered lists, where…
- foo
- bar
- baz
- boo
… evaluates to nested, unordered sublists…
<ul>
<li>foo
<ul>
<li>bar
<ul>
<li>baz
<ul>
<li>boo</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
</ul>
Here’s the ordered list from above as an unordered list.
* item one
* item two
* item three
Nice:
<ul>
<li>item one</li>
<li>item two
<ul>
<li>item three</li>
</ul>
</li>
</ul>
- item one
- item two
- item three
Quacks like a paragraph?
Though I haven’t checked the code, I’m going to guess that the parsers, including the dingus, are treating the first example’s nested 3. item three
as part of the previous line because of some misapplication (?) of the spec logic for examples 267 and following (linking to 266 to back up before the discussion).
Since it is well established Markdown practice to allow lists to interrupt paragraphs inside list items, the principle of uniformity requires us to allow this outside list items as well. (reStructuredText takes a different approach, requiring blank lines before lists even inside other list items.)
In order to solve of unwanted lists in paragraphs with hard-wrapped numerals, we allow only lists starting with
1
to interrupt paragraphs.
I’m don’t think that rule should apply here, where no paragraphs are being created (check the HTML pane in the dingus).
Any pointers what’s up? It’s certainly awkward behavior.
Thanks!