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

Reference implementation incorrectly detects setext heading as paragraph continuation text #675

Closed
jmholla opened this issue Feb 16, 2021 · 4 comments

Comments

@jmholla
Copy link

jmholla commented Feb 16, 2021

Hi,

I've noticed this is also an issue in the python commonmark library) and presumably commonmark.js. The spec says:

Paragraph continuation text is text that will be parsed as part of the content of a paragraph, but does not occur at the beginning of the paragraph.

But, in the following, I would not expect TITLE to be paragraph continuation text but is rendered as part of the block quote:

> code
TITLE
=====

https://spec.commonmark.org/dingus/?text=%3E%20code%0ATITLE%0A%3D%3D%3D%3D%3D (You'll have to copy and paste this by hand or refresh the page once it's loaded.)

@vassudanagunta
Copy link

vassudanagunta commented Feb 16, 2021

It is behaving according to spec.

Block quotes are containers. They contain other elements such as paragraphs. In this case the block quote contains a single paragraph whose first line is code\n (the remainder of the line following the block quote marker). Then because of the paragraph continuation rules, TITLE\n is appended to that paragraph. Then =====\n is also treated as lazy paragraph continuation per the spec.

That's the whole point of paragraph continuation: to support laziness, the ability to continue paragraphs nested in containers without having to repeat the container demarcation (>, indentation) on every line.

Examples are all over the spec. Please take a look.

As you can see, all the CommonMark compliant renderers work this way. I personally think the other interpretations make more visual sense (click on Preview in Babelmark). But I'm sure CommonMark specifies what it does for considered reasons, possibly for internally consistency across all its rules. I don't remember off hand, but if you read the spec I'm sure it's there.

@jgm
Copy link
Member

jgm commented Feb 16, 2021

See sec 4.3

The lines of text must be such that, were they not followed by the setext heading underline, they would be interpreted as a paragraph: they cannot be interpretable as a code fence, ATX heading, block quote, thematic break, list item, or HTML block.

and

In general, a setext heading need not be preceded or followed by a blank line. However, it cannot interrupt a paragraph, so when a setext heading comes after a paragraph, a blank line is needed between them.

@jgm jgm closed this as completed Feb 16, 2021
@jmholla
Copy link
Author

jmholla commented Feb 17, 2021

In that case, the issue here is with the spec itself. From the definition of a block quote:

Laziness. If a string of lines Ls constitute a block quote with contents Bs, then the result of deleting the initial block quote marker from one or more lines in which the next non-whitespace character after the block quote marker is paragraph continuation text is a block quote with Bs as its content. Paragraph continuation text is text that will be parsed as part of the content of a paragraph, but does not occur at the beginning of the paragraph.

Take the following two sets of line

["> Title", "> ====="]
["> Title", " ====="]

If " =====" (quotations are demarcators and not part of the text) is paragraph continuation text, then those two must be the same because the result of removing the block quote marker from one or more lines of paragraph continuation text in a block quote should result in the same content. Since that is not the case, it cannot be paragraph continuation text and so it is not a part of the block quote.

There is an example that does show that this would be a part of the previous text, but I think the definition of paragraph continuation text does not accurately explain why that is the case.

@jgm
Copy link
Member

jgm commented Feb 17, 2021

Your original case had another line with code, and I was responding to that.

With this new case (with just two lines), there is indeed an issue, already noted in #460 (see also #634).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants