securemark 0.289.0 → 0.289.1

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.289.1
4
+
5
+ - Refactoring.
6
+
3
7
  ## 0.289.0
4
8
 
5
9
  - Improve bracket parser.
package/README.md CHANGED
@@ -69,7 +69,7 @@ Secure markdown renderer working on browsers for user input data.
69
69
  |-|------------------------------|
70
70
  |9| \n |
71
71
  |6| ` |
72
- |5| ${}$ |
72
+ |5| \${}$ |
73
73
  |4| [% %] |
74
74
  |3| \<tag>\</tag> |
75
75
  |2| $, " |
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! securemark v0.289.0 https://github.com/falsandtru/securemark | (c) 2017, falsandtru | UNLICENSED License */
1
+ /*! securemark v0.289.1 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("Prism"), require("DOMPurify"));
@@ -6121,17 +6121,17 @@ const array_1 = __webpack_require__(6876);
6121
6121
  const dom_1 = __webpack_require__(394);
6122
6122
  const indexA = /^[0-9A-Za-z]+(?:(?:[.-]|, )[0-9A-Za-z]+)*$/;
6123
6123
  const indexF = new RegExp(indexA.source.replace(', ', '[,、]').replace(/[09AZaz.]|\-(?!\w)/g, c => String.fromCodePoint(c.codePointAt(0) + 0xFEE0)));
6124
- exports.bracket = (0, combinator_1.lazy)(() => (0, combinator_1.union)([(0, combinator_1.surround)((0, source_1.str)('('), (0, combinator_1.recursion)(5 /* Recursion.bracket */, (0, combinator_1.precedence)(1, (0, combinator_1.some)(inline_1.inline, ')', [[')', 1]]))), (0, source_1.str)(')'), true, ([as, bs = [], cs], rest, {
6124
+ exports.bracket = (0, combinator_1.lazy)(() => (0, combinator_1.union)([(0, combinator_1.surround)((0, source_1.str)('('), (0, combinator_1.precedence)(1, (0, combinator_1.recursion)(5 /* Recursion.bracket */, (0, combinator_1.some)(inline_1.inline, ')', [[')', 1]]))), (0, source_1.str)(')'), true, ([as, bs = [], cs], rest, {
6125
6125
  recent = []
6126
6126
  }) => [indexA.test(recent[1]) ? recent : [(0, dom_1.html)('span', {
6127
6127
  class: 'paren'
6128
- }, (0, dom_1.defrag)((0, array_1.push)((0, array_1.unshift)(as, bs), cs)))], rest], ([as, bs = []], rest) => [(0, array_1.unshift)(as, bs), rest], [2 | 8 /* Backtrack.bracket */]), (0, combinator_1.surround)((0, source_1.str)('('), (0, combinator_1.recursion)(5 /* Recursion.bracket */, (0, combinator_1.precedence)(1, (0, combinator_1.some)(inline_1.inline, ')', [[')', 1]]))), (0, source_1.str)(')'), true, ([as, bs = [], cs], rest, {
6128
+ }, (0, dom_1.defrag)((0, array_1.push)((0, array_1.unshift)(as, bs), cs)))], rest], ([as, bs = []], rest) => [(0, array_1.unshift)(as, bs), rest], [2 | 8 /* Backtrack.bracket */]), (0, combinator_1.surround)((0, source_1.str)('('), (0, combinator_1.precedence)(1, (0, combinator_1.recursion)(5 /* Recursion.bracket */, (0, combinator_1.some)(inline_1.inline, ')', [[')', 1]]))), (0, source_1.str)(')'), true, ([as, bs = [], cs], rest, {
6129
6129
  recent = []
6130
6130
  }) => [indexF.test(recent[1]) ? recent : [(0, dom_1.html)('span', {
6131
6131
  class: 'paren'
6132
- }, (0, dom_1.defrag)((0, array_1.push)((0, array_1.unshift)(as, bs), cs)))], rest], ([as, bs = []], rest) => [(0, array_1.unshift)(as, bs), rest]), (0, combinator_1.surround)((0, source_1.str)('['), (0, combinator_1.recursion)(5 /* Recursion.bracket */, (0, combinator_1.precedence)(1, (0, combinator_1.some)(inline_1.inline, ']', [[']', 1]]))), (0, source_1.str)(']'), true, undefined, ([as, bs = []], rest) => [(0, array_1.unshift)(as, bs), rest], [2 | 8 /* Backtrack.bracket */]), (0, combinator_1.surround)((0, source_1.str)('['), (0, combinator_1.recursion)(5 /* Recursion.bracket */, (0, combinator_1.precedence)(1, (0, combinator_1.some)(inline_1.inline, ']', [[']', 1]]))), (0, source_1.str)(']'), true, undefined, ([as, bs = []], rest) => [(0, array_1.unshift)(as, bs), rest]), (0, combinator_1.surround)((0, source_1.str)('{'), (0, combinator_1.recursion)(5 /* Recursion.bracket */, (0, combinator_1.precedence)(1, (0, combinator_1.some)(inline_1.inline, '}', [['}', 1]]))), (0, source_1.str)('}'), true, undefined, ([as, bs = []], rest) => [(0, array_1.unshift)(as, bs), rest], [2 | 8 /* Backtrack.bracket */]), (0, combinator_1.surround)((0, source_1.str)('{'), (0, combinator_1.recursion)(5 /* Recursion.bracket */, (0, combinator_1.precedence)(1, (0, combinator_1.some)(inline_1.inline, '}', [['}', 1]]))), (0, source_1.str)('}'), true, undefined, ([as, bs = []], rest) => [(0, array_1.unshift)(as, bs), rest]),
6133
- // 改行禁止はバックトラックなしでは内側の構文を破壊するため安易に行えない。
6134
- (0, combinator_1.surround)((0, source_1.str)('"'), (0, combinator_1.recursion)(5 /* Recursion.bracket */, (0, combinator_1.precedence)(2, (0, combinator_1.some)(inline_1.inline, '"', [['"', 2, false]]))), (0, source_1.str)('"'), true, ([as, bs = [], cs], rest, {
6132
+ }, (0, dom_1.defrag)((0, array_1.push)((0, array_1.unshift)(as, bs), cs)))], rest], ([as, bs = []], rest) => [(0, array_1.unshift)(as, bs), rest]), (0, combinator_1.surround)((0, source_1.str)('['), (0, combinator_1.precedence)(1, (0, combinator_1.recursion)(5 /* Recursion.bracket */, (0, combinator_1.some)(inline_1.inline, ']', [[']', 1]]))), (0, source_1.str)(']'), true, undefined, ([as, bs = []], rest) => [(0, array_1.unshift)(as, bs), rest], [2 | 8 /* Backtrack.bracket */]), (0, combinator_1.surround)((0, source_1.str)('['), (0, combinator_1.precedence)(1, (0, combinator_1.recursion)(5 /* Recursion.bracket */, (0, combinator_1.some)(inline_1.inline, ']', [[']', 1]]))), (0, source_1.str)(']'), true, undefined, ([as, bs = []], rest) => [(0, array_1.unshift)(as, bs), rest]), (0, combinator_1.surround)((0, source_1.str)('{'), (0, combinator_1.precedence)(1, (0, combinator_1.recursion)(5 /* Recursion.bracket */, (0, combinator_1.some)(inline_1.inline, '}', [['}', 1]]))), (0, source_1.str)('}'), true, undefined, ([as, bs = []], rest) => [(0, array_1.unshift)(as, bs), rest], [2 | 8 /* Backtrack.bracket */]), (0, combinator_1.surround)((0, source_1.str)('{'), (0, combinator_1.precedence)(1, (0, combinator_1.recursion)(5 /* Recursion.bracket */, (0, combinator_1.some)(inline_1.inline, '}', [['}', 1]]))), (0, source_1.str)('}'), true, undefined, ([as, bs = []], rest) => [(0, array_1.unshift)(as, bs), rest]),
6133
+ // 同一行内でしか閉じない以外括弧と同じ挙動
6134
+ (0, combinator_1.surround)((0, source_1.str)('"'), (0, combinator_1.precedence)(2, (0, combinator_1.recursion)(5 /* Recursion.bracket */, (0, combinator_1.some)(inline_1.inline, '"', [['"', 2, false]]))), (0, source_1.str)('"'), true, ([as, bs = [], cs], rest, {
6135
6135
  linebreak = 0
6136
6136
  }) => linebreak > rest.length ? [(0, array_1.unshift)(as, bs), cs[0] + rest] : [(0, array_1.push)((0, array_1.unshift)(as, bs), cs), rest], ([as, bs = []], rest) => [(0, array_1.unshift)(as, bs), rest], [2 | 8 /* Backtrack.bracket */])]));
6137
6137
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "securemark",
3
- "version": "0.289.0",
3
+ "version": "0.289.1",
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",
@@ -11,7 +11,11 @@ const indexF = new RegExp(indexA.source.replace(', ', '[,、]')
11
11
  .replace(/[09AZaz.]|\-(?!\w)/g, c => String.fromCodePoint(c.codePointAt(0)! + 0xFEE0)));
12
12
 
13
13
  export const bracket: BracketParser = lazy(() => union([
14
- surround(str('('), recursion(Recursion.bracket, precedence(1, some(inline, ')', [[')', 1]]))), str(')'), true,
14
+ surround(
15
+ str('('),
16
+ precedence(1, recursion(Recursion.bracket, some(inline, ')', [[')', 1]]))),
17
+ str(')'),
18
+ true,
15
19
  ([as, bs = [], cs], rest, { recent = [] }) => [
16
20
  indexA.test(recent[1])
17
21
  ? recent
@@ -19,7 +23,11 @@ export const bracket: BracketParser = lazy(() => union([
19
23
  rest
20
24
  ],
21
25
  ([as, bs = []], rest) => [unshift(as, bs), rest], [2 | Backtrack.bracket]),
22
- surround(str('('), recursion(Recursion.bracket, precedence(1, some(inline, ')', [[')', 1]]))), str(')'), true,
26
+ surround(
27
+ str('('),
28
+ precedence(1, recursion(Recursion.bracket, some(inline, ')', [[')', 1]]))),
29
+ str(')'),
30
+ true,
23
31
  ([as, bs = [], cs], rest, { recent = [] }) => [
24
32
  indexF.test(recent[1])
25
33
  ? recent
@@ -27,20 +35,40 @@ export const bracket: BracketParser = lazy(() => union([
27
35
  rest
28
36
  ],
29
37
  ([as, bs = []], rest) => [unshift(as, bs), rest]),
30
- surround(str('['), recursion(Recursion.bracket, precedence(1, some(inline, ']', [[']', 1]]))), str(']'), true,
38
+ surround(
39
+ str('['),
40
+ precedence(1, recursion(Recursion.bracket, some(inline, ']', [[']', 1]]))),
41
+ str(']'),
42
+ true,
31
43
  undefined,
32
44
  ([as, bs = []], rest) => [unshift(as, bs), rest], [2 | Backtrack.bracket]),
33
- surround(str('['), recursion(Recursion.bracket, precedence(1, some(inline, ']', [[']', 1]]))), str(']'), true,
45
+ surround(
46
+ str('['),
47
+ precedence(1, recursion(Recursion.bracket, some(inline, ']', [[']', 1]]))),
48
+ str(']'),
49
+ true,
34
50
  undefined,
35
51
  ([as, bs = []], rest) => [unshift(as, bs), rest]),
36
- surround(str('{'), recursion(Recursion.bracket, precedence(1, some(inline, '}', [['}', 1]]))), str('}'), true,
52
+ surround(
53
+ str('{'),
54
+ precedence(1, recursion(Recursion.bracket, some(inline, '}', [['}', 1]]))),
55
+ str('}'),
56
+ true,
37
57
  undefined,
38
58
  ([as, bs = []], rest) => [unshift(as, bs), rest], [2 | Backtrack.bracket]),
39
- surround(str('{'), recursion(Recursion.bracket, precedence(1, some(inline, '}', [['}', 1]]))), str('}'), true,
59
+ surround(
60
+ str('{'),
61
+ precedence(1, recursion(Recursion.bracket, some(inline, '}', [['}', 1]]))),
62
+ str('}'),
63
+ true,
40
64
  undefined,
41
65
  ([as, bs = []], rest) => [unshift(as, bs), rest]),
42
- // 改行禁止はバックトラックなしでは内側の構文を破壊するため安易に行えない。
43
- surround(str('"'), recursion(Recursion.bracket, precedence(2, some(inline, '"', [['"', 2, false]]))), str('"'), true,
66
+ // 同一行内でしか閉じない以外括弧と同じ挙動
67
+ surround(
68
+ str('"'),
69
+ precedence(2, recursion(Recursion.bracket, some(inline, '"', [['"', 2, false]]))),
70
+ str('"'),
71
+ true,
44
72
  ([as, bs = [], cs], rest, { linebreak = 0 }) =>
45
73
  linebreak > rest.length
46
74
  ? [unshift(as, bs), cs[0] + rest]
@@ -84,7 +84,7 @@ describe('Unit: parser/inline', () => {
84
84
  assert.deepStrictEqual(inspect(parser('"*a\nb*')), [['"', '<em>a<br>b</em>'], '']);
85
85
  assert.deepStrictEqual(inspect(parser('"*a\n""b*')), [['"', '<em>a<br>""b</em>'], '']);
86
86
  assert.deepStrictEqual(inspect(parser('"a\n"*b"c*')), [['"', 'a', '<br>', '"', '*', 'b', '"', 'c', '*'], '']);
87
- assert.deepStrictEqual(inspect(parser('"*a\n**b**"("c*')), [['"', '<em>a<br><strong>b</strong>"("c</em>'], '']);
87
+ assert.deepStrictEqual(inspect(parser('"*a**b\nc**"("*')), [['"', '<em>a<strong>b<br>c</strong>"("</em>'], '']);
88
88
  assert.deepStrictEqual(inspect(parser('<bdi>a"\nb</bdi>')), [['<bdi>a"<br>b</bdi>'], '']);
89
89
  assert.deepStrictEqual(inspect(parser('"<bdi>"a\n""b</bdi>"')), [['"', '<bdi>"a<br>""b</bdi>', '"'], '']);
90
90
  assert.deepStrictEqual(inspect(parser('<bdi>*<bdi>a</bdi>*</bdi>')), [['<bdi><em><bdi>a</bdi></em></bdi>'], '']);