securemark 0.258.7 → 0.258.8

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.258.8
4
+
5
+ - Refactoring.
6
+
3
7
  ## 0.258.7
4
8
 
5
9
  - Refactoring.
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! securemark v0.258.7 https://github.com/falsandtru/securemark | (c) 2017, falsandtru | UNLICENSED License */
1
+ /*! securemark v0.258.8 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"));
@@ -2884,6 +2884,7 @@ exports.syntax = syntax;
2884
2884
 
2885
2885
  function creation(cost, parser) {
2886
2886
  if (typeof cost === 'function') return creation(1, cost);
2887
+ if (cost === 0) return parser;
2887
2888
  return (source, context) => {
2888
2889
  const {
2889
2890
  resources = {
@@ -5700,13 +5701,13 @@ const dom_1 = __webpack_require__(3252);
5700
5701
 
5701
5702
  exports.annotation = (0, combinator_1.lazy)(() => (0, combinator_1.surround)('((', (0, combinator_1.constraint)(64
5702
5703
  /* State.annotation */
5703
- , false, (0, combinator_1.syntax)(32
5704
- /* Syntax.annotation */
5705
- , 6, 1, (0, combinator_1.state)(64
5704
+ , false, (0, combinator_1.state)(64
5706
5705
  /* State.annotation */
5707
5706
  | 2
5708
5707
  /* State.media */
5709
- , (0, visibility_1.startLoose)((0, combinator_1.context)({
5708
+ , (0, combinator_1.syntax)(32
5709
+ /* Syntax.annotation */
5710
+ , 6, 1, (0, visibility_1.startLoose)((0, combinator_1.context)({
5710
5711
  delimiters: global_1.undefined
5711
5712
  }, (0, combinator_1.some)((0, combinator_1.union)([inline_1.inline]), ')', [[/^\\?\n/, 9], [')', 2], ['))', 6]])), ')')))), '))', false, ([, ns], rest) => [[(0, dom_1.html)('sup', {
5712
5713
  class: 'annotation'
@@ -6252,9 +6253,7 @@ const dom_1 = __webpack_require__(3252);
6252
6253
 
6253
6254
  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)(16
6254
6255
  /* State.index */
6255
- , false, (0, combinator_1.syntax)(1024
6256
- /* Syntax.index */
6257
- , 2, 1, (0, combinator_1.state)(64
6256
+ , false, (0, combinator_1.state)(64
6258
6257
  /* State.annotation */
6259
6258
  | 32
6260
6259
  /* State.reference */
@@ -6268,7 +6267,9 @@ exports.index = (0, combinator_1.lazy)(() => (0, combinator_1.validate)('[#', (0
6268
6267
  /* State.media */
6269
6268
  | 1
6270
6269
  /* State.autolink */
6271
- , (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, {
6270
+ , (0, combinator_1.syntax)(1024
6271
+ /* Syntax.index */
6272
+ , 2, 1, (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, {
6272
6273
  id: el.id ? null : global_1.undefined,
6273
6274
  class: 'index',
6274
6275
  href: el.id ? `#${el.id}` : global_1.undefined
@@ -6679,9 +6680,7 @@ const optspec = {
6679
6680
  Object.setPrototypeOf(optspec, null);
6680
6681
  exports.link = (0, combinator_1.lazy)(() => (0, combinator_1.validate)(['[', '{'], (0, combinator_1.bind)((0, combinator_1.constraint)(4
6681
6682
  /* State.link */
6682
- , false, (0, combinator_1.syntax)(256
6683
- /* Syntax.link */
6684
- , 2, 10, (0, combinator_1.fmap)((0, combinator_1.subsequence)([(0, combinator_1.state)(4
6683
+ , false, (0, combinator_1.creation)(10, (0, combinator_1.fmap)((0, combinator_1.subsequence)([(0, combinator_1.state)(4
6685
6684
  /* State.link */
6686
6685
  , (0, combinator_1.dup)((0, combinator_1.union)([(0, combinator_1.surround)('[', inline_1.media, ']'), (0, combinator_1.surround)('[', inline_1.shortmedia, ']'), (0, combinator_1.surround)('[', (0, combinator_1.state)(64
6687
6686
  /* State.annotation */
@@ -6695,7 +6694,9 @@ exports.link = (0, combinator_1.lazy)(() => (0, combinator_1.validate)(['[', '{'
6695
6694
  /* State.media */
6696
6695
  | 1
6697
6696
  /* State.autolink */
6698
- , (0, combinator_1.some)(inline_1.inline, ']', [[/^\\?\n/, 9], [']', 2]])), ']', true)]))), (0, combinator_1.dup)((0, combinator_1.surround)(/^{(?![{}])/, (0, combinator_1.inits)([exports.uri, (0, combinator_1.some)(exports.option)]), /^[^\S\n]*}/))], nodes => nodes[0][0] !== ''), ([as, bs = []]) => bs[0] === '\r' && bs.shift() ? [as, bs] : as[0] === '\r' && as.shift() ? [[], as] : [as, []]))), ([content, params], rest, context) => {
6697
+ , (0, combinator_1.syntax)(256
6698
+ /* Syntax.link */
6699
+ , 2, 0, (0, combinator_1.some)(inline_1.inline, ']', [[/^\\?\n/, 9], [']', 2]]))), ']', true)]))), (0, combinator_1.dup)((0, combinator_1.surround)(/^{(?![{}])/, (0, combinator_1.inits)([exports.uri, (0, combinator_1.some)(exports.option)]), /^[^\S\n]*}/))], nodes => nodes[0][0] !== ''), ([as, bs = []]) => bs[0] === '\r' && bs.shift() ? [as, bs] : as[0] === '\r' && as.shift() ? [[], as] : [as, []]))), ([content, params], rest, context) => {
6699
6700
  if (content[0] === '') return [content, rest];
6700
6701
  if (params.length === 0) return;
6701
6702
  if (content.length !== 0 && (0, visibility_1.trimNode)(content).length === 0) return;
@@ -7000,15 +7001,15 @@ const dom_1 = __webpack_require__(3252);
7000
7001
 
7001
7002
  exports.reference = (0, combinator_1.lazy)(() => (0, combinator_1.surround)('[[', (0, combinator_1.constraint)(32
7002
7003
  /* State.reference */
7003
- , false, (0, combinator_1.syntax)(4096
7004
- /* Syntax.reference */
7005
- , 6, 1, (0, combinator_1.state)(64
7004
+ , false, (0, combinator_1.state)(64
7006
7005
  /* State.annotation */
7007
7006
  | 32
7008
7007
  /* State.reference */
7009
7008
  | 2
7010
7009
  /* State.media */
7011
- , (0, visibility_1.startLoose)((0, combinator_1.context)({
7010
+ , (0, combinator_1.syntax)(4096
7011
+ /* Syntax.reference */
7012
+ , 6, 1, (0, visibility_1.startLoose)((0, combinator_1.context)({
7012
7013
  delimiters: global_1.undefined
7013
7014
  }, (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]));
7014
7015
  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, '')]));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "securemark",
3
- "version": "0.258.7",
3
+ "version": "0.258.8",
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",
@@ -89,6 +89,7 @@ export function creation<P extends Parser<unknown>>(parser: P): P;
89
89
  export function creation<P extends Parser<unknown>>(cost: number, parser: P): P;
90
90
  export function creation(cost: number | Parser<unknown>, parser?: Parser<unknown>): Parser<unknown> {
91
91
  if (typeof cost === 'function') return creation(1, cost);
92
+ if (cost === 0) return parser!;
92
93
  assert(cost >= 0);
93
94
  return (source, context) => {
94
95
  const { resources = { clock: 1, recursion: 1 } } = context;
@@ -9,8 +9,8 @@ import { html, defrag } from 'typed-dom/dom';
9
9
  export const annotation: AnnotationParser = lazy(() => surround(
10
10
  '((',
11
11
  constraint(State.annotation, false,
12
- syntax(Syntax.annotation, 6, 1,
13
12
  state(State.annotation | State.media,
13
+ syntax(Syntax.annotation, 6, 1,
14
14
  startLoose(
15
15
  context({ delimiters: undefined },
16
16
  some(union([inline]), ')', [[/^\\?\n/, 9], [')', 2], ['))', 6]])), ')')))),
@@ -13,8 +13,8 @@ import IndexParser = ExtensionParser.IndexParser;
13
13
  export const index: IndexParser = lazy(() => validate('[#', fmap(indexee(surround(
14
14
  '[#',
15
15
  constraint(State.index, false,
16
- syntax(Syntax.index, 2, 1,
17
16
  state(State.annotation | State.reference | State.index | State.label | State.link | State.media | State.autolink,
17
+ syntax(Syntax.index, 2, 1,
18
18
  startTight(
19
19
  open(stropt(/^\|?/), trimBlankEnd(some(union([
20
20
  signature,
@@ -19,7 +19,7 @@ Object.setPrototypeOf(optspec, null);
19
19
 
20
20
  export const link: LinkParser = lazy(() => validate(['[', '{'], bind(
21
21
  constraint(State.link, false,
22
- syntax(Syntax.link, 2, 10,
22
+ creation(10,
23
23
  fmap(subsequence([
24
24
  state(State.link,
25
25
  dup(union([
@@ -28,7 +28,8 @@ export const link: LinkParser = lazy(() => validate(['[', '{'], bind(
28
28
  surround(
29
29
  '[',
30
30
  state(State.annotation | State.reference | State.index | State.label | State.media | State.autolink,
31
- some(inline, ']', [[/^\\?\n/, 9], [']', 2]])),
31
+ syntax(Syntax.link, 2, 0,
32
+ some(inline, ']', [[/^\\?\n/, 9], [']', 2]]))),
32
33
  ']',
33
34
  true),
34
35
  ]))),
@@ -11,8 +11,8 @@ import { html, defrag } from 'typed-dom/dom';
11
11
  export const reference: ReferenceParser = lazy(() => surround(
12
12
  '[[',
13
13
  constraint(State.reference, false,
14
- syntax(Syntax.reference, 6, 1,
15
14
  state(State.annotation | State.reference | State.media,
15
+ syntax(Syntax.reference, 6, 1,
16
16
  startLoose(
17
17
  context({ delimiters: undefined },
18
18
  subsequence([