securemark 0.274.1 → 0.274.3

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/.eslintrc.json CHANGED
@@ -20,8 +20,6 @@
20
20
  "maxSimpleRepeatCount": 256,
21
21
  "attackTimeout": null,
22
22
  "incubationTimeout": null,
23
- "recallTimeout": null,
24
- "seedingTimeout": null,
25
23
  "timeout": 1e6
26
24
  }
27
25
  ]
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.274.3
4
+
5
+ - Fix abbr parser.
6
+
7
+ ## 0.274.2
8
+
9
+ - Fix identifiers of notes.
10
+
3
11
  ## 0.274.1
4
12
 
5
13
  - Fix identifiers of notes.
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! securemark v0.274.1 https://github.com/falsandtru/securemark | (c) 2017, falsandtru | UNLICENSED License */
1
+ /*! securemark v0.274.3 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"));
@@ -6581,14 +6581,14 @@ const visibility_1 = __webpack_require__(7618);
6581
6581
  const array_1 = __webpack_require__(8112);
6582
6582
  const dom_1 = __webpack_require__(3252);
6583
6583
  exports.mark = (0, combinator_1.lazy)(() => (0, combinator_1.surround)((0, source_1.str)('==', '='), (0, combinator_1.constraint)(4 /* State.mark */, false, (0, combinator_1.syntax)(0 /* Syntax.none */, 1, 1, 0 /* State.none */, (0, visibility_1.startTight)((0, combinator_1.some)((0, combinator_1.union)([(0, combinator_1.some)(inline_1.inline, (0, visibility_1.blankWith)('=='), [[/^\\?\n/, 9]]), (0, combinator_1.open)((0, combinator_1.some)(inline_1.inline, '=', [[/^\\?\n/, 9]]), exports.mark)]))))), (0, source_1.str)('=='), false, ([, bs], rest, {
6584
- id
6584
+ id,
6585
+ state
6585
6586
  }) => {
6586
6587
  const el = (0, dom_1.html)('mark', (0, dom_1.defrag)(bs));
6587
- (0, dom_1.define)(el, {
6588
- id: (0, indexee_1.identity)(id, (0, indexee_1.text)(el), 'mark')
6589
- });
6590
- return [[el, (0, dom_1.html)('a', {
6591
- href: el.id ? `#${el.id}` : undefined
6588
+ return [[(0, dom_1.define)(el, {
6589
+ id: state & (256 /* State.annotation */ | 128 /* State.reference */) ? undefined : (0, indexee_1.identity)(id, (0, indexee_1.text)(el), 'mark')
6590
+ }), el.id && (0, dom_1.html)('a', {
6591
+ href: `#${el.id}`
6592
6592
  })], rest];
6593
6593
  }, ([as, bs], rest) => [(0, array_1.unshift)(as, bs), rest]));
6594
6594
 
@@ -6645,6 +6645,7 @@ const link_1 = __webpack_require__(9628);
6645
6645
  const html_1 = __webpack_require__(5994);
6646
6646
  const htmlentity_1 = __webpack_require__(1562);
6647
6647
  const source_1 = __webpack_require__(6743);
6648
+ const util_1 = __webpack_require__(9437);
6648
6649
  const url_1 = __webpack_require__(2261);
6649
6650
  const array_1 = __webpack_require__(8112);
6650
6651
  const dom_1 = __webpack_require__(3252);
@@ -6692,32 +6693,19 @@ function sanitize(target, uri, alt) {
6692
6693
  case 'http:':
6693
6694
  case 'https:':
6694
6695
  if (/\/\.\.?(?:\/|$)/.test('/' + uri.source.slice(0, uri.source.search(/[?#]|$/)))) {
6695
- (0, dom_1.define)(target, {
6696
- class: void target.classList.add('invalid'),
6697
- 'data-invalid-syntax': 'media',
6698
- 'data-invalid-type': 'argument',
6699
- 'data-invalid-message': 'Dot-segments cannot be used in media paths; use subresource paths instead'
6700
- });
6696
+ (0, util_1.markInvalid)(target, 'media', 'argument', 'Dot-segments cannot be used in media paths; use subresource paths instead');
6701
6697
  return false;
6702
6698
  }
6703
6699
  break;
6704
6700
  default:
6705
- (0, dom_1.define)(target, {
6706
- class: void target.classList.add('invalid'),
6707
- 'data-invalid-syntax': 'media',
6708
- 'data-invalid-type': 'argument',
6709
- 'data-invalid-message': 'Invalid protocol'
6710
- });
6701
+ (0, util_1.markInvalid)(target, 'media', 'argument', 'Invalid protocol');
6711
6702
  return false;
6712
6703
  }
6713
6704
  if (alt.includes('\x1B')) {
6714
6705
  (0, dom_1.define)(target, {
6715
- class: void target.classList.add('invalid'),
6716
- 'data-invalid-syntax': 'media',
6717
- 'data-invalid-type': 'content',
6718
- 'data-invalid-message': `Cannot use invalid HTML entitiy "${alt.match(/&[0-9A-Za-z]+;/)[0]}"`,
6719
6706
  alt: target.getAttribute('alt')?.replace(/\x1B/g, '')
6720
6707
  });
6708
+ (0, util_1.markInvalid)(target, 'media', 'content', `Cannot use invalid HTML entitiy "${alt.match(/&[0-9A-Za-z]+;/)[0]}"`);
6721
6709
  return false;
6722
6710
  }
6723
6711
  return true;
@@ -6739,22 +6727,31 @@ const combinator_1 = __webpack_require__(2087);
6739
6727
  const inline_1 = __webpack_require__(1160);
6740
6728
  const source_1 = __webpack_require__(6743);
6741
6729
  const visibility_1 = __webpack_require__(7618);
6742
- const util_1 = __webpack_require__(9437);
6743
6730
  const dom_1 = __webpack_require__(3252);
6744
6731
  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]));
6745
- 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, '')]));
6732
+ // Chicago-Style
6733
+ const abbr = (0, combinator_1.creation)((0, combinator_1.bind)((0, combinator_1.surround)('^', (0, combinator_1.union)([(0, source_1.str)(/^(?=[A-Z])(?:[0-9A-Za-z]'?|(?:[-.:]|\.?\??,? ?)(?!['\-.:?, ]))+/)]), /^\|?(?=]])|^\|[^\S\n]*/), ([source], rest) => [['\n', source.trimEnd()], rest.replace(visibility_1.regBlankStart, '')]));
6746
6734
  function attributes(ns) {
6747
- return typeof ns[0] === 'object' && ns[0].tagName === 'ABBR' ? {
6748
- class: 'reference',
6749
- 'data-abbr': (0, util_1.stringify)([ns.shift()]).trimEnd()
6750
- } : ns[0] === '' ? {
6751
- class: 'invalid',
6752
- 'data-invalid-syntax': 'reference',
6753
- 'data-invalid-type': 'syntax',
6754
- 'data-invalid-message': 'Invalid abbr'
6755
- } : {
6756
- class: 'reference'
6757
- };
6735
+ switch (ns[0]) {
6736
+ case '':
6737
+ return {
6738
+ class: 'invalid',
6739
+ 'data-invalid-syntax': 'reference',
6740
+ 'data-invalid-type': 'syntax',
6741
+ 'data-invalid-message': 'Invalid abbreviation'
6742
+ };
6743
+ case '\n':
6744
+ const abbr = ns[1];
6745
+ ns[0] = ns[1] = '';
6746
+ return {
6747
+ class: 'reference',
6748
+ 'data-abbr': abbr
6749
+ };
6750
+ default:
6751
+ return {
6752
+ class: 'reference'
6753
+ };
6754
+ }
6758
6755
  }
6759
6756
 
6760
6757
  /***/ }),
@@ -6924,6 +6921,7 @@ Object.defineProperty(exports, "__esModule", ({
6924
6921
  }));
6925
6922
  exports.figure = void 0;
6926
6923
  const label_1 = __webpack_require__(466);
6924
+ const util_1 = __webpack_require__(9437);
6927
6925
  const queue_1 = __webpack_require__(4934);
6928
6926
  const array_1 = __webpack_require__(8112);
6929
6927
  const dom_1 = __webpack_require__(3252);
@@ -6946,11 +6944,8 @@ function* figure(target, notes, opts = {}) {
6946
6944
  const label = tagName === 'FIGURE' ? def.getAttribute('data-label') : `$-${increment(index, def)}`;
6947
6945
  if (label.endsWith('-')) continue;
6948
6946
  if (label.endsWith('-0')) {
6947
+ (0, util_1.markInvalid)(def, 'figure', 'argument', 'Invalid base index');
6949
6948
  (0, dom_1.define)(def, {
6950
- class: void def.classList.add('invalid'),
6951
- 'data-invalid-syntax': 'figure',
6952
- 'data-invalid-type': 'argument',
6953
- 'data-invalid-message': 'Invalid base index',
6954
6949
  hidden: null
6955
6950
  });
6956
6951
  continue;
@@ -6958,32 +6953,23 @@ function* figure(target, notes, opts = {}) {
6958
6953
  if (tagName === 'FIGURE' && label.endsWith('.0')) {
6959
6954
  // $-x.x.0 is disabled.
6960
6955
  if (label.lastIndexOf('.', label.length - 3) !== -1) {
6956
+ (0, util_1.markInvalid)(def, 'figure', 'argument', 'Base index must be $-x.0 format');
6961
6957
  (0, dom_1.define)(def, {
6962
- class: void def.classList.add('invalid'),
6963
- 'data-invalid-syntax': 'figure',
6964
- 'data-invalid-type': 'argument',
6965
- 'data-invalid-message': 'Base index must be $-x.0 format',
6966
6958
  hidden: null
6967
6959
  });
6968
6960
  continue;
6969
6961
  }
6970
6962
  // $-x.0 after h1-h6.
6971
6963
  if (!/^H[1-6]$/.test(def.previousElementSibling?.tagName ?? '')) {
6964
+ (0, util_1.markInvalid)(def, 'figure', 'position', messages.declaration);
6972
6965
  (0, dom_1.define)(def, {
6973
- class: void def.classList.add('invalid'),
6974
- 'data-invalid-syntax': 'figure',
6975
- 'data-invalid-type': 'position',
6976
- 'data-invalid-message': messages.declaration,
6977
6966
  hidden: null
6978
6967
  });
6979
6968
  continue;
6980
6969
  } else if (def.getAttribute('data-invalid-message') === messages.declaration) {
6970
+ (0, util_1.unmarkInvalid)(def);
6981
6971
  (0, dom_1.define)(def, {
6982
- class: void def.classList.remove('invalid'),
6983
- 'data-invalid-syntax': null,
6984
- 'data-invalid-type': null,
6985
- 'data-invalid-message': null,
6986
- hidden: ''
6972
+ hidden: null
6987
6973
  });
6988
6974
  }
6989
6975
  }
@@ -7008,31 +6994,18 @@ function* figure(target, notes, opts = {}) {
7008
6994
  if (labels.has(label)) {
7009
6995
  if (def.classList.contains('invalid')) continue;
7010
6996
  (0, dom_1.define)(def, {
7011
- id: null,
7012
- class: void def.classList.add('invalid'),
7013
- 'data-invalid-syntax': 'figure',
7014
- 'data-invalid-type': 'argument',
7015
- 'data-invalid-message': messages.duplicate
6997
+ id: null
7016
6998
  });
6999
+ (0, util_1.markInvalid)(def, 'figure', 'argument', messages.duplicate);
7017
7000
  continue;
7018
7001
  } else if (def.getAttribute('data-invalid-message') === messages.duplicate) {
7019
- (0, dom_1.define)(def, {
7020
- class: void def.classList.remove('invalid'),
7021
- 'data-invalid-syntax': null,
7022
- 'data-invalid-type': null,
7023
- 'data-invalid-message': null
7024
- });
7002
+ (0, util_1.unmarkInvalid)(def);
7025
7003
  }
7026
7004
  labels.add(label);
7027
7005
  opts.id !== '' && def.setAttribute('id', `label:${opts.id ? `${opts.id}:` : ''}${label}`);
7028
7006
  for (const ref of refs.take(label, Infinity)) {
7029
7007
  if (ref.getAttribute('data-invalid-message') === messages.reference) {
7030
- (0, dom_1.define)(ref, {
7031
- class: void ref.classList.remove('invalid'),
7032
- 'data-invalid-syntax': null,
7033
- 'data-invalid-type': null,
7034
- 'data-invalid-message': null
7035
- });
7008
+ (0, util_1.unmarkInvalid)(ref);
7036
7009
  }
7037
7010
  if (ref.hash.slice(1) === def.id && ref.innerText === figindex) continue;
7038
7011
  yield (0, dom_1.define)(ref, opts.id !== '' ? {
@@ -7044,12 +7017,7 @@ function* figure(target, notes, opts = {}) {
7044
7017
  }
7045
7018
  for (const [, ref] of refs) {
7046
7019
  if (opts.id !== '' && !ref.classList.contains('invalid')) {
7047
- (0, dom_1.define)(ref, {
7048
- class: void ref.classList.add('invalid'),
7049
- 'data-invalid-syntax': 'label',
7050
- 'data-invalid-type': 'reference',
7051
- 'data-invalid-message': messages.reference
7052
- });
7020
+ (0, util_1.markInvalid)(ref, 'label', 'reference', messages.reference);
7053
7021
  }
7054
7022
  yield ref;
7055
7023
  }
@@ -7091,6 +7059,7 @@ Object.defineProperty(exports, "__esModule", ({
7091
7059
  }));
7092
7060
  exports.reference = exports.annotation = exports.note = void 0;
7093
7061
  const indexee_1 = __webpack_require__(1269);
7062
+ const util_1 = __webpack_require__(9437);
7094
7063
  const dom_1 = __webpack_require__(3252);
7095
7064
  function* note(target, notes, opts = {}, bottom = null) {
7096
7065
  for (let es = target.querySelectorAll(`.annotations`), len = es.length, i = 0; i < len; ++i) {
@@ -7109,101 +7078,85 @@ function build(syntax, marker, splitter = '') {
7109
7078
  // 構文ごとに各1回の処理では不可能
7110
7079
  return function* (target, note, opts = {}, bottom = null) {
7111
7080
  const defs = new Map();
7112
- const splitters = [];
7113
- for (let es = target.querySelectorAll(splitter || '_'), len = es.length, i = 0; i < len; ++i) {
7114
- if (i % 100 === 0) yield;
7115
- const el = es[i];
7116
- el.parentNode === target && splitters.push(el);
7117
- }
7118
7081
  const refs = target.querySelectorAll(`sup.${syntax}:not(.disabled)`);
7119
7082
  const titles = new Map();
7120
7083
  const defIndexes = new Map();
7121
7084
  const refSubindexes = new Map();
7122
- const defSubindexes = new Map();
7123
- let refIndex = 0;
7085
+ const defSubindexes = splitter && refs.length > 0 ? new Map() : undefined;
7086
+ const splitters = splitter && refs.length > 0 ? target.querySelectorAll(splitter) : [];
7087
+ let iSplitters = 0;
7124
7088
  let total = 0;
7125
- let style;
7089
+ let format;
7090
+ let refIndex = 0;
7126
7091
  for (let len = refs.length, i = 0; i < len; ++i) {
7127
7092
  const ref = refs[i];
7128
- if (ref.closest('[hidden]')) {
7093
+ if (ref.closest('sup > [hidden]')) {
7129
7094
  yield;
7130
7095
  continue;
7131
7096
  }
7132
- while (splitters.length > 0 && splitters[0].compareDocumentPosition(ref) & Node.DOCUMENT_POSITION_FOLLOWING) {
7097
+ if (splitter) for (let el; (el = splitters[iSplitters])?.compareDocumentPosition(ref) & Node.DOCUMENT_POSITION_FOLLOWING; ++iSplitters) {
7098
+ if (el.parentNode !== target) continue;
7133
7099
  if (defs.size > 0) {
7134
7100
  total += defs.size;
7135
7101
  yield* proc(defs, target.insertBefore((0, dom_1.html)('ol', {
7136
7102
  class: `${syntax}s`
7137
- }), splitters[0]));
7138
- } else if (splitters.length % 100 === 0) {
7103
+ }), el));
7104
+ } else if (~iSplitters % 128 === 0) {
7139
7105
  yield;
7140
7106
  }
7141
- splitters.shift();
7142
7107
  }
7143
7108
  const abbr = ref.getAttribute('data-abbr') || undefined;
7144
- const identifier = abbr || (0, indexee_1.identity)(undefined, (0, indexee_1.text)(ref.firstElementChild), 'mark')?.slice(6) || '';
7109
+ const identifier = (0, indexee_1.identity)(undefined, abbr ? abbr.match(/^(?:\S+ )+?(?:(?:January|February|March|April|May|June|August|September|October|November|December) \d{1,2}(?:-\d{0,2})?, \d{1,4}(?:-\d{0,4})?[a-z]?|n\.d\.)(?=,|$)/)?.[0] ?? abbr.match(/^[^,\s]+(?:,? [^,\s]+)*?(?: \d{1,4}(?:-\d{0,4})?[a-z]?(?=,|$)|(?=,(?: [a-z]+\.?)? [0-9]))/)?.[0] ?? abbr : (0, indexee_1.text)(ref.firstElementChild), 'mark')?.slice(6) || '';
7145
7110
  const refSubindex = refSubindexes.get(identifier) + 1 || 1;
7146
7111
  refSubindexes.set(identifier, refSubindex);
7147
7112
  const refId = opts.id !== '' ? `${syntax}:${opts.id ?? ''}:ref:${identifier}:${refSubindex}` : undefined;
7148
7113
  const initial = splitter ? !defs.has(identifier) : refSubindex === 1;
7149
- const defSubindex = defSubindexes.get(identifier) + 1 || 1;
7150
- defSubindexes.set(identifier, defSubindex);
7114
+ const defSubindex = defSubindexes?.get(identifier) + +initial || 1;
7115
+ initial && defSubindexes?.set(identifier, defSubindex);
7116
+ const defId = opts.id !== '' ? `${syntax}:${opts.id ?? ''}:def:${identifier}${splitter && `:${defSubindex}`}` : undefined;
7151
7117
  const def = initial ? (0, dom_1.html)('li', {
7152
- id: opts.id !== '' ? `${syntax}:${opts.id ?? ''}:def:${identifier}:${defSubindex}` : undefined,
7153
- 'data-marker': !note ? marker(total + defs.size + 1, abbr) : undefined
7118
+ id: defId,
7119
+ 'data-marker': note ? undefined : marker(total + defs.size + 1, abbr)
7154
7120
  }, [(0, dom_1.define)(ref.firstElementChild.cloneNode(true), {
7155
7121
  hidden: null
7156
7122
  }), (0, dom_1.html)('sup')]) : defs.get(identifier);
7157
7123
  initial && defs.set(identifier, def);
7158
7124
  const defIndex = initial ? total + defs.size : defIndexes.get(def);
7159
7125
  initial && defIndexes.set(def, defIndex);
7160
- const defId = def.id || undefined;
7161
7126
  const title = initial ? (0, indexee_1.text)(ref.firstElementChild) : titles.get(identifier);
7162
7127
  initial && titles.set(identifier, title);
7163
- style ??= abbr ? 'abbr' : 'count';
7164
- if (style === 'count' ? abbr : !abbr) {
7165
- (0, dom_1.define)(ref, {
7166
- class: void ref.classList.add('invalid'),
7167
- 'data-invalid-syntax': syntax,
7168
- 'data-invalid-type': 'style',
7169
- 'data-invalid-message': `${syntax[0].toUpperCase() + syntax.slice(1)} style must be consistent`
7170
- });
7171
- } else if (ref.getAttribute('data-invalid-type') === 'style') {
7172
- (0, dom_1.define)(ref, {
7173
- class: void ref.classList.remove('invalid'),
7174
- 'data-invalid-syntax': null,
7175
- 'data-invalid-type': null,
7176
- 'data-invalid-message': null
7177
- });
7178
- }
7179
- if (!ref.firstElementChild.hasAttribute('hidden')) {
7180
- ref.firstElementChild.setAttribute('hidden', '');
7181
- } else {
7182
- ref.lastChild?.remove();
7183
- }
7128
+ ref.firstElementChild.hasAttribute('hidden') ? ref.lastElementChild.remove() : ref.firstElementChild.setAttribute('hidden', '');
7184
7129
  (0, dom_1.define)(ref, {
7185
7130
  id: refId,
7186
7131
  class: opts.id !== '' ? undefined : void ref.classList.add('disabled'),
7187
- title,
7188
- ...(!title && {
7189
- class: void ref.classList.add('invalid'),
7190
- 'data-invalid-syntax': syntax,
7191
- 'data-invalid-type': 'content',
7192
- 'data-invalid-message': 'Missing the content'
7193
- })
7132
+ title
7194
7133
  });
7134
+ switch (ref.getAttribute('data-invalid-syntax')) {
7135
+ case 'format':
7136
+ case 'content':
7137
+ (0, util_1.unmarkInvalid)(ref);
7138
+ }
7139
+ format ??= abbr ? 'abbr' : 'number';
7140
+ if (!ref.classList.contains('invalid')) switch (true) {
7141
+ case format === 'number' ? !!abbr : !abbr:
7142
+ (0, util_1.markInvalid)(ref, syntax, 'format', 'Notation format must be consistent with numbers or abbreviations');
7143
+ break;
7144
+ case !title:
7145
+ (0, util_1.markInvalid)(ref, syntax, 'content', 'Missing the content');
7146
+ break;
7147
+ }
7195
7148
  yield ref.appendChild((0, dom_1.html)('a', {
7196
7149
  href: refId && defId && `#${defId}`
7197
7150
  }, marker(defIndex, abbr)));
7198
- def.lastChild.appendChild((0, dom_1.html)('a', {
7151
+ def.lastElementChild.appendChild((0, dom_1.html)('a', {
7199
7152
  href: refId && `#${refId}`,
7200
7153
  title: abbr && (0, indexee_1.text)((0, dom_1.frag)(ref.firstElementChild.cloneNode(true).childNodes)).trim() || undefined
7201
7154
  }, `^${++refIndex}`));
7202
7155
  }
7203
- if (defs.size > 0 || note) {
7156
+ if (note || defs.size > 0) {
7204
7157
  yield* proc(defs, note ?? target.insertBefore((0, dom_1.html)('ol', {
7205
7158
  class: `${syntax}s`
7206
- }), splitters[0] ?? bottom));
7159
+ }), splitters[iSplitters] ?? bottom));
7207
7160
  }
7208
7161
  return;
7209
7162
  };
@@ -7586,7 +7539,7 @@ exports.unescsource = (0, combinator_1.creation)(1, false, ({
7586
7539
  /***/ }),
7587
7540
 
7588
7541
  /***/ 9437:
7589
- /***/ ((__unused_webpack_module, exports) => {
7542
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
7590
7543
 
7591
7544
  "use strict";
7592
7545
 
@@ -7594,7 +7547,26 @@ exports.unescsource = (0, combinator_1.creation)(1, false, ({
7594
7547
  Object.defineProperty(exports, "__esModule", ({
7595
7548
  value: true
7596
7549
  }));
7597
- exports.stringify = void 0;
7550
+ exports.stringify = exports.unmarkInvalid = exports.markInvalid = void 0;
7551
+ const dom_1 = __webpack_require__(3252);
7552
+ function markInvalid(el, syntax, type, message) {
7553
+ return (0, dom_1.define)(el, {
7554
+ class: void el.classList.add('invalid'),
7555
+ 'data-invalid-syntax': syntax,
7556
+ 'data-invalid-type': type,
7557
+ 'data-invalid-message': message
7558
+ });
7559
+ }
7560
+ exports.markInvalid = markInvalid;
7561
+ function unmarkInvalid(el) {
7562
+ return (0, dom_1.define)(el, {
7563
+ class: void el.classList.remove('invalid'),
7564
+ 'data-invalid-syntax': null,
7565
+ 'data-invalid-type': null,
7566
+ 'data-invalid-message': null
7567
+ });
7568
+ }
7569
+ exports.unmarkInvalid = unmarkInvalid;
7598
7570
  function stringify(nodes) {
7599
7571
  let acc = '';
7600
7572
  for (let i = 0; i < nodes.length; ++i) {
package/markdown.d.ts CHANGED
@@ -658,8 +658,8 @@ export namespace MarkdownParser {
658
658
  }
659
659
  export interface ReferenceParser extends
660
660
  // [[abc]]
661
- // [[^abbr]]
662
- // [[^abbr| abc]]
661
+ // [[^Abbr]]
662
+ // [[^Abbr| abc]]
663
663
  Inline<'reference'>,
664
664
  Parser<HTMLElement, Context, [
665
665
  ReferenceParser.AbbrParser,
@@ -669,11 +669,10 @@ export namespace MarkdownParser {
669
669
  }
670
670
  export namespace ReferenceParser {
671
671
  export interface AbbrParser extends
672
- // ^Xyz2020
673
- // ^X, 2020, p1-2
674
- // ^X. Y., Z et al., 2020, p1-2
672
+ // ^X 2020, 1-2
673
+ // ^X. Y., and Z et al. 2020, 1-2
675
674
  Inline<'reference/abbr'>,
676
- Parser<HTMLElement, Context, [
675
+ Parser<string, Context, [
677
676
  SourceParser.StrParser,
678
677
  ]> {
679
678
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "securemark",
3
- "version": "0.274.1",
3
+ "version": "0.274.3",
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",
@@ -194,34 +194,34 @@ describe('Unit: parser/api/bind', () => {
194
194
  html('p', [
195
195
  html('sup', { class: "reference", id: "reference::ref:1:1", title: "1" }, [
196
196
  html('span', { hidden: '' }, '1'),
197
- html('a', { href: "#reference::def:1:1" }, '[1]'),
197
+ html('a', { href: "#reference::def:1" }, '[1]'),
198
198
  ]),
199
199
  ]).outerHTML,
200
200
  html('p', [
201
201
  html('sup', { class: "reference", id: "reference::ref:2:1", title: "2" }, [
202
202
  html('span', { hidden: '' }, '2'),
203
- html('a', { href: "#reference::def:2:1" }, '[2]'),
203
+ html('a', { href: "#reference::def:2" }, '[2]'),
204
204
  ]),
205
205
  ]).outerHTML,
206
206
  html('p', [
207
207
  html('sup', { class: "reference", id: "reference::ref:3:1", title: "3" }, [
208
208
  html('span', { hidden: '' }, '3'),
209
- html('a', { href: "#reference::def:3:1" }, '[3]'),
209
+ html('a', { href: "#reference::def:3" }, '[3]'),
210
210
  ]),
211
211
  ]).outerHTML,
212
212
  ]);
213
213
  assert.deepStrictEqual(
214
214
  cfgs.notes.references?.outerHTML,
215
215
  html('ol', [
216
- html('li', { id: 'reference::def:1:1' }, [
216
+ html('li', { id: 'reference::def:1' }, [
217
217
  html('span', '1'),
218
218
  html('sup', [html('a', { href: '#reference::ref:1:1' }, '^1')]),
219
219
  ]),
220
- html('li', { id: 'reference::def:2:1' }, [
220
+ html('li', { id: 'reference::def:2' }, [
221
221
  html('span', '2'),
222
222
  html('sup', [html('a', { href: '#reference::ref:2:1' }, '^2')]),
223
223
  ]),
224
- html('li', { id: 'reference::def:3:1' }, [
224
+ html('li', { id: 'reference::def:3' }, [
225
225
  html('span', '3'),
226
226
  html('sup', [html('a', { href: '#reference::ref:3:1' }, '^3')]),
227
227
  ]),
@@ -204,15 +204,80 @@ describe('Unit: parser/api/parse', () => {
204
204
  it('note', () => {
205
205
  const notes = { references: html('ol') };
206
206
  assert.deepStrictEqual(
207
- [...parse('$-a\n$$\n$$\n\n(($-a[[^b]]))[[^b|$-a]]', { notes }).children].map(el => el.outerHTML),
207
+ [...parse('$-a\n$$\n$$\n\n(($-a[[^B]]))[[^B|$-a]]', { notes }).children].map(el => el.outerHTML),
208
208
  [
209
209
  '<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>',
210
- '<p><sup class="annotation" id="annotation::ref:(1):1" title="(1)"><span hidden=""><a class="label" data-label="$-a" href="#label:$-a">(1)</a><sup class="reference" data-abbr="b"><span></span></sup></span><a href="#annotation::def:(1):1">*1</a></sup><sup class="reference" data-abbr="b" id="reference::ref:b:1" title="(1)"><span hidden=""><a class="label" data-label="$-a" href="#label:$-a">(1)</a></span><a href="#reference::def:b:1">[b]</a></sup></p>',
211
- '<ol class="annotations"><li id="annotation::def:(1):1" data-marker="*1"><span><a class="label" data-label="$-a" href="#label:$-a">(1)</a><sup class="reference" data-abbr="b" id="reference::ref:b:2" title="(1)"><span hidden=""></span><a href="#reference::def:b:1">[b]</a></sup></span><sup><a href="#annotation::ref:(1):1">^1</a></sup></li></ol>',
210
+ '<p><sup class="annotation" id="annotation::ref:(1):1" title="(1)"><span hidden=""><a class="label" data-label="$-a" href="#label:$-a">(1)</a><sup class="reference" data-abbr="B"><span></span></sup></span><a href="#annotation::def:(1):1">*1</a></sup><sup class="reference" data-abbr="B" id="reference::ref:B:1" title="(1)"><span hidden=""><a class="label" data-label="$-a" href="#label:$-a">(1)</a></span><a href="#reference::def:B">[B]</a></sup></p>',
211
+ '<ol class="annotations"><li id="annotation::def:(1):1" data-marker="*1"><span><a class="label" data-label="$-a" href="#label:$-a">(1)</a><sup class="reference" data-abbr="B" id="reference::ref:B:2" title="(1)"><span hidden=""></span><a href="#reference::def:B">[B]</a></sup></span><sup><a href="#annotation::ref:(1):1">^1</a></sup></li></ol>',
212
212
  ]);
213
213
  assert.deepStrictEqual(
214
214
  notes.references.outerHTML,
215
- '<ol><li id="reference::def:b:1"><span><a class="label" data-label="$-a" href="#label:$-a">(1)</a></span><sup><a href="#reference::ref:b:1" title="(1)">^1</a><a href="#reference::ref:b:2">^2</a></sup></li></ol>');
215
+ '<ol><li id="reference::def:B"><span><a class="label" data-label="$-a" href="#label:$-a">(1)</a></span><sup><a href="#reference::ref:B:1" title="(1)">^1</a><a href="#reference::ref:B:2">^2</a></sup></li></ol>');
216
+ assert.deepStrictEqual(
217
+ [...parse([
218
+ '[[^A 1|b]]',
219
+ '[[^A 1,|b]]',
220
+ '[[^A 1, |b]]',
221
+ '[[^Xyz 2020|b]]',
222
+ '[[^Xyz 2020, 1|b]]',
223
+ '[[^Xyz 2020, 1, 2|b]]',
224
+ '[[^Xyz 2020, 1, fig. 1.1|b]]',
225
+ '[[^Xyz 2020, 1, fig. 1.1-2.1b|b]]',
226
+ '[[^Xyz 2020, 1, fig. 1.1a-b|b]]',
227
+ '[[^Xyz 2020, 1-2|b]]',
228
+ '[[^Xyz 2020, 1:1-2|b]]',
229
+ '[[^Xyz 2020, 1n|b]]',
230
+ '[[^Xyz 2020, 1n1|b]]',
231
+ '[[^Xyz 2020, 1nn1-2|b]]',
232
+ '[[^Xyz 2020, i|b]]',
233
+ '[[^Xyz 2020, capter 1|b]]',
234
+ '[[^Xyz 2020, cap. 1|b]]',
235
+ '[[^Xyz 2020a|b]]',
236
+ '[[^Xyz 2020a, 1|b]]',
237
+ '[[^Xyz 2020-2021a|b]]',
238
+ '[[^Xyz 2020-2021a, 1|b]]',
239
+ '[[^Xyz, April 1, 2020|b]]',
240
+ '[[^Xyz, April 1, 2020, 1|b]]',
241
+ '[[^Xyz n.d.|b]]',
242
+ '[[^Xyz n.d., 1|b]]',
243
+ '[[^X. Y., and Z et al. 2020, 1-2|b]]',
244
+ '[[^A title 2020|b]]',
245
+ '[[^A title 2020, 1|b]]',
246
+ '[[^Constitution, art. 2|b]]',
247
+ '[[^Constitution, art. 2, sec. 1|b]]',
248
+ ].join('\n\n'), { notes }).children].map(el => el.outerHTML),
249
+ [
250
+ '<p><sup class="reference" data-abbr="A 1" id="reference::ref:A_1:1" title="b"><span hidden="">b</span><a href="#reference::def:A_1">[A 1]</a></sup></p>',
251
+ '<p><sup class="reference" data-abbr="A 1," id="reference::ref:A_1:2" title="b"><span hidden="">b</span><a href="#reference::def:A_1">[A 1,]</a></sup></p>',
252
+ '<p><sup class="reference" data-abbr="A 1," id="reference::ref:A_1:3" title="b"><span hidden="">b</span><a href="#reference::def:A_1">[A 1,]</a></sup></p>',
253
+ '<p><sup class="reference" data-abbr="Xyz 2020" id="reference::ref:Xyz_2020:1" title="b"><span hidden="">b</span><a href="#reference::def:Xyz_2020">[Xyz 2020]</a></sup></p>',
254
+ '<p><sup class="reference" data-abbr="Xyz 2020, 1" id="reference::ref:Xyz_2020:2" title="b"><span hidden="">b</span><a href="#reference::def:Xyz_2020">[Xyz 2020, 1]</a></sup></p>',
255
+ '<p><sup class="reference" data-abbr="Xyz 2020, 1, 2" id="reference::ref:Xyz_2020:3" title="b"><span hidden="">b</span><a href="#reference::def:Xyz_2020">[Xyz 2020, 1, 2]</a></sup></p>',
256
+ '<p><sup class="reference" data-abbr="Xyz 2020, 1, fig. 1.1" id="reference::ref:Xyz_2020:4" title="b"><span hidden="">b</span><a href="#reference::def:Xyz_2020">[Xyz 2020, 1, fig. 1.1]</a></sup></p>',
257
+ '<p><sup class="reference" data-abbr="Xyz 2020, 1, fig. 1.1-2.1b" id="reference::ref:Xyz_2020:5" title="b"><span hidden="">b</span><a href="#reference::def:Xyz_2020">[Xyz 2020, 1, fig. 1.1-2.1b]</a></sup></p>',
258
+ '<p><sup class="reference" data-abbr="Xyz 2020, 1, fig. 1.1a-b" id="reference::ref:Xyz_2020:6" title="b"><span hidden="">b</span><a href="#reference::def:Xyz_2020">[Xyz 2020, 1, fig. 1.1a-b]</a></sup></p>',
259
+ '<p><sup class="reference" data-abbr="Xyz 2020, 1-2" id="reference::ref:Xyz_2020:7" title="b"><span hidden="">b</span><a href="#reference::def:Xyz_2020">[Xyz 2020, 1-2]</a></sup></p>',
260
+ '<p><sup class="reference" data-abbr="Xyz 2020, 1:1-2" id="reference::ref:Xyz_2020:8" title="b"><span hidden="">b</span><a href="#reference::def:Xyz_2020">[Xyz 2020, 1:1-2]</a></sup></p>',
261
+ '<p><sup class="reference" data-abbr="Xyz 2020, 1n" id="reference::ref:Xyz_2020:9" title="b"><span hidden="">b</span><a href="#reference::def:Xyz_2020">[Xyz 2020, 1n]</a></sup></p>',
262
+ '<p><sup class="reference" data-abbr="Xyz 2020, 1n1" id="reference::ref:Xyz_2020:10" title="b"><span hidden="">b</span><a href="#reference::def:Xyz_2020">[Xyz 2020, 1n1]</a></sup></p>',
263
+ '<p><sup class="reference" data-abbr="Xyz 2020, 1nn1-2" id="reference::ref:Xyz_2020:11" title="b"><span hidden="">b</span><a href="#reference::def:Xyz_2020">[Xyz 2020, 1nn1-2]</a></sup></p>',
264
+ '<p><sup class="reference" data-abbr="Xyz 2020, i" id="reference::ref:Xyz_2020:12" title="b"><span hidden="">b</span><a href="#reference::def:Xyz_2020">[Xyz 2020, i]</a></sup></p>',
265
+ '<p><sup class="reference" data-abbr="Xyz 2020, capter 1" id="reference::ref:Xyz_2020:13" title="b"><span hidden="">b</span><a href="#reference::def:Xyz_2020">[Xyz 2020, capter 1]</a></sup></p>',
266
+ '<p><sup class="reference" data-abbr="Xyz 2020, cap. 1" id="reference::ref:Xyz_2020:14" title="b"><span hidden="">b</span><a href="#reference::def:Xyz_2020">[Xyz 2020, cap. 1]</a></sup></p>',
267
+ '<p><sup class="reference" data-abbr="Xyz 2020a" id="reference::ref:Xyz_2020a:1" title="b"><span hidden="">b</span><a href="#reference::def:Xyz_2020a">[Xyz 2020a]</a></sup></p>',
268
+ '<p><sup class="reference" data-abbr="Xyz 2020a, 1" id="reference::ref:Xyz_2020a:2" title="b"><span hidden="">b</span><a href="#reference::def:Xyz_2020a">[Xyz 2020a, 1]</a></sup></p>',
269
+ '<p><sup class="reference" data-abbr="Xyz 2020-2021a" id="reference::ref:Xyz_2020-2021a:1" title="b"><span hidden="">b</span><a href="#reference::def:Xyz_2020-2021a">[Xyz 2020-2021a]</a></sup></p>',
270
+ '<p><sup class="reference" data-abbr="Xyz 2020-2021a, 1" id="reference::ref:Xyz_2020-2021a:2" title="b"><span hidden="">b</span><a href="#reference::def:Xyz_2020-2021a">[Xyz 2020-2021a, 1]</a></sup></p>',
271
+ '<p><sup class="reference" data-abbr="Xyz, April 1, 2020" id="reference::ref:Xyz,_April_1,_2020:1" title="b"><span hidden="">b</span><a href="#reference::def:Xyz,_April_1,_2020">[Xyz, April 1, 2020]</a></sup></p>',
272
+ '<p><sup class="reference" data-abbr="Xyz, April 1, 2020, 1" id="reference::ref:Xyz,_April_1,_2020:2" title="b"><span hidden="">b</span><a href="#reference::def:Xyz,_April_1,_2020">[Xyz, April 1, 2020, 1]</a></sup></p>',
273
+ '<p><sup class="reference" data-abbr="Xyz n.d." id="reference::ref:Xyz_n.d.:1" title="b"><span hidden="">b</span><a href="#reference::def:Xyz_n.d.">[Xyz n.d.]</a></sup></p>',
274
+ '<p><sup class="reference" data-abbr="Xyz n.d., 1" id="reference::ref:Xyz_n.d.:2" title="b"><span hidden="">b</span><a href="#reference::def:Xyz_n.d.">[Xyz n.d., 1]</a></sup></p>',
275
+ '<p><sup class="reference" data-abbr="X. Y., and Z et al. 2020, 1-2" id="reference::ref:X._Y.,_and_Z_et_al._2020:1" title="b"><span hidden="">b</span><a href="#reference::def:X._Y.,_and_Z_et_al._2020">[X. Y., and Z et al. 2020, 1-2]</a></sup></p>',
276
+ '<p><sup class="reference" data-abbr="A title 2020" id="reference::ref:A_title_2020:1" title="b"><span hidden="">b</span><a href="#reference::def:A_title_2020">[A title 2020]</a></sup></p>',
277
+ '<p><sup class="reference" data-abbr="A title 2020, 1" id="reference::ref:A_title_2020:2" title="b"><span hidden="">b</span><a href="#reference::def:A_title_2020">[A title 2020, 1]</a></sup></p>',
278
+ '<p><sup class="reference" data-abbr="Constitution, art. 2" id="reference::ref:Constitution:1" title="b"><span hidden="">b</span><a href="#reference::def:Constitution">[Constitution, art. 2]</a></sup></p>',
279
+ '<p><sup class="reference" data-abbr="Constitution, art. 2, sec. 1" id="reference::ref:Constitution:2" title="b"><span hidden="">b</span><a href="#reference::def:Constitution">[Constitution, art. 2, sec. 1]</a></sup></p>',
280
+ ]);
216
281
  });
217
282
 
218
283
  it('normalize', () => {
@@ -17,9 +17,15 @@ export const mark: MarkParser = lazy(() => surround(
17
17
  open(some(inline, '=', [[/^\\?\n/, 9]]), mark),
18
18
  ]))))),
19
19
  str('=='), false,
20
- ([, bs], rest, { id }) => {
20
+ ([, bs], rest, { id, state }) => {
21
21
  const el = html('mark', defrag(bs));
22
- define(el, { id: identity(id, text(el), 'mark') });
23
- return [[el, html('a', { href: el.id ? `#${el.id}` : undefined })], rest];
22
+ return [[
23
+ define(el, {
24
+ id: state! & (State.annotation | State.reference)
25
+ ? undefined
26
+ : identity(id, text(el), 'mark'),
27
+ }),
28
+ el.id && html('a', { href: `#${el.id}` }),
29
+ ], rest];
24
30
  },
25
31
  ([as, bs], rest) => [unshift(as, bs), rest]));