-
-
Notifications
You must be signed in to change notification settings - Fork 326
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
Possibly undesired behavior uncovered by the spec #766
Comments
Possibly. In any case, it's not great that it's not in the spec in some way (also, I agree with sentiment in the other ones that adding a |
What isn’t in the spec? What did you expect in the spec? Your first example is explained because block quotes take 0 or 1 space after the >+
> foo is sort of “equivalent” to: +
foo leaving one space on the 1nd line, which is not enough for that line to be included in the list item. Both the “block quote space”, and the “how many spaces for list item content” are explained. |
Here's the demonstration of how the parser makes an unexpected visit into the writer's head is:
which renreds as:
The brokeness is that you need to be a "markdown expert" to know what's going on, and (again, IMO) the most important premise of markdown is that you don't need such experts. BTW, the above is "kind of" in the spec (eg, this example), but since it uses a plain paragraph, the implications are not visible enough. (And as another sidenote, this is even messier in its surprising result:
) |
I agree that something should change here; see discussion in the blockquote issues linked above. |
Because it’s 2 things combined. There are tons of things explained in the spec. To account for every combination of things is unmanagable.
I disagree. All markdown parsers work like this so it’s pretty predicatable. Many things in markdown are optional and allowed to be messy. And this one is explained right in the first line in the spec. Your proposal breaks for blank lines: > Some text
>
> Some more text which also happens a lot in code: > ```js
> function something(value) {
> const double = value * 2
>
> return double
> }
> ``` If you account for blank lines, it would still break when people are a bit messy. > ```js
> function something(value) {
> const double = value * 2
>
> return double
-> }
+>}
> ``` you are proposing that users accidentally forgetting a space on one line, get a different result for many lines. I use code as an example because those spaces are visual. I think for lists and indented code it gets more complex.
Nobody wants to be aware of the parser but having rules in markdown doesn’t mean that suddenly people need to “know the parser”. We can have some rules. You are also suggesting another rule.
When you write messy markdown, reglardless of this
What do you think should happen? Glossing over the linked discussion, it seems to be more about improving the words in the spec in 2017? |
I'm not sure what should happen (or it would have happened already). But I do think it's bad that the spec makes it ambiguous what certain strings represent. Note how the current reference parser interprets the spec in the cases noted in #421:
blockquote [list [blockquote], blockquote] vs
blockquote [list [blockquote]] These shouldn't have different meanings, by the "principle of uniformity." Maybe that's just a problem with the parser -- but the fact is, the spec doesn't unambiguously say how this is to be treated, for reasons explained in #460. Requiring that the "block quote marker" either include a space or not include a space on every line of the block quote seems a step in the right direction. This runs into the problem you noted with blank lines, but we could easily say something like "include a space unless followed by blank line." I'm less concerned about the second problem you note (the writer who just accidentally omits the space on one line). I'd rather have an unambiguous spec than a forgiving parser, I suppose. |
(@jgm)
Yes, that how I see it. In terms of what humans do, the current state can lead to a surprise if you add just a (@wooorm)
Please re-read the original description: I took a parser that passes all of the tests, changed it so that in the case I started with I get a more reasonable behavior, re-ran the tests and they passed again. This means that the change I did was not tested, it means nothing more or less than that. It's a very simple technical point, so I don't see why you're confrontational about it. The subjective point of how commonmark is specified or how the reference implementation(s) behave is a separate point. Yes, existing parsers tend to follow the reference. The question is whether the reference should be refined. And yes, authors are messy: you show a (valid) example of an unintended result when you have one line without a space as a result of messy writing, I showed another example that is unintended because of leaving out a space on the first line. So they're both examples of having no space on one line affecting many lines. I agree with @jgm's sentiment that the grab-a-space-if-you-can is more of a forgiving parser thing, which makes things (more) ambiguous, and I prefer a more deterministic behavior overall. It's all a game of tradeoffs, and the question is which one is less confusing overall, or rather which editing mistake is more common -- tweaking a line and forgetting the space, or adding a |
There are many things untested indeed, something I would love to see change, but I believe @jgm prefers to leave things up for interpretation. You want to change the spec. I do not think that should be done.
You misrepresent. The space after
There are many markdown records that exist already that you want to break. |
Please reconsider your interactions. You could start by resisting the urge to reply to every word I just write. I'll make it easier for you by shutting up. |
I ran into a particular edge case that looks like a bug:
Renders as:
with
foo
being in its own<p>
.Adding one space works as expected:
Renders as:
And also dropping the
>
blockquote makes it work as expected:Renders as:
The last one in particular makes me think that this is undesired behavior.
I looked through the spec but didn't find anything about this being intentional. I ran into it when using markdown-it, and in there it seems that changing the 1 to 0 in the following:
fixes this. Running the tests from here on the resulting code shows no failures, which implies that there's no other tested cases that depend on the original behavior.
(I tried to look through the
commonmark.js
code (parseListMarker
), to see if it can fixed in a similar way, but it's very different.)The text was updated successfully, but these errors were encountered: