securemark 0.270.0 → 0.270.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.270.1
4
+
5
+ - Refactoring.
6
+
3
7
  ## 0.270.0
4
8
 
5
9
  - Change the operator precedence of double quotation to 3.
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! securemark v0.270.0 https://github.com/falsandtru/securemark | (c) 2017, falsandtru | UNLICENSED License */
1
+ /*! securemark v0.270.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"));
@@ -2090,7 +2090,13 @@ exports.pcg32 = exports.xorshift = exports.unique = exports.rndAf = exports.rndA
2090
2090
  const bases = Object.freeze([...Array(7)].map((_, i) => 1 << i));
2091
2091
  const masks = Object.freeze(bases.map(radix => radix - 1));
2092
2092
  const dict0_ = [...[...Array(36)].map((_, i) => i.toString(36)), ...[...Array(36)].map((_, i) => i.toString(36).toUpperCase()).slice(-26), '-', '_'].join('');
2093
+
2094
+ // eslint-disable-next-line
2095
+
2093
2096
  const dictAz = [...[...Array(36)].map((_, i) => i.toString(36).toUpperCase()).slice(-26), ...[...Array(36)].map((_, i) => i.toString(36)).slice(-26)].join('');
2097
+
2098
+ // eslint-disable-next-line
2099
+
2094
2100
  exports.rnd16 = cons(16);
2095
2101
  exports.rnd32 = cons(32);
2096
2102
  exports.rnd62 = cons(62);
@@ -2391,7 +2397,10 @@ class URL {
2391
2397
  this.source = source;
2392
2398
  this.base = base;
2393
2399
  this.url = new format_1.ReadonlyURL(source, base);
2400
+
2401
+ //assert(this.href.startsWith(this.resource));
2394
2402
  }
2403
+
2395
2404
  get href() {
2396
2405
  return this.params?.toString().replace(/^(?=.)/, `${this.url.href.slice(0, -this.url.query.length - this.url.fragment.length || this.url.href.length)}?`).concat(this.fragment) ?? this.url.href;
2397
2406
  }
@@ -6101,7 +6110,7 @@ const indexee_1 = __webpack_require__(1269);
6101
6110
  const source_1 = __webpack_require__(6743);
6102
6111
  const visibility_1 = __webpack_require__(7618);
6103
6112
  const dom_1 = __webpack_require__(3252);
6104
- exports.index = (0, combinator_1.lazy)(() => (0, combinator_1.validate)('[#', (0, combinator_1.fmap)((0, indexee_1.indexee)((0, combinator_1.surround)('[#', (0, combinator_1.constraint)(64 /* State.index */, false, (0, combinator_1.syntax)(128 /* Syntax.index */, 2, 1, 502 /* State.linkers */ | 8 /* State.media */, (0, visibility_1.startTight)((0, combinator_1.open)((0, source_1.stropt)('|'), (0, visibility_1.trimBlankEnd)((0, combinator_1.some)((0, combinator_1.union)([signature, inline_1.inline]), ']', [[/^\\?\n/, 9], [']', 2]])), true)))), ']', false, ([, ns], rest) => [[(0, dom_1.html)('a', (0, dom_1.defrag)(ns))], rest])), ([el]) => [(0, dom_1.define)(el, {
6113
+ exports.index = (0, combinator_1.lazy)(() => (0, combinator_1.validate)('[#', (0, combinator_1.fmap)((0, indexee_1.indexee)((0, combinator_1.surround)('[#', (0, combinator_1.constraint)(64 /* State.index */, false, (0, combinator_1.syntax)(128 /* Syntax.index */, 2, 1, 502 /* State.linkers */ | 8 /* State.media */, (0, visibility_1.startTight)((0, combinator_1.open)((0, source_1.stropt)('|'), (0, combinator_1.some)((0, combinator_1.union)([signature, inline_1.inline]), ']', [[/^\\?\n/, 9], [']', 2]]), true)))), ']', false, ([, ns], rest) => [[(0, dom_1.html)('a', (0, visibility_1.trimNodeEnd)((0, dom_1.defrag)(ns)))], rest])), ([el]) => [(0, dom_1.define)(el, {
6105
6114
  id: el.id ? null : undefined,
6106
6115
  class: 'index',
6107
6116
  href: el.id ? `#${el.id}` : undefined
@@ -6271,7 +6280,7 @@ const array_1 = __webpack_require__(8112);
6271
6280
  const dom_1 = __webpack_require__(3252);
6272
6281
  // Don't use the symbols already used: !#$%@&*+~=|
6273
6282
  // All syntax surrounded by square brackets shouldn't contain line breaks.
6274
- exports.placeholder = (0, combinator_1.lazy)(() => (0, combinator_1.validate)('[', (0, combinator_1.surround)((0, source_1.str)(/^\[[:^|]/), (0, combinator_1.syntax)(64 /* Syntax.placeholder */, 2, 1, 0 /* State.none */, (0, visibility_1.startTight)((0, visibility_1.trimBlankEnd)((0, combinator_1.some)((0, combinator_1.union)([inline_1.inline]), ']', [[']', 2]])))), (0, source_1.str)(']'), false, ([, bs], rest) => [[(0, dom_1.html)('span', {
6283
+ exports.placeholder = (0, combinator_1.lazy)(() => (0, combinator_1.validate)('[', (0, combinator_1.surround)((0, source_1.str)(/^\[[:^|]/), (0, combinator_1.syntax)(64 /* Syntax.placeholder */, 2, 1, 0 /* State.none */, (0, visibility_1.startTight)((0, combinator_1.some)((0, combinator_1.union)([inline_1.inline]), ']', [[']', 2]]))), (0, source_1.str)(']'), false, ([, bs], rest) => [[(0, dom_1.html)('span', {
6275
6284
  class: 'invalid',
6276
6285
  'data-invalid-syntax': 'extension',
6277
6286
  'data-invalid-type': 'syntax',
@@ -6700,7 +6709,7 @@ const source_1 = __webpack_require__(6743);
6700
6709
  const visibility_1 = __webpack_require__(7618);
6701
6710
  const util_1 = __webpack_require__(9437);
6702
6711
  const dom_1 = __webpack_require__(3252);
6703
- exports.reference = (0, combinator_1.lazy)(() => (0, combinator_1.surround)('[[', (0, combinator_1.constraint)(128 /* State.reference */, false, (0, combinator_1.syntax)(256 /* Syntax.reference */, 6, 1, 256 /* State.annotation */ | 128 /* State.reference */ | 8 /* State.media */, (0, visibility_1.startLoose)((0, combinator_1.subsequence)([abbr, (0, combinator_1.open)((0, source_1.stropt)(/^(?=\^)/), (0, combinator_1.some)(inline_1.inline, ']', [[/^\\?\n/, 9], [']', 2], [']]', 6]])), (0, combinator_1.some)(inline_1.inline, ']', [[/^\\?\n/, 9], [']', 2], [']]', 6]])]), ']'))), ']]', false, ([, ns], rest) => [[(0, dom_1.html)('sup', attributes(ns), [(0, dom_1.html)('span', (0, visibility_1.trimNode)((0, dom_1.defrag)(ns)))])], rest]));
6712
+ exports.reference = (0, combinator_1.lazy)(() => (0, combinator_1.surround)('[[', (0, combinator_1.constraint)(128 /* State.reference */, false, (0, combinator_1.syntax)(256 /* Syntax.reference */, 6, 1, 256 /* State.annotation */ | 128 /* State.reference */ | 8 /* State.media */, (0, visibility_1.startLoose)((0, combinator_1.subsequence)([abbr, (0, combinator_1.fmap)((0, source_1.str)('^'), ns => ['', ...ns]), (0, combinator_1.some)(inline_1.inline, ']', [[/^\\?\n/, 9], [']', 2], [']]', 6]])]), ']'))), ']]', false, ([, ns], rest) => [[(0, dom_1.html)('sup', attributes(ns), [(0, dom_1.html)('span', (0, visibility_1.trimNode)((0, dom_1.defrag)(ns)))])], rest]));
6704
6713
  const abbr = (0, combinator_1.creation)((0, combinator_1.bind)((0, combinator_1.surround)('^', (0, combinator_1.union)([(0, source_1.str)(/^(?![0-9]+\s?[|\]])[0-9A-Za-z]+(?:(?:-|(?=\W)(?!'\d)'?(?!\.\d)\.?(?!,\S),? ?)[0-9A-Za-z]+)*(?:-|'?\.?,? ?)?/)]), /^\|?(?=]])|^\|[^\S\n]*/), ([source], rest) => [[(0, dom_1.html)('abbr', source)], rest.replace(visibility_1.regBlankStart, '')]));
6705
6714
  function attributes(ns) {
6706
6715
  return typeof ns[0] === 'object' && ns[0].tagName === 'ABBR' ? {
@@ -7579,7 +7588,7 @@ exports.stringify = stringify;
7579
7588
  Object.defineProperty(exports, "__esModule", ({
7580
7589
  value: true
7581
7590
  }));
7582
- exports.trimNode = exports.trimBlankEnd = exports.trimBlankStart = exports.trimBlank = exports.isStartTightNodes = exports.isStartLooseNodes = exports.startTight = exports.startLoose = exports.blankWith = exports.regBlankStart = exports.visualize = void 0;
7591
+ exports.trimNodeEnd = exports.trimNode = exports.trimBlank = exports.isStartTightNodes = exports.isStartLooseNodes = exports.startTight = exports.startLoose = exports.blankWith = exports.regBlankStart = exports.visualize = void 0;
7583
7592
  const parser_1 = __webpack_require__(6728);
7584
7593
  const combinator_1 = __webpack_require__(2087);
7585
7594
  const htmlentity_1 = __webpack_require__(1562);
@@ -7715,11 +7724,9 @@ exports.trimBlank = trimBlank;
7715
7724
  function trimBlankStart(parser) {
7716
7725
  return (0, combinator_1.convert)((0, memoize_1.reduce)(source => source.replace(exports.regBlankStart, '')), parser);
7717
7726
  }
7718
- exports.trimBlankStart = trimBlankStart;
7719
7727
  function trimBlankEnd(parser) {
7720
7728
  return (0, combinator_1.fmap)(parser, trimNodeEnd);
7721
7729
  }
7722
- exports.trimBlankEnd = trimBlankEnd;
7723
7730
  function trimNode(nodes) {
7724
7731
  return trimNodeStart(trimNodeEnd(nodes));
7725
7732
  }
@@ -7752,6 +7759,7 @@ function trimNodeEnd(nodes) {
7752
7759
  }
7753
7760
  return (0, array_1.push)(nodes, skip);
7754
7761
  }
7762
+ exports.trimNodeEnd = trimNodeEnd;
7755
7763
 
7756
7764
  /***/ }),
7757
7765
 
@@ -8714,9 +8722,9 @@ exports.defrag = defrag;
8714
8722
  /******/ // startup
8715
8723
  /******/ // Load entry module and return exports
8716
8724
  /******/ // This entry module is referenced by other modules so it can't be inlined
8717
- /******/ var __webpack_exports__ = __nested_webpack_require_11449__(521);
8725
+ /******/ var __nested_webpack_exports__ = __nested_webpack_require_11449__(521);
8718
8726
  /******/
8719
- /******/ return __webpack_exports__;
8727
+ /******/ return __nested_webpack_exports__;
8720
8728
  /******/ })()
8721
8729
  ;
8722
8730
  });
@@ -8734,10 +8742,10 @@ exports.defrag = defrag;
8734
8742
  })(this, () => {
8735
8743
  return /******/ (() => { // webpackBootstrap
8736
8744
  /******/ "use strict";
8737
- var __webpack_exports__ = {};
8745
+ var __nested_webpack_exports__ = {};
8738
8746
  // This entry need to be wrapped in an IIFE because it uses a non-standard name for the exports (exports).
8739
8747
  (() => {
8740
- var exports = __webpack_exports__;
8748
+ var exports = __nested_webpack_exports__;
8741
8749
 
8742
8750
 
8743
8751
  Object.defineProperty(exports, "__esModule", ({
@@ -8769,7 +8777,7 @@ function querySelectorAll(node, selector) {
8769
8777
  exports.querySelectorAll = querySelectorAll;
8770
8778
  })();
8771
8779
 
8772
- /******/ return __webpack_exports__;
8780
+ /******/ return __nested_webpack_exports__;
8773
8781
  /******/ })()
8774
8782
  ;
8775
8783
  });
package/markdown.d.ts CHANGED
@@ -663,7 +663,7 @@ export namespace MarkdownParser {
663
663
  Inline<'reference'>,
664
664
  Parser<HTMLElement, Context, [
665
665
  ReferenceParser.AbbrParser,
666
- InlineParser,
666
+ SourceParser.StrParser,
667
667
  InlineParser,
668
668
  ]> {
669
669
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "securemark",
3
- "version": "0.270.0",
3
+ "version": "0.270.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",
@@ -4,7 +4,7 @@ import { inline } from '../../inline';
4
4
  import { indexee, identity } from './indexee';
5
5
  import { txt, str, stropt } from '../../source';
6
6
  import { Syntax, State } from '../../context';
7
- import { startTight, trimBlankEnd } from '../../visibility';
7
+ import { startTight, trimNodeEnd } from '../../visibility';
8
8
  import { html, define, defrag } from 'typed-dom/dom';
9
9
 
10
10
  import IndexParser = ExtensionParser.IndexParser;
@@ -14,13 +14,13 @@ export const index: IndexParser = lazy(() => validate('[#', fmap(indexee(surroun
14
14
  constraint(State.index, false,
15
15
  syntax(Syntax.index, 2, 1, State.linkers | State.media,
16
16
  startTight(
17
- open(stropt('|'), trimBlankEnd(some(union([
17
+ open(stropt('|'), some(union([
18
18
  signature,
19
19
  inline,
20
- ]), ']', [[/^\\?\n/, 9], [']', 2]])), true)))),
20
+ ]), ']', [[/^\\?\n/, 9], [']', 2]]), true)))),
21
21
  ']',
22
22
  false,
23
- ([, ns], rest) => [[html('a', defrag(ns))], rest])),
23
+ ([, ns], rest) => [[html('a', trimNodeEnd(defrag(ns)))], rest])),
24
24
  ([el]: [HTMLAnchorElement]) => [
25
25
  define(el,
26
26
  {
@@ -33,16 +33,16 @@ describe('Unit: parser/inline/extension/placeholder', () => {
33
33
  it('valid', () => {
34
34
  assert.deepStrictEqual(inspect(parser('[^a]')), [['<span class="invalid">a</span>'], '']);
35
35
  assert.deepStrictEqual(inspect(parser('[^a b]')), [['<span class="invalid">a b</span>'], '']);
36
- assert.deepStrictEqual(inspect(parser('[^a ]')), [['<span class="invalid">a</span>'], '']);
37
- assert.deepStrictEqual(inspect(parser('[^a ]')), [['<span class="invalid">a</span>'], '']);
38
- assert.deepStrictEqual(inspect(parser('[^a\\ ]')), [['<span class="invalid">a</span>'], '']);
39
- assert.deepStrictEqual(inspect(parser('[^a\\ \\ ]')), [['<span class="invalid">a</span>'], '']);
40
- assert.deepStrictEqual(inspect(parser('[^a\n]')), [['<span class="invalid">a</span>'], '']);
41
- assert.deepStrictEqual(inspect(parser('[^a\\\n]')), [['<span class="invalid">a</span>'], '']);
36
+ assert.deepStrictEqual(inspect(parser('[^a ]')), [['<span class="invalid">a </span>'], '']);
37
+ assert.deepStrictEqual(inspect(parser('[^a ]')), [['<span class="invalid">a </span>'], '']);
38
+ assert.deepStrictEqual(inspect(parser('[^a\\ ]')), [['<span class="invalid">a </span>'], '']);
39
+ assert.deepStrictEqual(inspect(parser('[^a\\ \\ ]')), [['<span class="invalid">a </span>'], '']);
40
+ assert.deepStrictEqual(inspect(parser('[^a\n]')), [['<span class="invalid">a<br></span>'], '']);
41
+ assert.deepStrictEqual(inspect(parser('[^a\\\n]')), [['<span class="invalid">a<br></span>'], '']);
42
42
  assert.deepStrictEqual(inspect(parser('[^a\nb]')), [['<span class="invalid">a<br>b</span>'], '']);
43
43
  assert.deepStrictEqual(inspect(parser('[^a\\\nb]')), [['<span class="invalid">a<br>b</span>'], '']);
44
- assert.deepStrictEqual(inspect(parser('[^a<wbr>]')), [['<span class="invalid">a</span>'], '']);
45
- assert.deepStrictEqual(inspect(parser('[^a<wbr><wbr>]')), [['<span class="invalid">a</span>'], '']);
44
+ assert.deepStrictEqual(inspect(parser('[^a<wbr>]')), [['<span class="invalid">a<wbr></span>'], '']);
45
+ assert.deepStrictEqual(inspect(parser('[^a<wbr><wbr>]')), [['<span class="invalid">a<wbr><wbr></span>'], '']);
46
46
  assert.deepStrictEqual(inspect(parser('[^==]')), [['<span class="invalid">==</span>'], '']);
47
47
  assert.deepStrictEqual(inspect(parser('[^a[% b %]]')), [['<span class="invalid">a<span class="comment"><input type="checkbox"><span>[% b %]</span></span></span>'], '']);
48
48
  assert.deepStrictEqual(inspect(parser('[^a[% b %][% c %]]')), [['<span class="invalid">a<span class="comment"><input type="checkbox"><span>[% b %]</span></span><span class="comment"><input type="checkbox"><span>[% c %]</span></span></span>'], '']);
@@ -3,7 +3,7 @@ import { union, some, syntax, validate, surround, lazy } from '../../../combinat
3
3
  import { inline } from '../../inline';
4
4
  import { str } from '../../source';
5
5
  import { Syntax, State } from '../../context';
6
- import { startTight, trimBlankEnd } from '../../visibility';
6
+ import { startTight } from '../../visibility';
7
7
  import { unshift } from 'spica/array';
8
8
  import { html, defrag } from 'typed-dom/dom';
9
9
 
@@ -14,7 +14,7 @@ import { html, defrag } from 'typed-dom/dom';
14
14
  export const placeholder: ExtensionParser.PlaceholderParser = lazy(() => validate('[', surround(
15
15
  str(/^\[[:^|]/),
16
16
  syntax(Syntax.placeholder, 2, 1, State.none,
17
- startTight(trimBlankEnd(some(union([inline]), ']', [[']', 2]])))),
17
+ startTight(some(union([inline]), ']', [[']', 2]]))),
18
18
  str(']'), false,
19
19
  ([, bs], rest) => [[
20
20
  html('span', {
@@ -1,7 +1,7 @@
1
1
  import { ReferenceParser } from '../inline';
2
- import { union, subsequence, some, syntax, creation, constraint, surround, open, lazy, bind } from '../../combinator';
2
+ import { union, subsequence, some, syntax, creation, constraint, surround, lazy, fmap, bind } from '../../combinator';
3
3
  import { inline } from '../inline';
4
- import { str, stropt } from '../source';
4
+ import { str } from '../source';
5
5
  import { Syntax, State } from '../context';
6
6
  import { regBlankStart, startLoose, trimNode } from '../visibility';
7
7
  import { stringify } from '../util';
@@ -14,7 +14,7 @@ export const reference: ReferenceParser = lazy(() => surround(
14
14
  startLoose(
15
15
  subsequence([
16
16
  abbr,
17
- open(stropt(/^(?=\^)/), some(inline, ']', [[/^\\?\n/, 9], [']', 2], [']]', 6]])),
17
+ fmap(str('^'), ns => ['', ...ns]),
18
18
  some(inline, ']', [[/^\\?\n/, 9], [']', 2], [']]', 6]]),
19
19
  ]), ']'))),
20
20
  ']]',
@@ -150,14 +150,14 @@ export function trimBlank<P extends Parser<HTMLElement | string>>(parser: P): P;
150
150
  export function trimBlank<T extends HTMLElement | string>(parser: Parser<T>): Parser<T> {
151
151
  return trimBlankStart(trimBlankEnd(parser));
152
152
  }
153
- export function trimBlankStart<P extends Parser<unknown>>(parser: P): P;
154
- export function trimBlankStart<T>(parser: Parser<T>): Parser<T> {
153
+ function trimBlankStart<P extends Parser<unknown>>(parser: P): P;
154
+ function trimBlankStart<T>(parser: Parser<T>): Parser<T> {
155
155
  return convert(
156
156
  reduce(source => source.replace(regBlankStart, '')),
157
157
  parser);
158
158
  }
159
- export function trimBlankEnd<P extends Parser<HTMLElement | string>>(parser: P): P;
160
- export function trimBlankEnd<T extends HTMLElement | string>(parser: Parser<T>): Parser<T> {
159
+ function trimBlankEnd<P extends Parser<HTMLElement | string>>(parser: P): P;
160
+ function trimBlankEnd<T extends HTMLElement | string>(parser: Parser<T>): Parser<T> {
161
161
  return fmap(
162
162
  parser,
163
163
  trimNodeEnd);
@@ -179,7 +179,7 @@ function trimNodeStart<T extends HTMLElement | string>(nodes: T[]): T[] {
179
179
  }
180
180
  return nodes;
181
181
  }
182
- function trimNodeEnd<T extends HTMLElement | string>(nodes: T[]): T[] {
182
+ export function trimNodeEnd<T extends HTMLElement | string>(nodes: T[]): T[] {
183
183
  const skip = nodes.length > 0 &&
184
184
  typeof nodes[nodes.length - 1] === 'object' &&
185
185
  nodes[nodes.length - 1]['className'] === 'indexer'
package/webpack.config.js CHANGED
@@ -81,7 +81,7 @@ module.exports = env => {
81
81
  return merge(config);
82
82
  case 'lint':
83
83
  return merge(config, {
84
- entry: glob.sync('./!(node_modules)**/*.ts'),
84
+ entry: glob.sync('./!(node_modules)/**/*.ts'),
85
85
  plugins: [
86
86
  new ESLintPlugin({
87
87
  extensions: ['ts'],