Skip to content

Commit cd24778

Browse files
committed
Update to comply with spec 0.31.2
The spec update changes these things: * It simplifies the HTML regex so that `<!-- a -- b -->` is an HTML comment. HTML5 reports this as an error, but still parses it. * It changes the set of known HTML block elements to match HTML5, adding `search` and removing `source`. * It adds Unicode Symbols to the set of punctuation characters that are used to evaluate flankingness. This commit also changes the declaration HTML regex to match lowercase, even though that change was technically made in spec version 0.30.
1 parent eaef476 commit cd24778

File tree

5 files changed

+6
-6
lines changed

5 files changed

+6
-6
lines changed

lib/common/html_blocks.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ export default [
5151
'option',
5252
'p',
5353
'param',
54+
'search',
5455
'section',
55-
'source',
5656
'summary',
5757
'table',
5858
'tbody',

lib/common/html_re.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ const attribute = '(?:\\s+' + attr_name + '(?:\\s*=\\s*' + attr_value + ')?)'
1313
const open_tag = '<[A-Za-z][A-Za-z0-9\\-]*' + attribute + '*\\s*\\/?>'
1414

1515
const close_tag = '<\\/[A-Za-z][A-Za-z0-9\\-]*\\s*>'
16-
const comment = '<!---->|<!--(?:-?[^>-])(?:-?[^-])*-->'
16+
const comment = '<!---?>|<!--(?:[^-]|-[^-]|--[^>])*-->'
1717
const processing = '<[?][\\s\\S]*?[?]>'
18-
const declaration = '<![A-Z]+\\s+[^>]*>'
18+
const declaration = '<![A-Za-z][^>]*>'
1919
const cdata = '<!\\[CDATA\\[[\\s\\S]*?\\]\\]>'
2020

2121
const HTML_TAG_RE = new RegExp('^(?:' + open_tag + '|' + close_tag + '|' + comment +

lib/common/utils.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ function isWhiteSpace (code) {
176176

177177
// Currently without astral characters support.
178178
function isPunctChar (ch) {
179-
return ucmicro.P.test(ch)
179+
return ucmicro.P.test(ch) || ucmicro.S.test(ch)
180180
}
181181

182182
// Markdown ASCII punctuation characters.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
"linkify-it": "^5.0.0",
5151
"mdurl": "^2.0.0",
5252
"punycode.js": "^2.3.1",
53-
"uc.micro": "^2.0.0"
53+
"uc.micro": "^2.1.0"
5454
},
5555
"devDependencies": {
5656
"@rollup/plugin-babel": "^6.0.4",

test/fixtures/markdown-it/fatal.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ foo <!--- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ->
2929
foo <!------------------------------------------------------------------->
3030
.
3131
<p>foo &lt;!— xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx -&gt;</p>
32-
<p>foo &lt;!-------------------------------------------------------------------&gt;</p>
32+
<p>foo <!-------------------------------------------------------------------></p>
3333
.
3434

3535

0 commit comments

Comments
 (0)