securemark 0.261.0 → 0.261.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.261.1
4
+
5
+ - Refactoring.
6
+
3
7
  ## 0.261.0
4
8
 
5
9
  - Change emphasis syntax and strong syntax.
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! securemark v0.261.0 https://github.com/falsandtru/securemark | (c) 2017, falsandtru | UNLICENSED License */
1
+ /*! securemark v0.261.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("DOMPurify"), require("Prism"));
@@ -5886,8 +5886,6 @@ exports.shortmedia = exports.media = exports.indexer = exports.indexee = exports
5886
5886
 
5887
5887
  const combinator_1 = __webpack_require__(2087);
5888
5888
 
5889
- const escape_1 = __webpack_require__(2778);
5890
-
5891
5889
  const annotation_1 = __webpack_require__(2736);
5892
5890
 
5893
5891
  const reference_1 = __webpack_require__(3555);
@@ -5930,7 +5928,7 @@ const bracket_1 = __webpack_require__(5196);
5930
5928
 
5931
5929
  const source_1 = __webpack_require__(6743);
5932
5930
 
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]);
5931
+ exports.inline = (0, combinator_1.union)([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]);
5934
5932
 
5935
5933
  var indexee_1 = __webpack_require__(1269);
5936
5934
 
@@ -6410,7 +6408,7 @@ const dom_1 = __webpack_require__(3252);
6410
6408
 
6411
6409
  const array_1 = __webpack_require__(8112);
6412
6410
 
6413
- exports.deletion = (0, combinator_1.lazy)(() => (0, combinator_1.surround)((0, source_1.str)('~~'), (0, combinator_1.syntax)(0
6411
+ exports.deletion = (0, combinator_1.lazy)(() => (0, combinator_1.surround)((0, source_1.str)('~~', '~'), (0, combinator_1.syntax)(0
6414
6412
  /* Syntax.none */
6415
6413
  , 1, 1, 0
6416
6414
  /* State.none */
@@ -6441,50 +6439,11 @@ const dom_1 = __webpack_require__(3252);
6441
6439
 
6442
6440
  const array_1 = __webpack_require__(8112);
6443
6441
 
6444
- exports.emphasis = (0, combinator_1.lazy)(() => (0, combinator_1.surround)((0, source_1.str)('_'), (0, combinator_1.syntax)(0
6442
+ exports.emphasis = (0, combinator_1.lazy)(() => (0, combinator_1.surround)((0, source_1.str)('_', '_'), (0, combinator_1.syntax)(0
6445
6443
  /* Syntax.none */
6446
6444
  , 1, 1, 0
6447
6445
  /* State.none */
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]));
6449
-
6450
- /***/ }),
6451
-
6452
- /***/ 2778:
6453
- /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
6454
-
6455
- "use strict";
6456
-
6457
-
6458
- Object.defineProperty(exports, "__esModule", ({
6459
- value: true
6460
- }));
6461
- exports.escape = void 0;
6462
-
6463
- const global_1 = __webpack_require__(4128);
6464
-
6465
- const combinator_1 = __webpack_require__(2087);
6466
-
6467
- const source_1 = __webpack_require__(6743);
6468
-
6469
- const repeat = (0, source_1.str)(/^(.)\1*/);
6470
- exports.escape = (0, combinator_1.union)([({
6471
- source,
6472
- context
6473
- }) => {
6474
- switch (source[0]) {
6475
- case '+':
6476
- case '~':
6477
- case '=':
6478
- if (!source[2]) return;
6479
- return source[2] === source[0] && source[1] === source[0] ? repeat({
6480
- source,
6481
- context
6482
- }) : global_1.undefined;
6483
-
6484
- default:
6485
- return;
6486
- }
6487
- }]);
6446
+ , (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]));
6488
6447
 
6489
6448
  /***/ }),
6490
6449
 
@@ -6916,7 +6875,7 @@ const dom_1 = __webpack_require__(3252);
6916
6875
 
6917
6876
  const array_1 = __webpack_require__(8112);
6918
6877
 
