securemark 0.260.6 → 0.261.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/README.md +12 -12
  3. package/design.md +0 -4
  4. package/dist/index.js +34 -113
  5. package/markdown.d.ts +5 -21
  6. package/package.json +4 -4
  7. package/src/parser/api/parse.test.ts +1 -1
  8. package/src/parser/block/blockquote.test.ts +2 -2
  9. package/src/parser/block/dlist.test.ts +1 -1
  10. package/src/parser/block/extension/example.test.ts +1 -1
  11. package/src/parser/block/extension/fig.test.ts +1 -1
  12. package/src/parser/block/heading.test.ts +2 -2
  13. package/src/parser/block/paragraph.test.ts +1 -4
  14. package/src/parser/inline/autolink/anchor.test.ts +1 -0
  15. package/src/parser/inline/autolink/email.test.ts +3 -0
  16. package/src/parser/inline/autolink/email.ts +1 -1
  17. package/src/parser/inline/autolink/hashnum.test.ts +1 -2
  18. package/src/parser/inline/autolink/hashnum.ts +1 -1
  19. package/src/parser/inline/autolink/hashtag.test.ts +15 -12
  20. package/src/parser/inline/autolink/hashtag.ts +3 -3
  21. package/src/parser/inline/autolink/url.test.ts +1 -1
  22. package/src/parser/inline/autolink/url.ts +1 -1
  23. package/src/parser/inline/autolink.ts +13 -4
  24. package/src/parser/inline/deletion.test.ts +2 -2
  25. package/src/parser/inline/emphasis.test.ts +26 -35
  26. package/src/parser/inline/emphasis.ts +5 -12
  27. package/src/parser/inline/escape.ts +1 -10
  28. package/src/parser/inline/extension/index.test.ts +2 -2
  29. package/src/parser/inline/insertion.test.ts +2 -2
  30. package/src/parser/inline/link.test.ts +1 -1
  31. package/src/parser/inline/mark.test.ts +1 -1
  32. package/src/parser/inline/strong.test.ts +25 -32
  33. package/src/parser/inline/strong.ts +4 -8
  34. package/src/parser/inline.test.ts +18 -91
  35. package/src/parser/inline.ts +0 -3
  36. package/src/parser/locale/ja.ts +1 -9
  37. package/src/parser/locale.test.ts +1 -1
  38. package/src/parser/source/text.test.ts +9 -4
  39. package/src/parser/source/text.ts +9 -16
  40. package/src/parser/inline/emstrong.ts +0 -62
package/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.261.0
4
+
5
+ - Change emphasis syntax and strong syntax.
6
+
3
7
  ## 0.260.6
4
8
 
5
9
  - Refactoring.
package/README.md CHANGED
@@ -51,7 +51,7 @@ https://falsandtru.github.io/securemark/
51
51
  - Blockquote (>, !>)
