FYI - this seems to be especially related to the default themes, so it could be specific to the default editor CSS files. I can get ordered lists to work correctly with one of the community themes (â80s Neonâ theme by @death.au), whereas previously that theme would not work for me. So something changed in the right direction â maybe the core CSS. So the problem may lie with the default themes only. Notice the bug report from @hiddenone at the top of this thread says âUsing Custom CSS: No.â
This is going to sound weird, but I believe the image you posted is absolutely correct. Hear me out:
In the editor view you have, at the top level, a numbered list with one item numbered â1â - this renders as â1â and no one should doubt this is fine
At the second level, you have three numbered items, starting with 2 (2,6,10). In the preview, you also have three numbered items, starting with 2 (2,3,4).
At the third level, under â6â/â3â, you have two numbered items, starting with 7 (7,9). In the preview, you also have three numbered items, starting with 7 (7,8).
The markdown render seems to take the first number you supply in a list and number from there incrementally. If your list was 1,2,3 - it would number 1,2,3. If it was 1,1,1 it would also number 1,2,3. If it was 1,15,42 it would also number 1,2,3.
This is handy for when you rearrange your list and numbers get removed and added - you donât have to keep track of them in the source, the preview will do it for you.
The issue thatâs confusing matters here is that the editor attempts to number the lists automatically as you add new lines, but that number doesnât reset automatically when you indent the list. So the preview starts a new inner list from the indent at the number that the editor automatically put in there, when youâre expecting it to start from 1.
The issue with my theme is to do with the way I restart the count at a new list in a way that is different than the browser does it by default[^1]. In this instance, my theme looks right, compared to what youâre expecting, but itâs actually wrong because it doesnât start the list at the number specified.
tl;dr: @Caketray was right and the issue is with the text being inserted and not with the render - my themes are actually wrong.
[^1]: I remove the auto numbers and replace them with my own so I can do fancy colours and shadows and stuff
Wow. I think this has become an unhealthy obsession for me â straight to CSS first thing in the morning.
You make an interesting point. So I think it may be an issue of deciding: by which rules of CSS grammar does the community (or the devs of course) want their text interpreted? Or better yet, we use custom CSS to style what we like regardless of what is objectively âcorrect.â
Check this out and hit the Preview tab on the right â itâs a site that compares many of the flavors of Markdown. I put my example text in there. Look at all the different renderings. I think I need to go back to bed.
Wow. Commonmark (the one I usually judge based off) doesnât recognise a nested ul unless it starts with 1., but itâs happy to accept any number to start with at the top level. Thatâs really weird to me.