6919
- exports.insertion = (0, combinator_1.lazy)(() => (0, combinator_1.surround)((0, source_1.str)('++'), (0, combinator_1.syntax)(0
6878
+ exports.insertion = (0, combinator_1.lazy)(() => (0, combinator_1.surround)((0, source_1.str)('++', '+'), (0, combinator_1.syntax)(0
6920
6879
  /* Syntax.none */
6921
6880
  , 1, 1, 0
6922
6881
  /* State.none */
@@ -7122,7 +7081,7 @@ const dom_1 = __webpack_require__(3252);
7122
7081
 
7123
7082
  const array_1 = __webpack_require__(8112);
7124
7083
 
7125
- exports.mark = (0, combinator_1.lazy)(() => (0, combinator_1.surround)((0, source_1.str)('=='), (0, combinator_1.syntax)(0
7084
+ exports.mark = (0, combinator_1.lazy)(() => (0, combinator_1.surround)((0, source_1.str)('==', '='), (0, combinator_1.syntax)(0
7126
7085
  /* Syntax.none */
7127
7086
  , 1, 1, 0
7128
7087
  /* State.none */
@@ -7510,11 +7469,11 @@ const dom_1 = __webpack_require__(3252);
7510
7469
 
7511
7470
  const array_1 = __webpack_require__(8112);
7512
7471
 
7513
- exports.strong = (0, combinator_1.lazy)(() => (0, combinator_1.surround)((0, source_1.str)('*'), (0, combinator_1.syntax)(0
7472
+ exports.strong = (0, combinator_1.lazy)(() => (0, combinator_1.surround)((0, source_1.str)('*', '*'), (0, combinator_1.syntax)(0
7514
7473
  /* Syntax.none */
7515
7474
  , 1, 1, 0
7516
7475
  /* State.none */
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]));
7476
+ , (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]));
7518
7477
 
7519
7478
  /***/ }),
7520
7479
 
@@ -7640,7 +7599,7 @@ Object.defineProperty(exports, "__esModule", ({
7640
7599
  exports.japanese = void 0;
7641
7600
 
7642
7601
  function japanese(char) {
7643
- return /^[\p{Ideo}\p{Script_Extensions=Hiragana}\p{Script_Extensions=Katakana}~!?]/u.test(char);
7602
+ return /^[\p{Ideo}\p{scx=Hiragana}\p{scx=Katakana}~!?]/u.test(char);
7644
7603
  }
7645
7604
 
7646
7605
  exports.japanese = japanese;
@@ -8264,17 +8223,19 @@ const global_1 = __webpack_require__(4128);
8264
8223
 
8265
8224
  const combinator_1 = __webpack_require__(2087);
8266
8225
 
8267
- function str(pattern) {
8226
+ function str(pattern, not) {
8268
8227
  return typeof pattern === 'string' ? (0, combinator_1.creation)(1, false, ({
8269
8228
  source
8270
8229
  }) => {
8271
8230
  if (source === '') return;
8231
+ if (not && source.slice(pattern.length, pattern.length + not.length) === not) return;
8272
8232
  return source.slice(0, pattern.length) === pattern ? [[pattern], source.slice(pattern.length)] : global_1.undefined;
8273
8233
  }) : (0, combinator_1.creation)(1, false, ({
8274
8234
  source
8275
8235
  }) => {
8276
8236
  if (source === '') return;
8277
8237
  const m = source.match(pattern);
8238
+ if (m && not && source.slice(m[0].length, m[0].length + not.length) === not) return;
8278
8239
  return m && m[0].length > 0 ? [[m[0]], source.slice(m[0].length)] : global_1.undefined;
8279
8240
  });
8280
8241
  }
@@ -8319,10 +8280,10 @@ const str_1 = __webpack_require__(2790);
8319
8280
 
8320
8281
  const dom_1 = __webpack_require__(3252);
8321
8282
 
8322
- exports.delimiter = /[\s\x00-\x7F]|\S[#>]|[\p{Ideo}\p{Script_Extensions=Hiragana}\p{Script_Extensions=Katakana}~!?][^\S\n]*(?=\\\n)/u;
8283
+ exports.delimiter = /[\s\x00-\x7F]|\S[#>]|[\p{Ideo}\p{scx=Hiragana}\p{scx=Katakana}~!?][^\S\n]*(?=\\\n)/u;
8323
8284
  exports.nonWhitespace = /[\S\n]|$/;
8324
8285
  exports.nonAlphanumeric = /[^0-9A-Za-z]|\S[#>]|$/;
8325
- const nssb = /^[\p{Ideo}\p{Script_Extensions=Hiragana}\p{Script_Extensions=Katakana}~!?][^\S\n]*(?=\\\n)/u;
8286
+ const nssb = /^[\p{Ideo}\p{scx=Hiragana}\p{scx=Katakana}~!?][^\S\n]*(?=\\\n)/u;
8326
8287
  const repeat = (0, str_1.str)(/^(.)\1*/);
8327
8288
  exports.text = (0, combinator_1.creation)(1, false, ({
8328
8289
  source,
package/markdown.d.ts CHANGED
@@ -621,7 +621,6 @@ export namespace MarkdownParser {
621
621
  export interface InlineParser extends
622
622
  Markdown<'inline'>,
623
623
  Parser<HTMLElement | string, Context, [
624
- InlineParser.EscapeParser,
625
624
  InlineParser.AnnotationParser,
626
625
  InlineParser.ReferenceParser,
627
626
  InlineParser.TemplateParser,
@@ -647,16 +646,6 @@ export namespace MarkdownParser {
647
646
  }
648
647
  export namespace InlineParser {
649
648
  interface Inline<T extends string> extends Markdown<`inline/${T}`> { }
650
- export interface EscapeParser extends
651
- // ****
652
- // +++
653
- // ~~~
654
- // ===
655
- Inline<'escape'>,
656
- Parser<string, Context, [
657
- SourceParser.StrParser,
658
- ]> {
659
- }
660
649
  export interface AnnotationParser extends
661
650
  // ((abc))
662
651
  Inline<'annotation'>,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "securemark",
3
- "version": "0.261.0",
3
+ "version": "0.261.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",
@@ -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.33.0",
37
+ "@typescript-eslint/parser": "^5.33.1",
38
38
  "babel-loader": "^8.2.5",
39
39
  "babel-plugin-unassert": "^3.2.0",
40
40
  "concurrently": "^7.3.0",
41
- "eslint": "^8.21.0",
41
+ "eslint": "^8.22.0",
42
42
  "eslint-plugin-redos": "^4.4.1",
43
43
  "eslint-webpack-plugin": "^3.2.0",
44
44
  "glob": "^8.0.3",
@@ -8,7 +8,7 @@ import { html, defrag } from 'typed-dom/dom';
8
8
  import { unshift } from 'spica/array';
9
9
 
10
10
  export const deletion: DeletionParser = lazy(() => surround(
11
- str('~~'),
11
+ str('~~', '~'),
12
12
  syntax(Syntax.none, 1, 1, State.none,
13
13
  some(union([
14
14
  some(inline, blankWith('\n', '~~')),
@@ -8,12 +8,12 @@ import { html, defrag } from 'typed-dom/dom';
8
8
  import { unshift } from 'spica/array';
9
9
 
10
10
  export const emphasis: EmphasisParser = lazy(() => surround(
11
- str('_'),
11
+ str('_', '_'),
12
12
  syntax(Syntax.none, 1, 1, State.none,
13
13
  startTight(some(union([
14
14
  some(inline, blankWith('_')),
15
15
  open(some(inline, '_'), emphasis),
16
- ])), '_')),
16
+ ])))),
17
17
  str('_'), false,
18
18
  ([, bs], rest) => [[html('em', defrag(bs))], rest],
19
19
  ([as, bs], rest) => [unshift(as, bs), rest]));
@@ -8,7 +8,7 @@ import { html, defrag } from 'typed-dom/dom';
8
8
  import { unshift } from 'spica/array';
9
9
 
10
10
  export const insertion: InsertionParser = lazy(() => surround(
11
- str('++'),
11
+ str('++', '+'),
12
12
  syntax(Syntax.none, 1, 1, State.none,
13
13
  some(union([
14
14
  some(inline, blankWith('\n', '++')),
@@ -8,7 +8,7 @@ import { html, defrag } from 'typed-dom/dom';
8
8
  import { unshift } from 'spica/array';
9
9
 
10
10
  export const mark: MarkParser = lazy(() => surround(
11
- str('=='),
11
+ str('==', '='),
12
12
  syntax(Syntax.none, 1, 1, State.none,
13
13
  startTight(some(union([
14
14
  some(inline, blankWith('==')),
@@ -8,12 +8,12 @@ import { html, defrag } from 'typed-dom/dom';
8
8
  import { unshift } from 'spica/array';
9
9
 
10
10
  export const strong: StrongParser = lazy(() => surround(
11
- str('*'),
11
+ str('*', '*'),
12
12
  syntax(Syntax.none, 1, 1, State.none,
13
13
  startTight(some(union([
14
14
  some(inline, blankWith('*')),
15
15
  open(some(inline, '*'), strong),
16
- ])), '*')),
16
+ ])))),
17
17
  str('*'), false,
18
18
  ([, bs], rest) => [[html('strong', defrag(bs))], rest],
19
19
  ([as, bs], rest) => [unshift(as, bs), rest]));
@@ -1,6 +1,5 @@
1
1
  import { MarkdownParser } from '../../markdown';
2
2
  import { union } from '../combinator';
3
- import { escape } from './inline/escape';
4
3
  import { annotation } from './inline/annotation';
5
4
  import { reference } from './inline/reference';
6
5
  import { template } from './inline/template';
@@ -24,7 +23,6 @@ import { bracket } from './inline/bracket';
24
23
  import { text } from './source';
25
24
 
26
25
  export import InlineParser = MarkdownParser.InlineParser;
27
- export import EscapeParser = InlineParser.EscapeParser;
28
26
  export import AnnotationParser = InlineParser.AnnotationParser;
29
27
  export import ReferenceParser = InlineParser.ReferenceParser;
30
28
  export import TemplateParser = InlineParser.TemplateParser;
@@ -48,7 +46,6 @@ export import AutolinkParser = InlineParser.AutolinkParser;
48
46
  export import BracketParser = InlineParser.BracketParser;
49
47
 
50
48
  export const inline: InlineParser = union([
51
- escape,
52
49
  annotation,
53
50
  reference,
54
51
  template,
@@ -1,3 +1,3 @@
1
1
  export function japanese(char: string): boolean {
2
- return /^[\p{Ideo}\p{Script_Extensions=Hiragana}\p{Script_Extensions=Katakana}~!?]/u.test(char);
2
+ return /^[\p{Ideo}\p{scx=Hiragana}\p{scx=Katakana}~!?]/u.test(char);
3
3
  }
@@ -3,12 +3,13 @@ import { StrParser } from '../source';
3
3
  import { Parser, Context } from '../../combinator/data/parser';
4
4
  import { creation } from '../../combinator';
5
5
 
6
- export function str(pattern: string | RegExp): StrParser;
7
- export function str(pattern: string | RegExp): Parser<string, Context<StrParser>, []> {
6
+ export function str(pattern: string | RegExp, not?: string): StrParser;
7
+ export function str(pattern: string | RegExp, not?: string): Parser<string, Context<StrParser>, []> {
8
8
  assert(pattern);
9
9
  return typeof pattern === 'string'
10
10
  ? creation(1, false, ({ source }) => {
11
11
  if (source === '') return;
12
+ if (not && source.slice(pattern.length, pattern.length + not.length) === not) return;
12
13
  return source.slice(0, pattern.length) === pattern
13
14
  ? [[pattern], source.slice(pattern.length)]
14
15
  : undefined;
@@ -16,6 +17,7 @@ export function str(pattern: string | RegExp): Parser<string, Context<StrParser>
16
17
  : creation(1, false, ({ source }) => {
17
18
  if (source === '') return;
18
19
  const m = source.match(pattern);
20
+ if (m && not && source.slice(m[0].length, m[0].length + not.length) === not) return;
19
21
  return m && m[0].length > 0
20
22
  ? [[m[0]], source.slice(m[0].length)]
21
23
  : undefined;
@@ -4,10 +4,10 @@ import { union, creation, focus } from '../../combinator';
4
4
  import { str } from './str';
5
5
  import { html } from 'typed-dom/dom';
6
6
 
7
- export const delimiter = /[\s\x00-\x7F]|\S[#>]|[\p{Ideo}\p{Script_Extensions=Hiragana}\p{Script_Extensions=Katakana}~!?][^\S\n]*(?=\\\n)/u;
7
+ export const delimiter = /[\s\x00-\x7F]|\S[#>]|[\p{Ideo}\p{scx=Hiragana}\p{scx=Katakana}~!?][^\S\n]*(?=\\\n)/u;
8
8
  export const nonWhitespace = /[\S\n]|$/;
9
9
  export const nonAlphanumeric = /[^0-9A-Za-z]|\S[#>]|$/;
10
- const nssb = /^[\p{Ideo}\p{Script_Extensions=Hiragana}\p{Script_Extensions=Katakana}~!?][^\S\n]*(?=\\\n)/u;
10
+ const nssb = /^[\p{Ideo}\p{scx=Hiragana}\p{scx=Katakana}~!?][^\S\n]*(?=\\\n)/u;
11
11
  const repeat = str(/^(.)\1*/);
12
12
 
13
13
  export const text: TextParser = creation(1, false, ({ source, context }) => {
@@ -1,21 +0,0 @@
1
- import { undefined } from 'spica/global';
2
- import { EscapeParser } from '../inline';
3
- import { union } from '../../combinator';
4
- import { str } from '../source';
5
-
6
- const repeat = str(/^(.)\1*/);
7
-
8
- export const escape: EscapeParser = union([({ source, context }) => {
9
- switch (source[0]) {
10
- case '+':
11
- case '~':
12
- case '=':
13
- if (!source[2]) return;
14
- return source[2] === source[0]
15
- && source[1] === source[0]
16
- ? repeat({ source, context })
17
- : undefined;
18
- default:
19
- return;
20
- }
21
- }]);