Skip to content

Commit

Permalink
fix: update to commonmark specs 0.31 (#3176)
Browse files Browse the repository at this point in the history
BREAKING CHANGE:

- Update HTML block tags: add search, remove source
- Update punctuation to include unicode punctuation and symbol categories
- Update HTML comment to include <!--> and <!--->
UziTech authored Feb 3, 2024
1 parent 365e720 commit 3d9017b
Showing 8 changed files with 3,157 additions and 3,151 deletions.
2 changes: 1 addition & 1 deletion docs/INDEX.md
Original file line number Diff line number Diff line change
@@ -146,7 +146,7 @@ We actively support the features of the following [Markdown flavors](https://git
| Flavor | Version | Status |
| :--------------------------------------------------------- | :------ | :----------------------------------------------------------------- |
| The original markdown.pl | -- | |
| [CommonMark](http://spec.commonmark.org/0.30/) | 0.30 | [Work in progress](https://github.com/markedjs/marked/issues/1202) |
| [CommonMark](http://spec.commonmark.org/0.31.2/) | 0.31 | [Work in progress](https://github.com/markedjs/marked/issues/1202) |
| [GitHub Flavored Markdown](https://github.github.com/gfm/) | 0.29 | [Work in progress](https://github.com/markedjs/marked/issues/1202) |

By supporting the above Markdown flavors, it's possible that Marked can help you use other flavors as well; however, these are not actively supported by the community.
40 changes: 25 additions & 15 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -62,7 +62,7 @@
"@typescript-eslint/eslint-plugin": "^6.19.1",
"@typescript-eslint/parser": "^6.19.1",
"cheerio": "^1.0.0-rc.12",
"commonmark": "0.30.0",
"commonmark": "0.31.0",
"cross-env": "^7.0.3",
"dts-bundle-generator": "^9.2.5",
"eslint": "^8.56.0",
8 changes: 4 additions & 4 deletions src/rules.ts
Original file line number Diff line number Diff line change
@@ -31,9 +31,9 @@ const _tag = 'address|article|aside|base|basefont|blockquote|body|caption'
+ '|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption'
+ '|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe'
+ '|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option'
+ '|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr'
+ '|track|ul';
const _comment = /<!--(?!-?>)[\s\S]*?(?:-->|$)/;
+ '|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title'
+ '|tr|track|ul';
const _comment = /<!--(?:-?>|[\s\S]*?(?:-->|$))/;
const html = edit(
'^ {0,3}(?:' // optional indentation
+ '<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)' // (1)
@@ -165,7 +165,7 @@ const br = /^( {2,}|\\)\n(?!\s*$)/;
const inlineText = /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/;

// list of unicode punctuation marks, plus any missing characters from CommonMark spec
const _punctuation = '\\p{P}$+<=>`^|~';
const _punctuation = '\\p{P}\\p{S}';
const punctuation = edit(/^((?![*_])[\spunctuation])/, 'u')
.replace(/punctuation/g, _punctuation).getRegex();

Large diffs are not rendered by default.

3,120 changes: 1,559 additions & 1,561 deletions test/specs/gfm/commonmark.0.30.json → test/specs/gfm/commonmark.0.31.json

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions test/specs/new/html_comments.html
Original file line number Diff line number Diff line change
@@ -37,7 +37,7 @@ <h3>Example 9</h3>
<h3>Example 10</h3>

<!-- multi
line
line
comment
-->

@@ -50,11 +50,11 @@ <h3>Example 11</h3>

<h3>Example 12</h3>

<p>&lt;!--&gt; not a comment --&gt;</p>
<!--> a comment --&gt;
<p>&lt;!---&gt; not a comment --&gt;</p>
<!---> a comment --&gt;

<!-- <!-- not a comment? --> -->
<!-- <!-- a comment? --> -->

<h3>Example 13</h3>

8 changes: 4 additions & 4 deletions test/specs/new/html_comments.md
Original file line number Diff line number Diff line change
@@ -37,7 +37,7 @@
### Example 10

<!-- multi
line
line
comment
-->

@@ -49,11 +49,11 @@ comment

### Example 12

<!--> not a comment -->
<!--> a comment -->

<!---> not a comment -->
<!---> a comment -->

<!-- <!-- not a comment? --> -->
<!-- <!-- a comment? --> -->

### Example 13

0 comments on commit 3d9017b

Please sign in to comment.