Line containing only `* *` is incorrectly interpreted as a nested list

Most (17/23) markdown parsers interpret a line containing only * * as a list item consisting entirely of a single *. For example, the input

* a
* *
* b

produces

<ul>
    <li>a</li>
    <li>*</li>
    <li>b</li>
</ul>

Common Markdown, on the other hand, interprets it as a nested list:

<ul>
    <li>a</li>
    <li>
        <ul>
            <li></li>
        </ul>
    </li>
    <li>b</li>
</ul>

Since the former is both more common and more sane, it seems that the standard should be modified to do the former. At a minimum, there should be an example of this in the spec.

2 Likes

This is a result of two decisions: (a) to allow empty list items, (b) to allow list items whose contents are lists. In principle it would be possible to have (a) and (b) but disallow the special case where a list item contains a list with a single empty item, but this seems a bit ad hoc. Do you approve of (a)? Do you approve of (b)?

(a) and (b) both make sense to me. Most parsers (18/23) also agree with stmd (a), but the majority (15/23) disagree on (b). I raise this issue because my understanding of the spec was to describe the current consensus of parsers, not to proscribe what the ideal parsers would do.

Personally, it doesn’t matter to me what the decision is. All I am looking for clear instructions on how to write a parser (or in my case, a Vim syntax file), and the current spec does not make this very clear to me. Believe it or not, this was my first question when trying to write a better Vim syntax file. I read Example 12 and immediately thought, “What if there are only two stars?” Evidently I’m not the only one, since PHP Markdown [+ Extra] agrees with stmd on (a) and (b) yet disagrees about the original issue.

+++ MarkLodato [Sep 24 14 18:44 ]:

(a) and (b) both make sense to me. Most parsers (18/23) also agree with stmd (a), but the majority (15/23) disagree on (b). I raise this issue because my understanding of the spec was to describe the current consensus of parsers, not to proscribe what the ideal parsers would do.

I don’t think of it quite this way. I want to draw a smooth curve
through a bunch of messy data points, and to make good decisions about
things where implementations diverge. It’s not majority rule.

Personally, it doesn’t matter to me what the decision is. All I am looking for clear instructions on how to write a parser (or in my case, a Vim syntax file), and the current spec does not make this very clear to me. Believe it or not, this was my first question when trying to write a better Vim syntax file. I read Example 12 and immediately thought, “What if there are only two stars?” Evidently I’m not the only one, since PHP Markdown [+ Extra] agrees with stmd on (a) and (b) yet disagrees about the original issue.

Yes, I agree completely that the spec should have this as an example.

1 Like