52
52
  - Preformattedtext (```)
53
53
  - HorizontalRule (---)
54
- - Inline markups (*, `, []{}, {}, ![]{}, !{}, \[](), ++, ~~, (()), ...)
54
+ - Inline markups (_, *, `, []{}, {}, ![]{}, !{}, \[](), ++, ~~, (()), ...)
55
55
  - Inline HTML tags (\<bdi>, \<bdo>)
56
56
  - Autolink (https://host, user@host, @user)
57
57
  - Shortmedia (!https://host/image.png, !https://youtu.be/...)
@@ -69,16 +69,16 @@ https://falsandtru.github.io/securemark/
69
69
 
70
70
  ## Operator precedence
71
71
 
72
- |P| Operators |
73
- |-|-------------------|
74
- |9| \n, \\\n |
75
- |8| `, " |
76
- |6| (()), [[]], ${}$ |
77
- |5| \<tag>\</tag> |
78
- |4| [% %] |
79
- |3| $ |
80
- |2| (), [], {} |
81
- |1| *, **, ==, ++, ~~ |
72
+ |P| Operators |
73
+ |-|------------------|
74
+ |9| \n, \\\n |
75
+ |8| `, " |
76
+ |6| (()), [[]], ${}$ |
77
+ |5| \<tag>\</tag> |
78
+ |4| [% %] |
79
+ |3| $ |
80
+ |2| (), [], {} |
81
+ |1| _, *, ==, ++, ~~ |
82
82
 
83
83
  ## Dependencies
84
84
 
@@ -92,7 +92,7 @@ https://falsandtru.github.io/securemark/
92
92
  - Chrome
93
93
  - Firefox
94
94
  - Edge (Chromium edition only)
95
- - Safari
95
+ - ~~Safari~~ (Awaiting the support of lookbehind assertion in regular expressions)
96
96
 
97
97
  ## License
98
98
 
package/design.md CHANGED
@@ -332,7 +332,3 @@ Data URIは保存および転送容量削減ならびにユーザーおよび管
332
332
  - \<small>: 法的表記を縮小表示すべきでないため削除。
333
333
  - \<sub>: \<small>の代わりに使用されないよう削除。他の構文との相性も悪い。
334
334
  - \<sup>: 同上。
335
-
336
- ### _ emphasis
337
-
338
- オートリンクと非常に相性が悪いため不採用。
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! securemark v0.260.6 https://github.com/falsandtru/securemark | (c) 2017, falsandtru | UNLICENSED License */
1
+ /*! securemark v0.261.0 https://github.com/falsandtru/securemark | (c) 2017, falsandtru | UNLICENSED License */
2
2
  (function webpackUniversalModuleDefinition(root, factory) {
3
3
  if(typeof exports === 'object' && typeof module === 'object')
4
4
  module.exports = factory(require("DOMPurify"), require("Prism"));
@@ -5912,8 +5912,6 @@ const deletion_1 = __webpack_require__(7501);
5912
5912
 
5913
5913
  const mark_1 = __webpack_require__(2480);
5914
5914
 
5915
- const emstrong_1 = __webpack_require__(6132);
5916
-
5917
5915
  const emphasis_1 = __webpack_require__(3867);
5918
5916
 
5919
5917
  const strong_1 = __webpack_require__(8072);
@@ -5932,7 +5930,7 @@ const bracket_1 = __webpack_require__(5196);
5932
5930
 
5933
5931
  const source_1 = __webpack_require__(6743);
5934
5932
 
5935
- exports.inline = (0, combinator_1.union)([escape_1.escape, annotation_1.annotation, reference_1.reference, template_1.template, comment_1.comment, math_1.math, extension_1.extension, ruby_1.ruby, link_1.link, media_1.media, html_1.html, insertion_1.insertion, deletion_1.deletion, mark_1.mark, emstrong_1.emstrong, strong_1.strong, emphasis_1.emphasis, code_1.code, htmlentity_1.htmlentity, shortmedia_1.shortmedia, autolink_1.autolink, bracket_1.bracket, source_1.text]);
5933
+ exports.inline = (0, combinator_1.union)([escape_1.escape, annotation_1.annotation, reference_1.reference, template_1.template, comment_1.comment, math_1.math, extension_1.extension, ruby_1.ruby, link_1.link, media_1.media, html_1.html, insertion_1.insertion, deletion_1.deletion, mark_1.mark, strong_1.strong, emphasis_1.emphasis, code_1.code, htmlentity_1.htmlentity, shortmedia_1.shortmedia, autolink_1.autolink, bracket_1.bracket, source_1.text]);
5936
5934
 
5937
5935
  var indexee_1 = __webpack_require__(1269);
5938
5936
 
@@ -6047,10 +6045,18 @@ exports.autolink = (0, combinator_1.fmap)((0, combinator_1.validate)(/^(?:[@#>0-
6047
6045
  , 1, 1, ~1
6048
6046
  /* State.shortcut */
6049
6047
  , (0, combinator_1.some)((0, combinator_1.union)([url_1.url, email_1.email, // Escape unmatched email-like strings.
6050
- (0, source_1.str)(/^[0-9a-z]+(?:[.+_-][0-9a-z]+)*(?:@(?:[0-9a-z]+(?:[.-][0-9a-z]+)*)?)*/i), channel_1.channel, account_1.account, // Escape unmatched account-like strings.
6048
+ (0, combinator_1.focus)(/^[0-9a-z](?:[_.+-](?=[0-9a-z])|[0-9a-z])*(?:@(?:[0-9a-z]+(?:[.-][0-9a-z]+)*)?)*/i, ({
6049
+ source
6050
+ }) => {
6051
+ if (source.length > 255 || source.includes('@')) return [[source], ''];
6052
+ const i = source.indexOf('_');
6053
+ if (i === -1) return [[source], ''];
6054
+ return [[source.slice(0, i)], source.slice(i)];
6055
+ }), channel_1.channel, account_1.account, // Escape unmatched account-like strings.
6051
6056
  (0, source_1.str)(/^@+[0-9a-z]*(?:-[0-9a-z]+)*/i), // Escape invalid leading characters.
6052
- (0, source_1.str)(new RegExp(/^(?:[^\p{C}\p{S}\p{P}\s]|emoji|['_])(?=#)/u.source.replace('emoji', hashtag_1.emoji), 'u')), hashtag_1.hashtag, hashnum_1.hashnum, // Escape unmatched hashtag-like strings.
6053
- (0, source_1.str)(new RegExp(/^#+(?:[^\p{C}\p{S}\p{P}\s]|emoji|['_])*/u.source.replace('emoji', hashtag_1.emoji), 'u')), anchor_1.anchor]))))), ns => ns.length === 1 ? ns : [(0, util_1.stringify)(ns)]);
6057
+ (0, source_1.str)(new RegExp(/^(?:[^\p{C}\p{S}\p{P}\s]|emoji)(?=#)/u.source.replace('emoji', hashtag_1.emoji), 'u')), hashtag_1.hashtag, hashnum_1.hashnum, // Escape unmatched hashtag-like strings.
6058
+ (0, source_1.str)(new RegExp(/^#+(?:[^\p{C}\p{S}\p{P}\s]|emoji|')*/u.source.replace('emoji', hashtag_1.emoji), 'u')), // Escape invalid leading characters.
6059
+ (0, source_1.str)(/^[0-9\p{Sc}](?=>)/u), anchor_1.anchor]))))), ns => ns.length === 1 ? ns : [(0, util_1.stringify)(ns)]);
6054
6060
 
6055
6061
  /***/ }),
6056
6062
 
@@ -6166,7 +6172,7 @@ const source_1 = __webpack_require__(6743);
6166
6172
  const dom_1 = __webpack_require__(3252); // https://html.spec.whatwg.org/multipage/input.html
6167
6173
 
6168
6174
 
6169
- exports.email = (0, combinator_1.creation)((0, combinator_1.rewrite)((0, combinator_1.verify)((0, source_1.str)(/^[0-9a-z](?:[.+_-](?=[^\W_])|[0-9a-z]){0,255}@[0-9a-z](?:(?:[0-9a-z]|-(?=\w)){0,61}[0-9a-z])?(?:\.[0-9a-z](?:(?:[0-9a-z]|-(?=\w)){0,61}[0-9a-z])?)*(?![0-9a-z])/i), ([source]) => source.length <= 255), ({
6175
+ exports.email = (0, combinator_1.creation)((0, combinator_1.rewrite)((0, combinator_1.verify)((0, source_1.str)(/^[0-9a-z](?:[_.+-](?=[0-9a-z])|[0-9a-z]){0,255}@[0-9a-z](?:(?:[0-9a-z]|-(?=\w)){0,61}[0-9a-z])?(?:\.[0-9a-z](?:(?:[0-9a-z]|-(?=\w)){0,61}[0-9a-z])?)*(?![0-9a-z])/i), ([source]) => source.length <= 255), ({
6170
6176
  source
6171
6177
  }) => [[(0, dom_1.html)('a', {
6172
6178
  class: 'email',
@@ -6198,7 +6204,7 @@ const dom_1 = __webpack_require__(3252);
6198
6204
 
6199
6205
  exports.hashnum = (0, combinator_1.lazy)(() => (0, combinator_1.fmap)((0, combinator_1.rewrite)((0, combinator_1.constraint)(1
6200
6206
  /* State.shortcut */
6201
- , false, (0, combinator_1.open)('#', (0, source_1.str)(new RegExp(/^[0-9]{1,16}(?![^\p{C}\p{S}\p{P}\s]|emoji|['_])/u.source.replace(/emoji/, hashtag_1.emoji), 'u')))), (0, combinator_1.convert)(source => `[${source}]{ ${source.slice(1)} }`, (0, combinator_1.union)([link_1.unsafelink]))), ([el]) => [(0, dom_1.define)(el, {
6207
+ , false, (0, combinator_1.open)('#', (0, source_1.str)(new RegExp(/^[0-9]{1,16}(?![^\p{C}\p{S}\p{P}\s]|emoji|')/u.source.replace(/emoji/, hashtag_1.emoji), 'u')))), (0, combinator_1.convert)(source => `[${source}]{ ${source.slice(1)} }`, (0, combinator_1.union)([link_1.unsafelink]))), ([el]) => [(0, dom_1.define)(el, {
6202
6208
  class: 'hashnum',
6203
6209
  href: null
6204
6210
  })]));
@@ -6229,7 +6235,7 @@ const dom_1 = __webpack_require__(3252); // https://example/hashtags/a must be a
6229
6235
  exports.emoji = String.raw`\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F`;
6230
6236
  exports.hashtag = (0, combinator_1.lazy)(() => (0, combinator_1.fmap)((0, combinator_1.rewrite)((0, combinator_1.constraint)(1
6231
6237
  /* State.shortcut */
6232
- , false, (0, combinator_1.open)('#', (0, combinator_1.tails)([(0, combinator_1.verify)((0, source_1.str)(/^[0-9a-z](?:(?:[0-9a-z]|-(?=\w)){0,61}[0-9a-z])?(?:\.[0-9a-z](?:(?:[0-9a-z]|-(?=\w)){0,61}[0-9a-z])?)*\//i), ([source]) => source.length <= 253 + 1), (0, combinator_1.verify)((0, source_1.str)(new RegExp([/^(?=[0-9]{0,127}_?(?:[^\d\p{C}\p{S}\p{P}\s]|emoji))/u.source, /(?:[^\p{C}\p{S}\p{P}\s]|emoji|_(?=[^\p{C}\p{S}\p{P}\s]|emoji)){1,128}/u.source, /(?!_?(?:[^\p{C}\p{S}\p{P}\s]|emoji)|')/u.source].join('').replace(/emoji/g, exports.emoji), 'u')), ([source]) => source.length <= 128)]))), (0, combinator_1.convert)(source => `[${source}]{ ${source.includes('/') ? `https://${source.slice(1).replace('/', '/hashtags/')}` : `/hashtags/${source.slice(1)}`} }`, (0, combinator_1.union)([link_1.unsafelink]))), ([el]) => [(0, dom_1.define)(el, {
6238
+ , false, (0, combinator_1.open)('#', (0, combinator_1.tails)([(0, combinator_1.verify)((0, source_1.str)(/^[0-9a-z](?:(?:[0-9a-z]|-(?=\w)){0,61}[0-9a-z])?(?:\.[0-9a-z](?:(?:[0-9a-z]|-(?=\w)){0,61}[0-9a-z])?)*\//i), ([source]) => source.length <= 253 + 1), (0, combinator_1.verify)((0, source_1.str)(new RegExp([/^(?=(?:[0-9]{1,127}_?)?(?:[^\d\p{C}\p{S}\p{P}\s]|emoji|'))/u.source, /(?:[^\p{C}\p{S}\p{P}\s]|emoji|(?<!')'|_(?=[^\p{C}\p{S}\p{P}\s]|emoji|')){1,128}/u.source, /(?!_?(?:[^\p{C}\p{S}\p{P}\s]|emoji|(?<!')'))/u.source].join('').replace(/emoji/g, exports.emoji), 'u')), ([source]) => source.length <= 128)]))), (0, combinator_1.convert)(source => `[${source}]{ ${source.includes('/') ? `https://${source.slice(1).replace('/', '/hashtags/')}` : `/hashtags/${source.slice(1)}`} }`, (0, combinator_1.union)([link_1.unsafelink]))), ([el]) => [(0, dom_1.define)(el, {
6233
6239
  class: 'hashtag'
6234
6240
  }, el.innerText)]));
6235
6241
 
@@ -6252,7 +6258,7 @@ const link_1 = __webpack_require__(9628);
6252
6258
 
6253
6259
  const source_1 = __webpack_require__(6743);
6254
6260
 
6255
- const closer = /^[-+*=~^,.;:!?]*(?=[\\"`|\[\](){}<>]|$)/;
6261
+ const closer = /^[-+*=~^_,.;:!?]*(?=[\\"`|\[\](){}<>]|$)/;
6256
6262
  exports.url = (0, combinator_1.lazy)(() => (0, combinator_1.validate)(['http://', 'https://'], (0, combinator_1.rewrite)((0, combinator_1.open)(/^https?:\/\/(?=[\x21-\x7E])/, (0, combinator_1.focus)(/^[\x21-\x7E]+/, (0, combinator_1.some)((0, combinator_1.union)([bracket, (0, combinator_1.some)(source_1.unescsource, closer)])))), (0, combinator_1.convert)(url => `{ ${url} }`, (0, combinator_1.union)([link_1.unsafelink])))));
6257
6263
  const bracket = (0, combinator_1.lazy)(() => (0, combinator_1.creation)((0, combinator_1.precedence)(2, (0, combinator_1.union)([(0, combinator_1.surround)('(', (0, combinator_1.some)((0, combinator_1.union)([bracket, source_1.unescsource]), ')'), ')', true), (0, combinator_1.surround)('[', (0, combinator_1.some)((0, combinator_1.union)([bracket, source_1.unescsource]), ']'), ']', true), (0, combinator_1.surround)('{', (0, combinator_1.some)((0, combinator_1.union)([bracket, source_1.unescsource]), '}'), '}', true), (0, combinator_1.surround)('"', (0, combinator_1.precedence)(8, (0, combinator_1.some)(source_1.unescsource, '"')), '"', true)]))));
6258
6264
 
@@ -6427,10 +6433,6 @@ const combinator_1 = __webpack_require__(2087);
6427
6433
 
6428
6434
  const inline_1 = __webpack_require__(1160);
6429
6435
 
6430
- const emstrong_1 = __webpack_require__(6132);
6431
-
6432
- const strong_1 = __webpack_require__(8072);
6433
-
6434
6436
  const source_1 = __webpack_require__(6743);
6435
6437
 
6436
6438
  const visibility_1 = __webpack_require__(7618);
@@ -6439,65 +6441,11 @@ const dom_1 = __webpack_require__(3252);
6439
6441
 
6440
6442
  const array_1 = __webpack_require__(8112);
6441
6443
 
6442
- exports.emphasis = (0, combinator_1.lazy)(() => (0, combinator_1.surround)((0, source_1.str)('*'), (0, combinator_1.syntax)(0
6444
+ exports.emphasis = (0, combinator_1.lazy)(() => (0, combinator_1.surround)((0, source_1.str)('_'), (0, combinator_1.syntax)(0
6443
6445
  /* Syntax.none */
6444
6446
  , 1, 1, 0
6445
6447
  /* State.none */
6446
- , (0, visibility_1.startTight)((0, combinator_1.some)((0, combinator_1.union)([strong_1.strong, (0, combinator_1.some)(inline_1.inline, (0, visibility_1.blankWith)('*')), (0, combinator_1.open)((0, combinator_1.some)(inline_1.inline, '*'), (0, combinator_1.union)([emstrong_1.emstrong, strong_1.strong, exports.emphasis]))])), '*')), (0, source_1.str)('*'), false, ([, bs], rest) => [[(0, dom_1.html)('em', (0, dom_1.defrag)(bs))], rest], ([as, bs], rest) => [(0, array_1.unshift)(as, bs), rest]));
6447
-
6448
- /***/ }),
6449
-
6450
- /***/ 6132:
6451
- /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
6452
-
6453
- "use strict";
6454
-
6455
-
6456
- Object.defineProperty(exports, "__esModule", ({
6457
- value: true
6458
- }));
6459
- exports.emstrong = void 0;
6460
-
6461
- const combinator_1 = __webpack_require__(2087);
6462
-
6463
- const inline_1 = __webpack_require__(1160);
6464
-
6465
- const strong_1 = __webpack_require__(8072);
6466
-
6467
- const emphasis_1 = __webpack_require__(3867);
6468
-
6469
- const source_1 = __webpack_require__(6743);
6470
-
6471
- const visibility_1 = __webpack_require__(7618);
6472
-
6473
- const dom_1 = __webpack_require__(3252);
6474
-
6475
- const array_1 = __webpack_require__(8112);
6476
-
6477
- const substrong = (0, combinator_1.lazy)(() => (0, combinator_1.some)((0, combinator_1.union)([(0, combinator_1.some)(inline_1.inline, (0, visibility_1.blankWith)('**')), (0, combinator_1.open)((0, combinator_1.some)(inline_1.inline, '*'), (0, combinator_1.union)([exports.emstrong, strong_1.strong]))])));
6478
- const subemphasis = (0, combinator_1.lazy)(() => (0, combinator_1.some)((0, combinator_1.union)([strong_1.strong, (0, combinator_1.some)(inline_1.inline, (0, visibility_1.blankWith)('*')), (0, combinator_1.open)((0, combinator_1.some)(inline_1.inline, '*'), (0, combinator_1.union)([exports.emstrong, strong_1.strong, emphasis_1.emphasis]))])));
6479
- exports.emstrong = (0, combinator_1.lazy)(() => (0, combinator_1.surround)((0, source_1.str)('***'), (0, combinator_1.syntax)(0
6480
- /* Syntax.none */
6481
- , 1, 1, 0
6482
- /* State.none */
6483
- , (0, visibility_1.startTight)((0, combinator_1.some)((0, combinator_1.union)([(0, combinator_1.some)(inline_1.inline, (0, visibility_1.blankWith)('*')), (0, combinator_1.open)((0, combinator_1.some)(inline_1.inline, '*'), inline_1.inline)])))), (0, source_1.str)(/^\*{1,3}/), false, ([, bs, cs], rest, context) => {
6484
- switch (cs[0]) {
6485
- case '***':
6486
- return [[(0, dom_1.html)('em', [(0, dom_1.html)('strong', (0, dom_1.defrag)(bs))])], rest];
6487
-
6488
- case '**':
6489
- return (0, combinator_1.bind)(subemphasis, (ds, rest) => rest.slice(0, 1) === '*' ? [[(0, dom_1.html)('em', (0, array_1.unshift)([(0, dom_1.html)('strong', (0, dom_1.defrag)(bs))], (0, dom_1.defrag)(ds)))], rest.slice(1)] : [(0, array_1.unshift)(['*', (0, dom_1.html)('strong', (0, dom_1.defrag)(bs))], ds), rest])({
6490
- source: rest,
6491
- context
6492
- }) ?? [['*', (0, dom_1.html)('strong', (0, dom_1.defrag)(bs))], rest];
6493
-
6494
- case '*':
6495
- return (0, combinator_1.bind)(substrong, (ds, rest) => rest.slice(0, 2) === '**' ? [[(0, dom_1.html)('strong', (0, array_1.unshift)([(0, dom_1.html)('em', (0, dom_1.defrag)(bs))], (0, dom_1.defrag)(ds)))], rest.slice(2)] : [(0, array_1.unshift)(['**', (0, dom_1.html)('em', (0, dom_1.defrag)(bs))], ds), rest])({
6496
- source: rest,
6497
- context
6498
- }) ?? [['**', (0, dom_1.html)('em', (0, dom_1.defrag)(bs))], rest];
6499
- }
6500
- }, ([as, bs], rest) => [(0, array_1.unshift)(as, bs), rest]));
6448
+ , (0, visibility_1.startTight)((0, combinator_1.some)((0, combinator_1.union)([(0, combinator_1.some)(inline_1.inline, (0, visibility_1.blankWith)('_')), (0, combinator_1.open)((0, combinator_1.some)(inline_1.inline, '_'), exports.emphasis)])), '_')), (0, source_1.str)('_'), false, ([, bs], rest) => [[(0, dom_1.html)('em', (0, dom_1.defrag)(bs))], rest], ([as, bs], rest) => [(0, array_1.unshift)(as, bs), rest]));
6501
6449
 
