securemark 0.238.0 → 0.240.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,17 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.240.1
4
+
5
+ - Refactoring.
6
+
7
+ ## 0.240.0
8
+
9
+ - Extend reference syntax not to require leading whitespace after abbr syntax.
10
+
11
+ ## 0.239.0
12
+
13
+ - Extend indexer syntax to make its own index optional.
14
+
3
15
  ## 0.238.0
4
16
 
5
17
  - Revert signature syntax not to require leading whitespace.
@@ -1,4 +1,4 @@
1
- /*! securemark v0.238.0 https://github.com/falsandtru/securemark | (c) 2017, falsandtru | UNLICENSED */
1
+ /*! securemark v0.240.1 https://github.com/falsandtru/securemark | (c) 2017, falsandtru | UNLICENSED */
2
2
  require = function () {
3
3
  function r(e, n, t) {
4
4
  function o(i, f) {
@@ -4037,21 +4037,10 @@ require = function () {
4037
4037
  const union_1 = _dereq_('./union');
4038
4038
  const inits_1 = _dereq_('./inits');
4039
4039
  function subsequence(parsers) {
4040
- switch (parsers.length) {
4041
- case 0:
4042
- case 1:
4043
- return (0, union_1.union)(parsers);
4044
- case 2:
4045
- return (0, union_1.union)([
4046
- (0, inits_1.inits)(parsers),
4047
- parsers[1]
4048
- ]);
4049
- default:
4050
- return subsequence([
4051
- parsers[0],
4052
- subsequence(parsers.slice(1))
4053
- ]);
4054
- }
4040
+ return (0, union_1.union)(parsers.map((_, i) => i + 1 < parsers.length ? (0, inits_1.inits)([
4041
+ parsers[i],
4042
+ subsequence(parsers.slice(i + 1))
4043
+ ]) : parsers[i]));
4055
4044
  }
4056
4045
  exports.subsequence = subsequence;
4057
4046
  },
@@ -4095,7 +4084,7 @@ require = function () {
4095
4084
  'return (source, context) =>',
4096
4085
  '0',
4097
4086
  ...parsers.map((_, i) => `|| parsers[${ i }](source, context)`)
4098
- ].join(''))(parsers);
4087
+ ].join('\n'))(parsers);
4099
4088
  }
4100
4089
  }
4101
4090
  exports.union = union;
@@ -4426,13 +4415,13 @@ require = function () {
4426
4415
  function headers(source) {
4427
4416
  var _a;
4428
4417
  const [el] = parse(source);
4429
- return (_a = el === null || el === void 0 ? void 0 : el.textContent.trimEnd().slice(el.firstChild.textContent.length).split('\n')) !== null && _a !== void 0 ? _a : [];
4418
+ return (_a = el === null || el === void 0 ? void 0 : el.textContent.trimEnd().slice(el.firstChild.firstChild.textContent.length).split('\n')) !== null && _a !== void 0 ? _a : [];
4430
4419
  }
4431
4420
  exports.headers = headers;
4432
4421
  function parse(source) {
4433
4422
  const result = (0, header_1.header)(source, {});
4434
4423
  const [el] = (0, parser_1.eval)(result, []);
4435
- return el instanceof HTMLDetailsElement ? [
4424
+ return (el === null || el === void 0 ? void 0 : el.tagName) === 'ASIDE' ? [
4436
4425
  el,
4437
4426
  (0, parser_1.exec)(result)
4438
4427
  ] : [];
@@ -5159,8 +5148,8 @@ require = function () {
5159
5148
  (0, combinator_1.block)((0, locale_1.localize)((0, combinator_1.context)({ syntax: { inline: { media: false } } }, (0, combinator_1.trim)((0, util_1.visualize)((0, combinator_1.some)(inline_1.inline))))))
5160
5149
  ])
5161
5150
  ])), ([label, param, content, ...caption]) => [(0, typed_dom_1.html)('figure', attributes(label.getAttribute('data-label'), param, content, caption), [
5162
- (0, typed_dom_1.html)('div', [content]),
5163
- (0, typed_dom_1.html)('figcaption', (0, array_1.unshift)([(0, typed_dom_1.html)('span', { class: 'figindex' })], (0, typed_dom_1.defrag)(caption)))
5151
+ (0, typed_dom_1.html)('figcaption', (0, array_1.unshift)([(0, typed_dom_1.html)('span', { class: 'figindex' })], (0, typed_dom_1.defrag)(caption))),
5152
+ (0, typed_dom_1.html)('div', [content])
5164
5153
  ])])));
5165
5154
  function attributes(label, param, content, caption) {
5166
5155
  const group = label.split('-', 1)[0];
@@ -5168,6 +5157,7 @@ require = function () {
5168
5157
  switch (type || content.tagName) {
5169
5158
  case 'UL':
5170
5159
  case 'OL':
5160
+ case 'checklist':
5171
5161
  type = 'list';
5172
5162
  break;
5173
5163
  case 'TABLE':
@@ -5193,15 +5183,39 @@ require = function () {
5193
5183
  } || param.trimStart() !== '' && {
5194
5184
  'data-invalid-type': 'argument',
5195
5185
  'data-invalid-message': 'Invalid argument'
5196
- } || group === '$' && (!content.classList.contains('math') || caption.length > 0) && {
5197
- 'data-invalid-type': 'content',
5198
- 'data-invalid-message': 'A figure labeled to define a formula number can contain only a math formula and no caption'
5186
+ } || group === '$' && (type !== 'math' || caption.length > 0) && {
5187
+ 'data-invalid-type': 'label',
5188
+ 'data-invalid-message': '"$" label group must be used to math formulas with no caption'
5189
+ } || type === 'media' && {} || [
5190
+ 'fig',
5191
+ 'figure'
5192
+ ].includes(group) && {
5193
+ 'data-invalid-type': 'label',
5194
+ 'data-invalid-message': '"fig" and "figure" label groups must be used to media'
5195
+ } || group === 'table' && type !== group && {
5196
+ 'data-invalid-type': 'label',
5197
+ 'data-invalid-message': '"table" label group must be used to tables'
5198
+ } || group === 'list' && type !== group && {
5199
+ 'data-invalid-type': 'label',
5200
+ 'data-invalid-message': '"list" label group must be used to lists'
5201
+ } || group === 'quote' && type !== group && {
5202
+ 'data-invalid-type': 'label',
5203
+ 'data-invalid-message': '"quote" label group must be used to blockquotes'
5204
+ } || group === 'text' && type !== group && {
5205
+ 'data-invalid-type': 'label',
5206
+ 'data-invalid-message': '"text" label group must be used to codeblocks with no language'
5207
+ } || group === 'code' && type !== group && {
5208
+ 'data-invalid-type': 'label',
5209
+ 'data-invalid-message': '"code" label group must be used to codeblocks with any language'
5210
+ } || group === 'example' && type !== group && {
5211
+ 'data-invalid-type': 'label',
5212
+ 'data-invalid-message': '"example" label group must be used to examples'
5199
5213
  } || global_1.undefined;
5200
5214
  return {
5201
5215
  'data-type': type,
5202
5216
  'data-label': label,
5203
5217
  'data-group': group,
5204
- ...invalid && {
5218
+ ...(invalid === null || invalid === void 0 ? void 0 : invalid['data-invalid-type']) && {
5205
5219
  class: 'invalid',
5206
5220
  'data-invalid-syntax': 'figure',
5207
5221
  ...invalid
@@ -6206,13 +6220,10 @@ require = function () {
6206
6220
  (0, combinator_1.guard)(context => {
6207
6221
  var _a;
6208
6222
  return (_a = context.header) !== null && _a !== void 0 ? _a : true;
6209
- }, (0, combinator_1.focus)(/^---[^\S\v\f\r\n]*\r?\n(?:[A-Za-z][0-9A-Za-z]*(?:-[A-Za-z][0-9A-Za-z]*)*:[ \t]+\S[^\v\f\r\n]*\r?\n){1,100}---[^\S\v\f\r\n]*(?:$|\r?\n)/, (0, combinator_1.convert)(source => (0, normalize_1.normalize)(source.slice(source.indexOf('\n') + 1, source.trimEnd().lastIndexOf('\n'))).replace(/(\S)\s+$/mg, '$1'), (0, combinator_1.fmap)((0, combinator_1.some)((0, combinator_1.union)([field])), es => [(0, typed_dom_1.html)('details', {
6210
- class: 'header',
6211
- open: ''
6212
- }, (0, typed_dom_1.defrag)([
6213
- (0, typed_dom_1.html)('summary', 'Header'),
6214
- ...es
6215
- ]))])))),
6223
+ }, (0, combinator_1.focus)(/^---[^\S\v\f\r\n]*\r?\n(?:[A-Za-z][0-9A-Za-z]*(?:-[A-Za-z][0-9A-Za-z]*)*:[ \t]+\S[^\v\f\r\n]*\r?\n){1,100}---[^\S\v\f\r\n]*(?:$|\r?\n)/, (0, combinator_1.convert)(source => (0, normalize_1.normalize)(source.slice(source.indexOf('\n') + 1, source.trimEnd().lastIndexOf('\n'))).replace(/(\S)\s+$/mg, '$1'), (0, combinator_1.fmap)((0, combinator_1.some)((0, combinator_1.union)([field])), es => [(0, typed_dom_1.html)('aside', { class: 'header' }, [(0, typed_dom_1.html)('details', { open: '' }, (0, typed_dom_1.defrag)([
6224
+ (0, typed_dom_1.html)('summary', 'Header'),
6225
+ ...es
6226
+ ]))])])))),
6216
6227
  source => [
6217
6228
  [(0, typed_dom_1.html)('pre', {
6218
6229
  class: 'invalid',
@@ -6232,7 +6243,7 @@ require = function () {
6232
6243
  return [
6233
6244
  [(0, typed_dom_1.html)('span', {
6234
6245
  class: 'field',
6235
- 'data-name': name,
6246
+ 'data-name': name.toLowerCase(),
6236
6247
  'data-value': value
6237
6248
  }, [
6238
6249
  (0, typed_dom_1.html)('span', { class: 'field-name' }, name),
@@ -6662,7 +6673,7 @@ require = function () {
6662
6673
  const source_1 = _dereq_('../source');
6663
6674
  const typed_dom_1 = _dereq_('typed-dom');
6664
6675
  const array_1 = _dereq_('spica/array');
6665
- const index = /^(?:[0-9]+(?:\.[0-9]+)*|[A-Za-z])/;
6676
+ const index = /^(?:[0-9]+(?:(?:[.-]|, )[0-9]+)*|[A-Za-z])/;
6666
6677
  exports.bracket = (0, combinator_1.lazy)(() => (0, combinator_1.creator)((0, combinator_1.union)([
6667
6678
  (0, combinator_1.surround)((0, source_1.str)('('), (0, source_1.str)(index), (0, source_1.str)(')')),
6668
6679
  (0, combinator_1.surround)((0, source_1.str)('('), (0, combinator_1.some)(inline_1.inline, ')'), (0, source_1.str)(')'), true, ([as, bs = [], cs], rest) => [
@@ -6672,7 +6683,7 @@ require = function () {
6672
6683
  (0, array_1.unshift)(as, bs),
6673
6684
  rest
6674
6685
  ]),
6675
- (0, combinator_1.surround)((0, source_1.str)('\uFF08'), (0, source_1.str)(new RegExp(index.source.replace(/[09AZaz.]/g, c => String.fromCharCode(c.charCodeAt(0) + 65248)))), (0, source_1.str)('\uFF09')),
6686
+ (0, combinator_1.surround)((0, source_1.str)('\uFF08'), (0, source_1.str)(new RegExp(index.source.replace(/[09AZaz., ]|\-(?!\w)/g, c => c.trimStart() && String.fromCharCode(c.charCodeAt(0) + 65248)))), (0, source_1.str)('\uFF09')),
6676
6687
  (0, combinator_1.surround)((0, source_1.str)('\uFF08'), (0, combinator_1.some)(inline_1.inline, '\uFF09'), (0, source_1.str)('\uFF09'), true, ([as, bs = [], cs], rest) => [
6677
6688
  [(0, typed_dom_1.html)('span', { class: 'paren' }, (0, typed_dom_1.defrag)((0, array_1.push)((0, array_1.unshift)(as, bs), cs)))],
6678
6689
  rest
@@ -7048,12 +7059,13 @@ require = function () {
7048
7059
  function text(source, optional = false) {
7049
7060
  var _a;
7050
7061
  const indexer = source.querySelector(':scope > .indexer');
7051
- if (indexer)
7052
- return indexer.getAttribute('data-index');
7053
- if (optional)
7062
+ if (!indexer && optional)
7054
7063
  return '';
7064
+ const index = indexer === null || indexer === void 0 ? void 0 : indexer.getAttribute('data-index');
7065
+ if (index)
7066
+ return index;
7055
7067
  const target = source.cloneNode(true);
7056
- for (let es = target.querySelectorAll('code[data-src], .math[data-src], .comment, rt, rp, .reference'), i = 0, len = es.length; i < len; ++i) {
7068
+ for (let es = target.querySelectorAll('code[data-src], .math[data-src], .comment, rt, rp, .reference, .checkbox, ul, ol'), i = 0, len = es.length; i < len; ++i) {
7057
7069
  const el = es[i];
7058
7070
  switch (el.tagName) {
7059
7071
  case 'CODE':
@@ -7061,6 +7073,8 @@ require = function () {
7061
7073
  continue;
7062
7074
  case 'RT':
7063
7075
  case 'RP':
7076
+ case 'UL':
7077
+ case 'OL':
7064
7078
  el.remove();
7065
7079
  continue;
7066
7080
  }
@@ -7069,6 +7083,7 @@ require = function () {
7069
7083
  (0, typed_dom_1.define)(el, el.getAttribute('data-src'));
7070
7084
  continue;
7071
7085
  case 'comment':
7086
+ case 'checkbox':
7072
7087
  el.remove();
7073
7088
  continue;
7074
7089
  case 'reference':
@@ -7094,7 +7109,13 @@ require = function () {
7094
7109
  const combinator_1 = _dereq_('../../../combinator');
7095
7110
  const index_1 = _dereq_('./index');
7096
7111
  const typed_dom_1 = _dereq_('typed-dom');
7097
- exports.indexer = (0, combinator_1.creator)((0, combinator_1.fmap)((0, combinator_1.verify)((0, combinator_1.surround)(/^\s+(?=\[#[^\s\]])/, (0, combinator_1.context)({ syntax: { inline: { index: true } } }, (0, combinator_1.union)([index_1.index])), /^\s*$/), ([el]) => el.getElementsByClassName('invalid').length === 0), ([el]) => [(0, typed_dom_1.html)('span', {
7112
+ exports.indexer = (0, combinator_1.creator)((0, combinator_1.fmap)((0, combinator_1.verify)((0, combinator_1.surround)(/^\s+(?=\[#\S)/, (0, combinator_1.context)({ syntax: { inline: { index: true } } }, (0, combinator_1.union)([
7113
+ (0, combinator_1.focus)('[#]', () => [
7114
+ [(0, typed_dom_1.html)('a', { href: '#' })],
7115
+ ''
7116
+ ]),
7117
+ index_1.index
7118
+ ])), /^\s*$/), ([el]) => el.getElementsByClassName('invalid').length === 0), ([el]) => [(0, typed_dom_1.html)('span', {
7098
7119
  class: 'indexer',
7099
7120
  'data-index': el.getAttribute('href').slice(7)
7100
7121
  })]));
@@ -7837,7 +7858,7 @@ require = function () {
7837
7858
  ]),
7838
7859
  (0, util_1.trimSpaceStart)((0, combinator_1.some)(inline_1.inline, ']', /^\\?\n/))
7839
7860
  ])))), ']]'), ns => [(0, typed_dom_1.html)('sup', attributes(ns), (0, util_1.trimNodeEnd)((0, typed_dom_1.defrag)(ns)))]))));
7840
- const abbr = (0, combinator_1.creator)((0, combinator_1.fmap)((0, combinator_1.verify)((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]+/), (_, rest, context) => (0, util_1.isStartLoose)(rest, context)), ([source]) => [(0, typed_dom_1.html)('abbr', source)]));
7861
+ const abbr = (0, combinator_1.creator)((0, combinator_1.fmap)((0, combinator_1.verify)((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]*/), (_, rest, context) => (0, util_1.isStartLoose)(rest, context)), ([source]) => [(0, typed_dom_1.html)('abbr', source)]));
7841
7862
  function attributes(ns) {
7842
7863
  return typeof ns[0] === 'object' && ns[0].tagName === 'ABBR' ? {
7843
7864
  class: 'reference',
@@ -8219,11 +8240,11 @@ require = function () {
8219
8240
  class: void def.classList.add('invalid'),
8220
8241
  'data-invalid-syntax': 'figure',
8221
8242
  'data-invalid-type': 'position',
8222
- 'data-invalid-message': 'Base index declarations must be after level 1 to 6 headings',
8243
+ 'data-invalid-message': messages.declaration,
8223
8244
  hidden: null
8224
8245
  });
8225
8246
  continue;
8226
- } else if (def.getAttribute('data-invalid-message') === 'Base index declarations must be after level 1 to 6 headings') {
8247
+ } else if (def.getAttribute('data-invalid-message') === messages.declaration) {
8227
8248
  (0, typed_dom_1.define)(def, {
8228
8249
  class: void def.classList.remove('invalid'),
8229
8250
  'data-invalid-syntax': null,
@@ -8260,10 +8281,10 @@ require = function () {
8260
8281
  class: void def.classList.add('invalid'),
8261
8282
  'data-invalid-syntax': 'figure',
8262
8283
  'data-invalid-type': 'argument',
8263
- 'data-invalid-message': 'Duplicate label'
8284
+ 'data-invalid-message': messages.duplicate
8264
8285
  });
8265
8286
  continue;
8266
- } else if (def.getAttribute('data-invalid-message') === 'Duplicate label') {
8287
+ } else if (def.getAttribute('data-invalid-message') === messages.duplicate) {
8267
8288
  (0, typed_dom_1.define)(def, {
8268
8289
  class: void def.classList.remove('invalid'),
8269
8290
  'data-invalid-syntax': null,
@@ -8274,7 +8295,7 @@ require = function () {
8274
8295
  labels.add(label);
8275
8296
  opts.id !== '' && def.setAttribute('id', `label:${ opts.id ? `${ opts.id }:` : '' }${ label }`);
8276
8297
  for (const ref of refs.take(label, global_1.Infinity)) {
8277
- if (ref.getAttribute('data-invalid-message') === 'Missing the target figure') {
8298
+ if (ref.getAttribute('data-invalid-message') === messages.reference) {
8278
8299
  (0, typed_dom_1.define)(ref, {
8279
8300
  class: void ref.classList.remove('invalid'),
8280
8301
  'data-invalid-syntax': null,
@@ -8293,7 +8314,7 @@ require = function () {
8293
8314
  class: void ref.classList.add('invalid'),
8294
8315
  'data-invalid-syntax': 'label',
8295
8316
  'data-invalid-type': 'reference',
8296
- 'data-invalid-message': 'Missing the target figure'
8317
+ 'data-invalid-message': messages.reference
8297
8318
  });
8298
8319
  }
8299
8320
  yield ref;
@@ -8301,6 +8322,11 @@ require = function () {
8301
8322
  return;
8302
8323
  }
8303
8324
  exports.figure = figure;
8325
+ const messages = {
8326
+ declaration: 'Base index declarations must be after level 1 to 6 headings',
8327
+ duplicate: 'Duplicate label',
8328
+ reference: 'Missing the target figure'
8329
+ };
8304
8330
  function increment(bases, el) {
8305
8331
  const index = (+el.tagName[1] - 1 || 1) - 1;
8306
8332
  return index + 1 < bases.length ? (0, array_1.join)(bases.slice(0, index + 2).map((v, i) => {
package/markdown.d.ts CHANGED
@@ -56,9 +56,9 @@ export namespace MarkdownParser {
56
56
  // url: https://host/path
57
57
  // ---
58
58
  Markdown<'header'>,
59
- Parser<HTMLDetailsElement | HTMLPreElement, Context, [
60
- Parser<HTMLDetailsElement | HTMLPreElement, Context, [
61
- Parser<HTMLDetailsElement, Context, [
59
+ Parser<HTMLElement | HTMLPreElement, Context, [
60
+ Parser<HTMLElement | HTMLPreElement, Context, [
61
+ Parser<HTMLElement, Context, [
62
62
  HeaderParser.FieldParser,
63
63
  ]>,
64
64
  Parser<HTMLPreElement, Context, []>,
@@ -768,9 +768,11 @@ export namespace MarkdownParser {
768
768
  }
769
769
  }
770
770
  export interface IndexerParser extends
771
+ // [#]
771
772
  // [#index]
772
773
  Inline<'extension/indexer'>,
773
774
  Parser<HTMLElement, Context, [
775
+ Parser<HTMLAnchorElement, Context, []>,
774
776
  IndexParser,
775
777
  ]> {
776
778
  }