-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Reorganize grammars #1407
Reorganize grammars #1407
Conversation
…e from gfm to normal. Fences can interrupt paragraphs. Pedantic mode doesn\'t support code fences
…nterrupt paragraphs in commonmark.
…itution for readability
…eadings\' delimiter
@davisjam Can you review for redos vulnerabilities? |
@@ -14,9 +14,9 @@ | |||
var block = { | |||
newline: /^\n+/, | |||
code: /^( {4}[^\n]+\n*)+/, | |||
fences: noop, | |||
fences: /^ {0,3}(`{3,}|~{3,})([^`\n]*)\n(?:|([\s\S]*?)\n)(?: {0,3}\1[~`]* *(?:\n+|$)|$)/, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this rule was copied from block.gfm as-is.
hr: /^ {0,3}((?:- *){3,}|(?:_ *){3,}|(?:\* *){3,})(?:\n+|$)/, | ||
heading: /^ *(#{1,6}) *([^\n]+?) *(?:#+ *)?(?:\n+|$)/, | ||
heading: /^ {0,3}(#{1,6}) +([^\n]*?)(?: +#+)? *(?:\n+|$)/, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@davisjam I think this is "better" than before?
fences: /^ {0,3}(`{3,}|~{3,})([^`\n]*)\n(?:|([\s\S]*?)\n)(?: {0,3}\1[~`]* *(?:\n+|$)|$)/, | ||
paragraph: /^/, | ||
heading: /^ *(#{1,6}) +([^\n]+?) *#* *(?:\n+|$)/ | ||
nptable: /^ *([^|\n ].*\|.*)\n *([-:]+ *\|[-| :]*)(?:\n((?:.*[^>\n ].*(?:\n|$))*)\n*|$)/, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these were copied as-is from block.tables
@Feder1co5oave could you fix the merge conflicts so we can get this merged? |
Description
I noticed commonmark tests were being run in
gfm
mode. So I disabled it and moved block rules around to better represent the difference between the two grammar flavors:code fences are now parsed with
gfm: false
too (they're a part of commonmark)ATX headings require a space after the
#
s ingfm: false
mode, too. They're still not required inpedantic
mode.tables are supported whenever
gfm: true
(they're a part of gfm), so the oldtables
mode (described as "github flavored markdown + tables") is now practically the same asgfm
mode.re-write the
paragraph
rule to make it more clear and efficient.setext headings can no longer interrupt paragraphs. This means that the following markdown
Paragraph? Heading? =======
was previously parsed (and still is, but only in
pedantic
mode) aswhereas now it is
Neither of these complies with commonmark, which introduced multi-line setext headings and whould parse it like
This involves parsing a paragraph-like block, followed by a line made of
=
or-
. Now that I think of it, I'm not sure it's worth introducing this breaking change, and then another. Or we could merge this and wait until we get setext heading parsing 100% compliant before releasing. Let's hear opinions on this.lists can now interrupt paragraphs, but only if unordered, or starting from 1. (as per example 268)
Fixes
I don't know at this time of any filed issues solved by this PR.
Expectation
marked should parse commonmark in
normal
mode (gfm: false, tables: false
), and github flavored markdown ingfm
mode, according to spec.We should consider deprecating the
tables
option.Committer
In most cases, this should be a different person than the contributor.