6502
6450
  /***/ }),
6503
6451
 
@@ -6523,19 +6471,11 @@ exports.escape = (0, combinator_1.union)([({
6523
6471
  source,
6524
6472
  context
6525
6473
  }) => {
6526
- if (source.length < 3) return;
6527
-
6528
6474
  switch (source[0]) {
6529
- case '*':
6530
- if (source.length < 4) return;
6531
- return source[3] === source[0] && source[2] === source[0] && source[1] === source[0] ? repeat({
6532
- source,
6533
- context
6534
- }) : global_1.undefined;
6535
-
6536
6475
  case '+':
6537
6476
  case '~':
6538
6477
  case '=':
6478
+ if (!source[2]) return;
6539
6479
  return source[2] === source[0] && source[1] === source[0] ? repeat({
6540
6480
  source,
6541
6481
  context
@@ -7562,8 +7502,6 @@ const combinator_1 = __webpack_require__(2087);
7562
7502
 
7563
7503
  const inline_1 = __webpack_require__(1160);
7564
7504
 
7565
- const emstrong_1 = __webpack_require__(6132);
7566
-
7567
7505
  const source_1 = __webpack_require__(6743);
7568
7506
 
7569
7507
  const visibility_1 = __webpack_require__(7618);
@@ -7572,11 +7510,11 @@ const dom_1 = __webpack_require__(3252);
7572
7510
 
7573
7511
  const array_1 = __webpack_require__(8112);
7574
7512
 
7575
- exports.strong = (0, combinator_1.lazy)(() => (0, combinator_1.surround)((0, source_1.str)('**'), (0, combinator_1.syntax)(0
7513
+ exports.strong = (0, combinator_1.lazy)(() => (0, combinator_1.surround)((0, source_1.str)('*'), (0, combinator_1.syntax)(0
7576
7514
  /* Syntax.none */
7577
7515
  , 1, 1, 0
7578
7516
  /* State.none */
7579
- , (0, visibility_1.startTight)((0, combinator_1.some)((0, combinator_1.union)([(0, combinator_1.some)(inline_1.inline, (0, visibility_1.blankWith)('**')), (0, combinator_1.open)((0, combinator_1.some)(inline_1.inline, '*'), (0, combinator_1.union)([emstrong_1.emstrong, exports.strong]))])), '*')), (0, source_1.str)('**'), false, ([, bs], rest) => [[(0, dom_1.html)('strong', (0, dom_1.defrag)(bs))], rest], ([as, bs], rest) => [(0, array_1.unshift)(as, bs), rest]));
7517
+ , (0, visibility_1.startTight)((0, combinator_1.some)((0, combinator_1.union)([(0, combinator_1.some)(inline_1.inline, (0, visibility_1.blankWith)('*')), (0, combinator_1.open)((0, combinator_1.some)(inline_1.inline, '*'), exports.strong)])), '*')), (0, source_1.str)('*'), false, ([, bs], rest) => [[(0, dom_1.html)('strong', (0, dom_1.defrag)(bs))], rest], ([as, bs], rest) => [(0, array_1.unshift)(as, bs), rest]));
7580
7518
 
7581
7519
  /***/ }),
7582
7520
 
@@ -7702,16 +7640,7 @@ Object.defineProperty(exports, "__esModule", ({
7702
7640
  exports.japanese = void 0;
7703
7641
 
7704
7642
  function japanese(char) {
7705
- switch (char) {
7706
- case '、':
7707
- case '。':
7708
- case '!':
7709
- case '?':
7710
- return true;
7711
-
7712
- default:
7713
- return false;
7714
- }
7643
+ return /^[\p{Ideo}\p{Script_Extensions=Hiragana}\p{Script_Extensions=Katakana}~!?]/u.test(char);
7715
7644
  }
7716
7645
 
7717
7646
  exports.japanese = japanese;
@@ -8390,9 +8319,10 @@ const str_1 = __webpack_require__(2790);
8390
8319
 
8391
8320
  const dom_1 = __webpack_require__(3252);
8392
8321
 
8393
- exports.delimiter = /[\s\x00-\x7F]|\S[#>]|[()、。!?][^\S\n]*(?=\\\n)/;
8322
+ exports.delimiter = /[\s\x00-\x7F]|\S[#>]|[\p{Ideo}\p{Script_Extensions=Hiragana}\p{Script_Extensions=Katakana}~!?][^\S\n]*(?=\\\n)/u;
8394
8323
  exports.nonWhitespace = /[\S\n]|$/;
8395
8324
  exports.nonAlphanumeric = /[^0-9A-Za-z]|\S[#>]|$/;
8325
+ const nssb = /^[\p{Ideo}\p{Script_Extensions=Hiragana}\p{Script_Extensions=Katakana}~!?][^\S\n]*(?=\\\n)/u;
8396
8326
  const repeat = (0, str_1.str)(/^(.)\1*/);
8397
8327
  exports.text = (0, combinator_1.creation)(1, false, ({
8398
8328
  source,
@@ -8409,25 +8339,15 @@ exports.text = (0, combinator_1.creation)(1, false, ({
8409
8339
  switch (source[0]) {
8410
8340
  case '\x1B':
8411
8341
  case '\\':
8412
- switch (source[1]) {
8413
- case '、':
8414
- case '。':
8415
- case '!':
8416
- case '?':
8417
- return (0, exports.text)({
8418
- source: source.slice(1),
8419
- context
8420
- });
8421
- }
8422
-
8423
- break;
8342
+ if (!nssb.test(source.slice(1))) break;
8343
+ return (0, exports.text)({
8344
+ source: source.slice(1),
8345
+ context
8346
+ });
8424
8347
 
8425
- case '、':
8426
- case '。':
8427
- case '':
8428
- case '?':
8429
- const i = source.slice(1).search(exports.nonWhitespace) + 1;
8430
- if (i > 0 && source.slice(i, i + 2) === '\\\n') return [[source[0], (0, dom_1.html)('span', {
8348
+ default:
8349
+ const i = source.match(nssb)?.[0].length ?? -1;
8350
+ if (i !== -1) return [[source[0], (0, dom_1.html)('span', {
8431
8351
  class: 'linebreak'
8432
8352
  })], source.slice(i + 2)];
8433
8353
  }
@@ -8451,6 +8371,7 @@ exports.text = (0, combinator_1.creation)(1, false, ({
8451
8371
  case '\n':
8452
8372
  return [[(0, dom_1.html)('br')], source.slice(1)];
8453
8373
 
8374
+ case '_':
8454
8375
  case '*':
8455
8376
  case '+':
8456
8377
  case '~':
package/markdown.d.ts CHANGED
@@ -635,7 +635,6 @@ export namespace MarkdownParser {
635
635
  InlineParser.InsertionParser,
636
636
  InlineParser.DeletionParser,
637
637
  InlineParser.MarkParser,
638
- InlineParser.EmStrongParser,
639
638
  InlineParser.StrongParser,
640
639
  InlineParser.EmphasisParser,
641
640
  InlineParser.CodeParser,
@@ -1032,36 +1031,20 @@ export namespace MarkdownParser {
1032
1031
  MarkParser,
1033
1032
  ]> {
1034
1033
  }
1035
- export interface EmStrongParser extends
1036
- // *abc*
1037
- Inline<'emstrong'>,
1038
- Parser<HTMLElement | string, Context, [
1039
- InlineParser,
1040
- InlineParser,
1041
- ]> {
1042
- }
1043
1034
  export interface StrongParser extends
1044
- // **abc**
1035
+ // *abc*
1045
1036
  Inline<'strong'>,
1046
1037
  Parser<HTMLElement | string, Context, [
1047
1038
  InlineParser,
1048
- Parser<HTMLElement | string, Context, [
1049
- EmStrongParser,
1050
- StrongParser,
1051
- ]>,
1039
+ StrongParser,
1052
1040
  ]> {
1053
1041
  }
1054
1042
  export interface EmphasisParser extends
1055
- // *abc*
1043
+ // _abc_
1056
1044
  Inline<'emphasis'>,
1057
1045
  Parser<HTMLElement | string, Context, [
1058
- StrongParser,
1059
1046
  InlineParser,
1060
- Parser<HTMLElement | string, Context, [
1061
- EmStrongParser,
1062
- StrongParser,
1063
- EmphasisParser,
1064
- ]>,
1047
+ EmphasisParser,
1065
1048
  ]> {
1066
1049
  }
1067
1050
  export interface CodeParser extends
@@ -1103,6 +1086,7 @@ export namespace MarkdownParser {
1103
1086
  AutolinkParser.HashtagParser,
1104
1087
  AutolinkParser.HashnumParser,
1105
1088
  SourceParser.StrParser,
1089
+ SourceParser.StrParser,
1106
1090
  AutolinkParser.AnchorParser,
1107
1091
  ]> {
1108
1092
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "securemark",
3
- "version": "0.260.6",
3
+ "version": "0.261.0",
4
4
  "description": "Secure markdown renderer working on browsers for user input data.",
5
5
  "private": false,
6
6
  "homepage": "https://github.com/falsandtru/securemark",
@@ -34,11 +34,11 @@
34
34
  "@types/mocha": "9.1.1",
35
35
  "@types/power-assert": "1.5.8",
36
36
  "@types/prismjs": "1.26.0",
37
- "@typescript-eslint/parser": "^5.31.0",
37
+ "@typescript-eslint/parser": "^5.33.0",
38
38
  "babel-loader": "^8.2.5",
39
39
  "babel-plugin-unassert": "^3.2.0",
40
40
  "concurrently": "^7.3.0",
41
- "eslint": "^8.20.0",
41
+ "eslint": "^8.21.0",
42
42
  "eslint-plugin-redos": "^4.4.1",
43
43
  "eslint-webpack-plugin": "^3.2.0",
44
44
  "glob": "^8.0.3",
@@ -49,7 +49,7 @@
49
49
  "karma-mocha": "^2.0.1",
50
50
  "karma-power-assert": "^1.0.0",
51
51
  "mocha": "^10.0.0",
52
- "npm-check-updates": "^16.0.3",
52
+ "npm-check-updates": "^16.0.5",
53
53
  "semver": "^7.3.7",
54
54
  "spica": "0.0.591",
55
55
  "ts-loader": "^9.3.1",
@@ -206,7 +206,7 @@ describe('Unit: parser/api/parse', () => {
206
206
  it('footnote', () => {
207
207
  const footnotes = { references: html('ol') };
208
208
  assert.deepStrictEqual(
209
- [...parse('$-a\n$$\n$$\n\n(($-a[[b]][[c*d*]]))', { footnotes }).children].map(el => el.outerHTML),
209
+ [...parse('$-a\n$$\n$$\n\n(($-a[[b]][[c_d_]]))', { footnotes }).children].map(el => el.outerHTML),
210
210
  [
211
211
  '<figure data-type="math" data-label="$-a" data-group="$" data-number="1" id="label:$-a"><figcaption><span class="figindex">(1)</span><span class="figtext"></span></figcaption><div><div class="math" translate="no">$$\n$$</div></div></figure>',
212
212
  '<p><sup class="annotation" id="annotation:ref:1" title="(1)[1][2]"><span hidden=""><a class="label" data-label="$-a" href="#label:$-a">(1)</a><sup class="reference" id="reference:ref:1" title="b"><span hidden="">b</span><a href="#reference:def:1">[1]</a></sup><sup class="reference" id="reference:ref:2" title="cd"><span hidden="">c<em>d</em></span><a href="#reference:def:2">[2]</a></sup></span><a href="#annotation:def:1">*1</a></sup></p>',
@@ -70,8 +70,8 @@ describe('Unit: parser/block/blockquote', () => {
70
70
  assert.deepStrictEqual(inspect(parser('!> a')), [['<blockquote><section><p>a</p><ol class="references"></ol></section></blockquote>'], '']);
71
71
  assert.deepStrictEqual(inspect(parser('!> a\n')), [['<blockquote><section><p>a</p><ol class="references"></ol></section></blockquote>'], '']);
72
72
  assert.deepStrictEqual(inspect(parser('!> a\\\nb')), [['<blockquote><section><p>a<span class="linebreak"> </span>b</p><ol class="references"></ol></section></blockquote>'], '']);
73
- assert.deepStrictEqual(inspect(parser('!> *a\nb*')), [['<blockquote><section><p><em>a<br>b</em></p><ol class="references"></ol></section></blockquote>'], '']);
74
- assert.deepStrictEqual(inspect(parser('!> *a\n> b*')), [['<blockquote><section><p><em>a<br>b</em></p><ol class="references"></ol></section></blockquote>'], '']);
73
+ assert.deepStrictEqual(inspect(parser('!> _a\nb_')), [['<blockquote><section><p><em>a<br>b</em></p><ol class="references"></ol></section></blockquote>'], '']);
74
+ assert.deepStrictEqual(inspect(parser('!> _a\n> b_')), [['<blockquote><section><p><em>a<br>b</em></p><ol class="references"></ol></section></blockquote>'], '']);
75
75
  assert.deepStrictEqual(inspect(parser('!> a \n b c ')), [['<blockquote><section><p> a<br> b c</p><ol class="references"></ol></section></blockquote>'], '']);
76
76
  assert.deepStrictEqual(inspect(parser('!>> a')), [['<blockquote><blockquote><section><p>a</p><ol class="references"></ol></section></blockquote></blockquote>'], '']);
77
77
  assert.deepStrictEqual(inspect(parser('!>> a\n> b')), [['<blockquote><blockquote><section><p>a</p><ol class="references"></ol></section></blockquote><section><p>b</p><ol class="references"></ol></section></blockquote>'], '']);
@@ -68,7 +68,7 @@ describe('Unit: parser/block/dlist', () => {
68
68
  assert.deepStrictEqual(inspect(parser('~ a [#b]')), [['<dl><dt id="index:b">a<span class="indexer" data-index="b"></span></dt><dd></dd></dl>'], '']);
69
69
  assert.deepStrictEqual(inspect(parser('~ a [#b]\\')), [['<dl><dt id="index:a_[#b]">a [<a class="hashtag" href="/hashtags/b">#b</a>]</dt><dd></dd></dl>'], '']);
70
70
  assert.deepStrictEqual(inspect(parser('~ A')), [['<dl><dt id="index:A">A</dt><dd></dd></dl>'], '']);
71
- assert.deepStrictEqual(inspect(parser('~ *A*')), [['<dl><dt id="index:A"><em>A</em></dt><dd></dd></dl>'], '']);
71
+ assert.deepStrictEqual(inspect(parser('~ _A_')), [['<dl><dt id="index:A"><em>A</em></dt><dd></dd></dl>'], '']);
72
72
  assert.deepStrictEqual(inspect(parser('~ `A`')), [['<dl><dt id="index:`A`"><code data-src="`A`">A</code></dt><dd></dd></dl>'], '']);
73
73
  assert.deepStrictEqual(inspect(parser('~ ${A}$')), [['<dl><dt id="index:${A}$"><span class="math" translate="no" data-src="${A}$">${A}$</span></dt><dd></dd></dl>'], '']);
74
74
  });
@@ -18,7 +18,7 @@ describe('Unit: parser/block/extension/example', () => {
18
18
  assert.deepStrictEqual(inspect(parser('~~~example/markdown\n~~~')), [['<aside class="example" data-type="markdown"><pre translate="no"></pre><hr><section><ol class="references"></ol></section></aside>'], '']);
19
19
  assert.deepStrictEqual(inspect(parser('~~~example/markdown\n\n~~~')), [['<aside class="example" data-type="markdown"><pre translate="no"></pre><hr><section><ol class="references"></ol></section></aside>'], '']);
20
20
  assert.deepStrictEqual(inspect(parser('~~~example/markdown\na\n~~~')), [['<aside class="example" data-type="markdown"><pre translate="no">a</pre><hr><section><p>a</p><ol class="references"></ol></section></aside>'], '']);
21
- assert.deepStrictEqual(inspect(parser('~~~example/markdown\n*a\nb*\n~~~')), [['<aside class="example" data-type="markdown"><pre translate="no">*a\nb*</pre><hr><section><p><em>a<br>b</em></p><ol class="references"></ol></section></aside>'], '']);
21
+ assert.deepStrictEqual(inspect(parser('~~~example/markdown\n_a\nb_\n~~~')), [['<aside class="example" data-type="markdown"><pre translate="no">_a\nb_</pre><hr><section><p><em>a<br>b</em></p><ol class="references"></ol></section></aside>'], '']);
22
22
  assert.deepStrictEqual(inspect(parser('~~~example/markdown\n$fig-a\n!https://host\n~~~')), [['<aside class="example" data-type="markdown"><pre translate="no">$fig-a\n!https://host</pre><hr><section><figure data-type="media" data-label="fig-a" data-group="fig" data-number="1"><figcaption><span class="figindex">Fig. 1. </span><span class="figtext"></span></figcaption><div><a href="https://host" target="_blank"><img class="media" data-src="https://host" alt=""></a></div></figure><ol class="references"></ol></section></aside>'], '']);
23
23
  assert.deepStrictEqual(inspect(parser('~~~example/markdown\n[$fig-a]\n!https://host\n~~~')), [['<aside class="example" data-type="markdown"><pre translate="no">[$fig-a]\n!https://host</pre><hr><section><figure data-type="media" data-label="fig-a" data-group="fig" data-number="1"><figcaption><span class="figindex">Fig. 1. </span><span class="figtext"></span></figcaption><div><a href="https://host" target="_blank"><img class="media" data-src="https://host" alt=""></a></div></figure><ol class="references"></ol></section></aside>'], '']);
24
24
  assert.deepStrictEqual(inspect(parser('~~~example/markdown\n## a\n~~~')), [['<aside class="example" data-type="markdown"><pre translate="no">## a</pre><hr><section><h2>a</h2><ol class="references"></ol></section></aside>'], '']);
@@ -40,7 +40,7 @@ describe('Unit: parser/block/extension/fig', () => {
40
40
  assert.deepStrictEqual(inspect(parser('[$group-name]\n> ')), [['<figure data-type="quote" data-label="group-name" data-group="group"><figcaption><span class="figindex"></span><span class="figtext"></span></figcaption><div><blockquote></blockquote></div></figure>'], '']);
41
41
  assert.deepStrictEqual(inspect(parser('[$group-name]\n> \n')), [['<figure data-type="quote" data-label="group-name" data-group="group"><figcaption><span class="figindex"></span><span class="figtext"></span></figcaption><div><blockquote></blockquote></div></figure>'], '']);
42
42
  assert.deepStrictEqual(inspect(parser('[$group-name]\n>\n~~~')), [['<figure data-type="quote" data-label="group-name" data-group="group"><figcaption><span class="figindex"></span><span class="figtext"></span></figcaption><div><blockquote><pre><br>~~~</pre></blockquote></div></figure>'], '']);
43
- assert.deepStrictEqual(inspect(parser('[$group-name]\n!> *a*')), [['<figure data-type="quote" data-label="group-name" data-group="group"><figcaption><span class="figindex"></span><span class="figtext"></span></figcaption><div><blockquote><section><p><em>a</em></p><ol class="references"></ol></section></blockquote></div></figure>'], '']);
43
+ assert.deepStrictEqual(inspect(parser('[$group-name]\n!> _a_')), [['<figure data-type="quote" data-label="group-name" data-group="group"><figcaption><span class="figindex"></span><span class="figtext"></span></figcaption><div><blockquote><section><p><em>a</em></p><ol class="references"></ol></section></blockquote></div></figure>'], '']);
44
44
  assert.deepStrictEqual(inspect(parser('[$group-name]\n![]{https://host}')), [['<figure data-type="media" data-label="group-name" data-group="group"><figcaption><span class="figindex"></span><span class="figtext"></span></figcaption><div><a href="https://host" target="_blank"><img class="media" data-src="https://host" alt=""></a></div></figure>'], '']);
45
45
  assert.deepStrictEqual(inspect(parser('[$group-name]\n![]{https://host}\n')), [['<figure data-type="media" data-label="group-name" data-group="group"><figcaption><span class="figindex"></span><span class="figtext"></span></figcaption><div><a href="https://host" target="_blank"><img class="media" data-src="https://host" alt=""></a></div></figure>'], '']);
46
46
  assert.deepStrictEqual(inspect(parser('$group-name\n!https://host')), [['<figure data-type="media" data-label="group-name" data-group="group"><figcaption><span class="figindex"></span><span class="figtext"></span></figcaption><div><a href="https://host" target="_blank"><img class="media" data-src="https://host" alt=""></a></div></figure>'], '']);
@@ -36,7 +36,7 @@ describe('Unit: parser/block/heading', () => {
36
36
  assert.deepStrictEqual(inspect(parser('# a ')), [['<h1 id="index:a">a</h1>'], '']);
37
37
  assert.deepStrictEqual(inspect(parser('# a b c \n')), [['<h1 id="index:a_b_c">a b c</h1>'], '']);
38
38
  assert.deepStrictEqual(inspect(parser('# a\n')), [['<h1 id="index:a">a</h1>'], '']);
39
- assert.deepStrictEqual(inspect(parser('# *a*`b`${c}$')), [['<h1 id="index:a`b`${c}$"><em>a</em><code data-src="`b`">b</code><span class="math" translate="no" data-src="${c}$">${c}$</span></h1>'], '']);
39
+ assert.deepStrictEqual(inspect(parser('# _a_`b`${c}$')), [['<h1 id="index:a`b`${c}$"><em>a</em><code data-src="`b`">b</code><span class="math" translate="no" data-src="${c}$">${c}$</span></h1>'], '']);
40
40
  assert.deepStrictEqual(inspect(parser('# a\\')), [['<h1 id="index:a">a</h1>'], '']);
41
41
  assert.deepStrictEqual(inspect(parser('# a\\\n')), [['<h1 id="index:a">a</h1>'], '']);
42
42
  assert.deepStrictEqual(inspect(parser('# \\')), [['<h1 id="index:\\">\\</h1>'], '']);
@@ -69,7 +69,7 @@ describe('Unit: parser/block/heading', () => {
69
69
  assert.deepStrictEqual(inspect(parser('# a [#b ]')), [['<h1 id="index:b">a<span class="indexer" data-index="b"></span></h1>'], '']);
70
70
  assert.deepStrictEqual(inspect(parser('# a [#b ]')), [['<h1 id="index:b">a<span class="indexer" data-index="b"></span></h1>'], '']);
71
71
  assert.deepStrictEqual(inspect(parser('# a [#b c]')), [['<h1 id="index:b_c">a<span class="indexer" data-index="b_c"></span></h1>'], '']);
72
- assert.deepStrictEqual(inspect(parser('# a [#*b*`c`${d}$]')), [['<h1 id="index:b`c`${d}$">a<span class="indexer" data-index="b`c`${d}$"></span></h1>'], '']);
72
+ assert.deepStrictEqual(inspect(parser('# a [#_b_`c`${d}$]')), [['<h1 id="index:b`c`${d}$">a<span class="indexer" data-index="b`c`${d}$"></span></h1>'], '']);
73
73
  assert.deepStrictEqual(inspect(parser('# a [#@a]')), [['<h1 id="index:@a">a<span class="indexer" data-index="@a"></span></h1>'], '']);
74
74
  assert.deepStrictEqual(inspect(parser('# a [#http://host]')), [['<h1 id="index:http://host">a<span class="indexer" data-index="http://host"></span></h1>'], '']);
75
75
  assert.deepStrictEqual(inspect(parser('# a [#!http://host]')), [['<h1 id="index:!http://host">a<span class="indexer" data-index="!http://host"></span></h1>'], '']);
@@ -27,11 +27,8 @@ describe('Unit: parser/block/paragraph', () => {
27
27
  assert.deepStrictEqual(inspect(parser('<wbr>\na')), [['<p>&lt;wbr&gt;<br>a</p>'], '']);
28
28
  assert.deepStrictEqual(inspect(parser('a\n<wbr>\n')), [['<p>a<br>&lt;wbr&gt;</p>'], '']);
29
29
  assert.deepStrictEqual(inspect(parser('a\n<wbr>\nb')), [['<p>a<br>&lt;wbr&gt;<br>b</p>'], '']);
30
+ assert.deepStrictEqual(inspect(parser('_a\n<wbr>_\nb')), [['<p>_a<br><wbr>_<br>b</p>'], '']);
30
31
  assert.deepStrictEqual(inspect(parser('*a\n<wbr>*\nb')), [['<p>*a<br><wbr>*<br>b</p>'], '']);
31
- assert.deepStrictEqual(inspect(parser('**a\n<wbr>**\nb')), [['<p>**a<br><wbr>**<br>b</p>'], '']);
32
- assert.deepStrictEqual(inspect(parser('***a\n<wbr>***\nb')), [['<p>***a<br><wbr>***<br>b</p>'], '']);
33
- assert.deepStrictEqual(inspect(parser('***a*b\n<wbr>**\nc')), [['<p>**<em>a</em>b<br><wbr>**<br>c</p>'], '']);
34
- assert.deepStrictEqual(inspect(parser('***a**b\n<wbr>*\nc')), [['<p>*<strong>a</strong>b<br><wbr>*<br>c</p>'], '']);
35
32
  assert.deepStrictEqual(inspect(parser('==a\n<wbr>==\nb')), [['<p>==a<br><wbr>==<br>b</p>'], '']);
36
33
  assert.deepStrictEqual(inspect(parser('\ta')), [['<p>\ta</p>'], '']);
37
34
  });
@@ -16,6 +16,7 @@ describe('Unit: parser/inline/autolink/anchor', () => {
16
16
  assert.deepStrictEqual(inspect(parser('>>https://host')), undefined);
17
17
  assert.deepStrictEqual(inspect(parser('>>tel:1234567890')), undefined);
18
18
  assert.deepStrictEqual(inspect(parser('>>>')), undefined);
19
+ assert.deepStrictEqual(inspect(parser('a>>0')), [['a>>0'], '']);
19
20
  assert.deepStrictEqual(inspect(parser(' >>0')), undefined);
20
21
  });
21
22
 
@@ -8,6 +8,9 @@ describe('Unit: parser/inline/autolink/email', () => {
8
8
 
9
9
  it('invalid', () => {
10
10
  assert.deepStrictEqual(inspect(parser('')), undefined);
11
+ assert.deepStrictEqual(inspect(parser('a_b')), [['a'], '_b']);
12
+ assert.deepStrictEqual(inspect(parser('a_b_c')), [['a'], '_b_c']);
13
+ assert.deepStrictEqual(inspect(parser(`a_${'b'.repeat(255 - 2)}@`)), [[`a_${'b'.repeat(255 - 2)}@`], '']);
11
14
  assert.deepStrictEqual(inspect(parser('a@')), [['a@'], '']);
12
15
  assert.deepStrictEqual(inspect(parser('a@+')), [['a@'], '+']);
13
16
  assert.deepStrictEqual(inspect(parser('a@_')), [['a@'], '_']);
@@ -6,6 +6,6 @@ import { html } from 'typed-dom/dom';
6
6
  // https://html.spec.whatwg.org/multipage/input.html
7
7
 
8
8
  export const email: AutolinkParser.EmailParser = creation(rewrite(verify(
9
- str(/^[0-9a-z](?:[.+_-](?=[^\W_])|[0-9a-z]){0,255}@[0-9a-z](?:(?:[0-9a-z]|-(?=\w)){0,61}[0-9a-z])?(?:\.[0-9a-z](?:(?:[0-9a-z]|-(?=\w)){0,61}[0-9a-z])?)*(?![0-9a-z])/i),
9
+ str(/^[0-9a-z](?:[_.+-](?=[0-9a-z])|[0-9a-z]){0,255}@[0-9a-z](?:(?:[0-9a-z]|-(?=\w)){0,61}[0-9a-z])?(?:\.[0-9a-z](?:(?:[0-9a-z]|-(?=\w)){0,61}[0-9a-z])?)*(?![0-9a-z])/i),
10
10
  ([source]) => source.length <= 255),
11
11
  ({ source }) => [[html('a', { class: 'email', href: `mailto:${source}` }, source)], '']));
@@ -20,8 +20,6 @@ describe('Unit: parser/inline/autolink/hashnum', () => {
20
20
  assert.deepStrictEqual(inspect(parser('##')), [['##'], '']);
21
21
  assert.deepStrictEqual(inspect(parser('##1')), [['##1'], '']);
22
22
  assert.deepStrictEqual(inspect(parser('###1')), [['###1'], '']);
23
- assert.deepStrictEqual(inspect(parser(`#1'`)), [[`#1'`], '']);
24
- assert.deepStrictEqual(inspect(parser(`#1''`)), [[`#1''`], '']);
25
23
  assert.deepStrictEqual(inspect(parser('#{}')), [['#'], '{}']);
26
24
  assert.deepStrictEqual(inspect(parser('#{{}')), [['#'], '{{}']);
27
25
  assert.deepStrictEqual(inspect(parser('#{}}')), [['#'], '{}}']);
@@ -40,6 +38,7 @@ describe('Unit: parser/inline/autolink/hashnum', () => {
40
38
 
41
39
  it('valid', () => {
42
40
  assert.deepStrictEqual(inspect(parser('#1')), [['<a class="hashnum">#1</a>'], '']);
41
+ assert.deepStrictEqual(inspect(parser('#1_')), [['<a class="hashnum">#1</a>'], '_']);
43
42
  assert.deepStrictEqual(inspect(parser('#1 ')), [['<a class="hashnum">#1</a>'], ' ']);
44
43
  assert.deepStrictEqual(inspect(parser('#1\n')), [['<a class="hashnum">#1</a>'], '\n']);
45
44
  assert.deepStrictEqual(inspect(parser('#1\\')), [['<a class="hashnum">#1</a>'], '\\']);
@@ -8,7 +8,7 @@ import { define } from 'typed-dom/dom';
8
8
 
9
9
  export const hashnum: AutolinkParser.HashnumParser = lazy(() => fmap(rewrite(
10
10
  constraint(State.shortcut, false,
11
- open('#', str(new RegExp(/^[0-9]{1,16}(?![^\p{C}\p{S}\p{P}\s]|emoji|['_])/u.source.replace(/emoji/, emoji), 'u')))),
11
+ open('#', str(new RegExp(/^[0-9]{1,16}(?![^\p{C}\p{S}\p{P}\s]|emoji|')/u.source.replace(/emoji/, emoji), 'u')))),
12
12
  convert(
13
13
  source => `[${source}]{ ${source.slice(1)} }`,
14
14
  union([unsafelink]))),