microsoft / vscode-markdown-tm-grammar

VS Code built-in markdown extension's Textmate grammar
MIT License
63 stars 50 forks source link

BlockQuote while condition is incorrect, scoping doesn't match preview or GitHub #56

Open msftrncs opened 5 years ago

msftrncs commented 5 years ago

Copying comment from another repository: https://github.com/microsoft/vscode-textmate/issues/110#issuecomment-524756619

Example:

> one nest.
>> second nest, new paragraph.
> continues paragraph of second nest.
also continues paragraph of second nest.

Actually (via GitHub):

one nest.

second nest, new paragraph. continues paragraph of second nest. also continues paragraph of second nest.

VS Code Editor highlight: image

From VS Code Preview: image

I believe VS Code's Markdown grammar is wrong. The while rule is expecting to find additional lines starting with > but that is not how the previewer works. I believe the correct test is, at a minimum, a non-blank line. but possibly also tests for other kinds of markup, or precisely the same as the while clause of list_paragraph. This is the correct while condition for blockquote: "while": "(^|\\G)([ ]{0,3}(>) ?|(?!\\s*$|#|[ ]{0,3}([-*_>][ ]{2,}){3,}[ \\t]*$\\n?|[ ]{0,3}[*+->]|[ ]{0,3}[0-9]+\\.))". With this change, I get the correct scoping.

image

mjbvz commented 5 years ago

This seems reasonable and matches the common markspec: https://spec.commonmark.org/0.29/#block-quotes

Do you want to submit a PR and add a few tests for this?

msftrncs commented 5 years ago

I'll try to post a PR shortly. As I went through the spec for blockquotes, I noticed where the REGEX still failed some situations, and it became more complicated to correct, but I think I have it.