securemark 0.233.3 → 0.234.2

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,18 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.234.2
4
+
5
+ - Refactoring.
6
+
7
+ ## 0.234.1
8
+
9
+ - Fix emstrong parser, emphasis parser, strong parser, and mark parser.
10
+
11
+ ## 0.234.0
12
+
13
+ - Extend anchor syntax.
14
+ - Refine comment parser.
15
+
3
16
  ## 0.233.3
4
17
 
5
18
  - Refactoring.
@@ -1,4 +1,4 @@
1
- /*! securemark v0.233.3 https://github.com/falsandtru/securemark | (c) 2017, falsandtru | UNLICENSED */
1
+ /*! securemark v0.234.2 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) {
@@ -5845,7 +5845,13 @@ require = function () {
5845
5845
  const typed_dom_1 = _dereq_('typed-dom');
5846
5846
  exports.cite = (0, combinator_1.creator)((0, combinator_1.line)((0, combinator_1.fmap)((0, combinator_1.validate)('>>', (0, combinator_1.reverse)((0, combinator_1.tails)([
5847
5847
  (0, source_1.str)(/^>*(?=>>[^>\s]+[^\S\n]*(?:$|\n))/),
5848
- anchor_1.anchor
5848
+ (0, combinator_1.union)([
5849
+ anchor_1.anchor,
5850
+ (0, combinator_1.focus)(/^>>\.[^\S\n]*(?:$|\n)/, () => [
5851
+ [(0, typed_dom_1.html)('a', { class: 'anchor' }, '>>.')],
5852
+ ''
5853
+ ])
5854
+ ])
5849
5855
  ]))), ([el, quotes = '']) => [
5850
5856
  (0, typed_dom_1.html)('span', { class: 'cite' }, (0, typed_dom_1.defrag)([
5851
5857
  `${ quotes }>`,
@@ -6341,14 +6347,14 @@ require = function () {
6341
6347
  const combinator_1 = _dereq_('../../../combinator');
6342
6348
  const link_1 = _dereq_('../link');
6343
6349
  const typed_dom_1 = _dereq_('typed-dom');
6344
- exports.anchor = (0, combinator_1.lazy)(() => (0, combinator_1.validate)('>>', (0, combinator_1.fmap)((0, combinator_1.focus)(/^>>[0-9a-z]+(?:-[0-9a-z]+)*(?![0-9A-Za-z@#:])/, (0, combinator_1.context)({
6350
+ exports.anchor = (0, combinator_1.lazy)(() => (0, combinator_1.validate)('>>', (0, combinator_1.fmap)((0, combinator_1.focus)(/^>>(?:[A-Za-z][0-9A-Za-z]*(?:-[0-9A-Za-z]+)*\/)?[0-9A-Za-z]+(?:-[0-9A-Za-z]+)*(?![0-9A-Za-z@#:])/, (0, combinator_1.context)({
6345
6351
  syntax: {
6346
6352
  inline: {
6347
6353
  link: true,
6348
6354
  autolink: false
6349
6355
  }
6350
6356
  }
6351
- }, (0, combinator_1.convert)(source => `[${ source }]{ ?at=${ source.slice(2) } }`, (0, combinator_1.union)([link_1.link])))), ([el]) => [(0, typed_dom_1.define)(el, { class: 'anchor' })])));
6357
+ }, (0, combinator_1.convert)(source => `[${ source }]{ ${ source.includes('/') ? `/@${ source.slice(2).replace('/', '/timeline/') }` : `?at=${ source.slice(2) }` } }`, (0, combinator_1.union)([link_1.link])))), ([el]) => [(0, typed_dom_1.define)(el, { class: 'anchor' })])));
6352
6358
  },
6353
6359
  {
6354
6360
  '../../../combinator': 27,
@@ -6600,24 +6606,25 @@ require = function () {
6600
6606
  'use strict';
6601
6607
  Object.defineProperty(exports, '__esModule', { value: true });
6602
6608
  exports.comment = void 0;
6603
- const parser_1 = _dereq_('../../combinator/data/parser');
6604
6609
  const combinator_1 = _dereq_('../../combinator');
6605
6610
  const inline_1 = _dereq_('../inline');
6606
6611
  const source_1 = _dereq_('../source');
6607
6612
  const typed_dom_1 = _dereq_('typed-dom');
6608
6613
  const memoize_1 = _dereq_('spica/memoize');
6609
6614
  const array_1 = _dereq_('spica/array');
6610
- exports.comment = (0, combinator_1.lazy)(() => (0, combinator_1.creator)((0, combinator_1.validate)('[#', (0, combinator_1.match)(/^(?=\[(#+)\s)/, (0, memoize_1.memoize)(([, fence], closer = new RegExp(String.raw`^\s+${ fence }\]`)) => (0, combinator_1.surround)((0, source_1.str)(/^\[(\S+)\s+(?!\1\])/), (0, combinator_1.union)([(0, combinator_1.some)(inline_1.inline, closer)]), (0, source_1.str)(closer), true, ([, bs = []], rest) => [
6611
- [(0, typed_dom_1.html)('span', { class: 'comment' }, (0, typed_dom_1.defrag)((0, array_1.push)((0, array_1.unshift)([`[${ fence } `], bs), [` ${ fence }]`])))],
6615
+ exports.comment = (0, combinator_1.lazy)(() => (0, combinator_1.creator)((0, combinator_1.validate)('[#', (0, combinator_1.match)(/^(?=\[(#+)\s)/, (0, memoize_1.memoize)(([, fence]) => (0, combinator_1.surround)((0, combinator_1.open)((0, source_1.str)(`[${ fence }`), (0, combinator_1.some)(source_1.text, new RegExp(String.raw`^\s+${ fence }\]|^\S`)), true), (0, combinator_1.union)([(0, combinator_1.some)(inline_1.inline, new RegExp(String.raw`^\s+${ fence }\]`))]), (0, combinator_1.close)((0, combinator_1.some)(source_1.text, /^\S/), (0, source_1.str)(`${ fence }]`)), true, ([as, bs = [], cs], rest) => [
6616
+ [(0, typed_dom_1.html)('span', { class: 'comment' }, [
6617
+ (0, typed_dom_1.html)('input', { type: 'checkbox' }),
6618
+ (0, typed_dom_1.html)('span', (0, typed_dom_1.defrag)((0, array_1.push)((0, array_1.unshift)(as, bs), cs)))
6619
+ ])],
6612
6620
  rest
6613
- ], ([as, bs = []], rest, context) => [
6614
- (0, array_1.unshift)((0, array_1.pop)((0, parser_1.eval)((0, combinator_1.some)(source_1.text)(`${ as[0] }!`, context)))[0], bs),
6621
+ ], ([as, bs = []], rest) => [
6622
+ (0, array_1.unshift)(as, bs),
6615
6623
  rest
6616
6624
  ]), ([, fence]) => fence)))));
6617
6625
  },
6618
6626
  {
6619
6627
  '../../combinator': 27,
6620
- '../../combinator/data/parser': 47,
6621
6628
  '../inline': 88,
6622
6629
  '../source': 128,
6623
6630
  'spica/array': 6,
@@ -6667,7 +6674,8 @@ require = function () {
6667
6674
  const array_1 = _dereq_('spica/array');
6668
6675
  exports.emphasis = (0, combinator_1.lazy)(() => (0, combinator_1.creator)((0, combinator_1.surround)((0, combinator_1.close)((0, source_1.str)('*'), /^(?!\*)/), (0, util_1.startTight)((0, combinator_1.some)((0, combinator_1.union)([
6669
6676
  strong_1.strong,
6670
- (0, combinator_1.some)(inline_1.inline, '*')
6677
+ (0, combinator_1.some)(inline_1.inline, (0, util_1.delimiter)(String.raw`\*`)),
6678
+ (0, combinator_1.open)((0, combinator_1.some)(inline_1.inline, '*'), inline_1.inline)
6671
6679
  ]))), (0, source_1.str)('*'), false, ([as, bs, cs], rest) => (0, util_1.isEndTightNodes)(bs) ? [
6672
6680
  [(0, typed_dom_1.html)('em', (0, typed_dom_1.defrag)(bs))],
6673
6681
  rest
@@ -6696,11 +6704,24 @@ require = function () {
6696
6704
  exports.emstrong = void 0;
6697
6705
  const combinator_1 = _dereq_('../../combinator');
6698
6706
  const inline_1 = _dereq_('../inline');
6707
+ const strong_1 = _dereq_('./strong');
6699
6708
  const source_1 = _dereq_('../source');
6700
6709
  const util_1 = _dereq_('../util');
6701
6710
  const typed_dom_1 = _dereq_('typed-dom');
6702
6711
  const array_1 = _dereq_('spica/array');
6703
- exports.emstrong = (0, combinator_1.lazy)(() => (0, combinator_1.creator)((0, combinator_1.surround)((0, source_1.str)('***'), (0, util_1.startTight)((0, combinator_1.union)([(0, combinator_1.some)(inline_1.inline, '*')])), (0, source_1.str)(/^\*{1,3}/), false, ([as, bs, cs], rest, context) => {
6712
+ const substrong = (0, combinator_1.lazy)(() => (0, combinator_1.some)((0, combinator_1.union)([
6713
+ (0, combinator_1.some)(inline_1.inline, (0, util_1.delimiter)(String.raw`\*\*`)),
6714
+ (0, combinator_1.open)((0, combinator_1.some)(inline_1.inline, '*'), inline_1.inline)
6715
+ ])));
6716
+ const subemphasis = (0, combinator_1.lazy)(() => (0, combinator_1.some)((0, combinator_1.union)([
6717
+ strong_1.strong,
6718
+ (0, combinator_1.some)(inline_1.inline, (0, util_1.delimiter)(String.raw`\*`)),
6719
+ (0, combinator_1.open)((0, combinator_1.some)(inline_1.inline, '*'), inline_1.inline)
6720
+ ])));
6721
+ exports.emstrong = (0, combinator_1.lazy)(() => (0, combinator_1.creator)((0, combinator_1.surround)((0, source_1.str)('***'), (0, util_1.startTight)((0, combinator_1.some)((0, combinator_1.union)([
6722
+ (0, combinator_1.some)(inline_1.inline, (0, util_1.delimiter)(String.raw`\*`)),
6723
+ (0, combinator_1.open)((0, combinator_1.some)(inline_1.inline, '*'), inline_1.inline)
6724
+ ]))), (0, source_1.str)(/^\*{1,3}/), false, ([as, bs, cs], rest, context) => {
6704
6725
  var _a, _b;
6705
6726
  if (!(0, util_1.isEndTightNodes)(bs))
6706
6727
  return [
@@ -6708,25 +6729,13 @@ require = function () {
6708
6729
  cs[0] + rest
6709
6730
  ];
6710
6731
  switch (cs[0]) {
6711
- case '*':
6712
- return (_a = (0, combinator_1.bind)((0, combinator_1.union)([(0, combinator_1.some)(inline_1.inline, '**')]), (ds, rest) => rest.slice(0, 2) === '**' && (0, util_1.isEndTightNodes)(ds) ? [
6713
- [(0, typed_dom_1.html)('strong', (0, array_1.unshift)([(0, typed_dom_1.html)('em', (0, typed_dom_1.defrag)(bs))], (0, typed_dom_1.defrag)(ds)))],
6714
- rest.slice(2)
6715
- ] : [
6716
- (0, array_1.unshift)([
6717
- '**',
6718
- (0, typed_dom_1.html)('em', (0, typed_dom_1.defrag)(bs))
6719
- ], ds),
6720
- rest
6721
- ])(rest, context)) !== null && _a !== void 0 ? _a : [
6722
- [
6723
- '**',
6724
- (0, typed_dom_1.html)('em', (0, typed_dom_1.defrag)(bs))
6725
- ],
6732
+ case '***':
6733
+ return [
6734
+ [(0, typed_dom_1.html)('em', [(0, typed_dom_1.html)('strong', (0, typed_dom_1.defrag)(bs))])],
6726
6735
  rest
6727
6736
  ];
6728
6737
  case '**':
6729
- return (_b = (0, combinator_1.bind)((0, combinator_1.union)([(0, combinator_1.some)(inline_1.inline, '*')]), (ds, rest) => rest.slice(0, 1) === '*' && (0, util_1.isEndTightNodes)(ds) ? [
6738
+ return (_a = (0, combinator_1.bind)(subemphasis, (ds, rest) => rest.slice(0, 1) === '*' && (0, util_1.isEndTightNodes)(ds) ? [
6730
6739
  [(0, typed_dom_1.html)('em', (0, array_1.unshift)([(0, typed_dom_1.html)('strong', (0, typed_dom_1.defrag)(bs))], (0, typed_dom_1.defrag)(ds)))],
6731
6740
  rest.slice(1)
6732
6741
  ] : [
@@ -6735,16 +6744,28 @@ require = function () {
6735
6744
  (0, typed_dom_1.html)('strong', (0, typed_dom_1.defrag)(bs))
6736
6745
  ], ds),
6737
6746
  rest
6738
- ])(rest, context)) !== null && _b !== void 0 ? _b : [
6747
+ ])(rest, context)) !== null && _a !== void 0 ? _a : [
6739
6748
  [
6740
6749
  '*',
6741
6750
  (0, typed_dom_1.html)('strong', (0, typed_dom_1.defrag)(bs))
6742
6751
  ],
6743
6752
  rest
6744
6753
  ];
6745
- case '***':
6746
- return [
6747
- [(0, typed_dom_1.html)('em', [(0, typed_dom_1.html)('strong', (0, typed_dom_1.defrag)(bs))])],
6754
+ case '*':
6755
+ return (_b = (0, combinator_1.bind)(substrong, (ds, rest) => rest.slice(0, 2) === '**' && (0, util_1.isEndTightNodes)(ds) ? [
6756
+ [(0, typed_dom_1.html)('strong', (0, array_1.unshift)([(0, typed_dom_1.html)('em', (0, typed_dom_1.defrag)(bs))], (0, typed_dom_1.defrag)(ds)))],
6757
+ rest.slice(2)
6758
+ ] : [
6759
+ (0, array_1.unshift)([
6760
+ '**',
6761
+ (0, typed_dom_1.html)('em', (0, typed_dom_1.defrag)(bs))
6762
+ ], ds),
6763
+ rest
6764
+ ])(rest, context)) !== null && _b !== void 0 ? _b : [
6765
+ [
6766
+ '**',
6767
+ (0, typed_dom_1.html)('em', (0, typed_dom_1.defrag)(bs))
6768
+ ],
6748
6769
  rest
6749
6770
  ];
6750
6771
  }
@@ -6758,6 +6779,7 @@ require = function () {
6758
6779
  '../inline': 88,
6759
6780
  '../source': 128,
6760
6781
  '../util': 134,
6782
+ './strong': 121,
6761
6783
  'spica/array': 6,
6762
6784
  'typed-dom': 26
6763
6785
  }
@@ -7216,7 +7238,7 @@ require = function () {
7216
7238
  const combinator_1 = _dereq_('../../combinator');
7217
7239
  const typed_dom_1 = _dereq_('typed-dom');
7218
7240
  const parser = (0, typed_dom_1.html)('textarea');
7219
- exports.unsafehtmlentity = (0, combinator_1.creator)((0, combinator_1.validate)('&', (0, combinator_1.fmap)((0, combinator_1.focus)(/^&[0-9A-Za-z]+;/, entity => [
7241
+ exports.unsafehtmlentity = (0, combinator_1.creator)((0, combinator_1.validate)('&', (0, combinator_1.fmap)((0, combinator_1.focus)(/^&(?!NewLine;)[0-9A-Za-z]+;/, entity => [
7220
7242
  [(parser.innerHTML = entity, parser.value)],
7221
7243
  ''
7222
7244
  ]), ([str]) => [str[0] !== '&' || str.length < 3 ? str : `\0${ str }`])));
@@ -7415,7 +7437,10 @@ require = function () {
7415
7437
  const util_1 = _dereq_('../util');
7416
7438
  const typed_dom_1 = _dereq_('typed-dom');
7417
7439
  const array_1 = _dereq_('spica/array');
7418
- exports.mark = (0, combinator_1.lazy)(() => (0, combinator_1.creator)((0, combinator_1.surround)((0, source_1.str)('=='), (0, util_1.startTight)((0, combinator_1.union)([(0, combinator_1.some)(inline_1.inline, '==')])), (0, source_1.str)('=='), false, ([as, bs, cs], rest) => (0, util_1.isEndTightNodes)(bs) ? [
7440
+ exports.mark = (0, combinator_1.lazy)(() => (0, combinator_1.creator)((0, combinator_1.surround)((0, source_1.str)('=='), (0, util_1.startTight)((0, combinator_1.some)((0, combinator_1.union)([
7441
+ (0, combinator_1.some)(inline_1.inline, (0, util_1.delimiter)('==')),
7442
+ (0, combinator_1.open)((0, combinator_1.some)(inline_1.inline, '='), inline_1.inline)
7443
+ ]))), (0, source_1.str)('=='), false, ([as, bs, cs], rest) => (0, util_1.isEndTightNodes)(bs) ? [
7419
7444
  [(0, typed_dom_1.html)('mark', (0, typed_dom_1.defrag)(bs))],
7420
7445
  rest
7421
7446
  ] : [
@@ -7442,11 +7467,10 @@ require = function () {
7442
7467
  exports.math = void 0;
7443
7468
  const combinator_1 = _dereq_('../../combinator');
7444
7469
  const source_1 = _dereq_('../source');
7445
- const util_1 = _dereq_('../util');
7446
7470
  const typed_dom_1 = _dereq_('typed-dom');
7447
7471
  const disallowedCommand = /\\(?:begin|tiny|huge|large)(?![0-9a-z])/i;
7448
7472
  exports.math = (0, combinator_1.lazy)(() => (0, combinator_1.creator)((0, combinator_1.validate)('$', (0, combinator_1.rewrite)((0, combinator_1.union)([
7449
- (0, combinator_1.surround)('$', (0, combinator_1.verify)((0, source_1.str)(/^(?![\s{}#$%&]|\d+(?:[,.]\d+)*[^-+*/=<>^_~\\$]|-[\da-z]|[a-z]+-)(?:\\\$|[\x20-\x23\x25-\x7E])+/i), util_1.isEndTightNodes), /^\$(?![0-9a-z])/i),
7473
+ (0, combinator_1.surround)('$', (0, source_1.str)(/^(?![\s{}#$%&]|\d+(?:[,.]\d+)*[^-+*/=<>^_~\\$]|-[\da-z]|[a-z]+-)(?:\\\$|\x20(?!\$)|[\x21-\x23\x25-\x7E])+/i), /^\$(?![0-9a-z])/i),
7450
7474
  (0, combinator_1.surround)('$', bracket, '$')
7451
7475
  ]), (source, {
7452
7476
  caches: {math: cache} = {}
@@ -7475,7 +7499,6 @@ require = function () {
7475
7499
  {
7476
7500
  '../../combinator': 27,
7477
7501
  '../source': 128,
7478
- '../util': 134,
7479
7502
  'typed-dom': 26
7480
7503
  }
7481
7504
  ],
@@ -7829,16 +7852,14 @@ require = function () {
7829
7852
  exports.strong = void 0;
7830
7853
  const combinator_1 = _dereq_('../../combinator');
7831
7854
  const inline_1 = _dereq_('../inline');
7832
- const emphasis_1 = _dereq_('./emphasis');
7833
7855
  const source_1 = _dereq_('../source');
7834
7856
  const util_1 = _dereq_('../util');
7835
7857
  const typed_dom_1 = _dereq_('typed-dom');
7836
7858
  const array_1 = _dereq_('spica/array');
7837
7859
  exports.strong = (0, combinator_1.lazy)(() => (0, combinator_1.creator)((0, combinator_1.surround)((0, combinator_1.close)((0, source_1.str)('**'), /^(?!\*)/), (0, util_1.startTight)((0, combinator_1.some)((0, combinator_1.union)([
7838
- emphasis_1.emphasis,
7839
- (0, combinator_1.some)(inline_1.inline, '*'),
7840
- (0, source_1.str)('*')
7841
- ]), '**')), (0, source_1.str)('**'), false, ([as, bs, cs], rest) => (0, util_1.isEndTightNodes)(bs) ? [
7860
+ (0, combinator_1.some)(inline_1.inline, (0, util_1.delimiter)(String.raw`\*\*`)),
7861
+ (0, combinator_1.open)((0, combinator_1.some)(inline_1.inline, '*'), inline_1.inline)
7862
+ ]))), (0, source_1.str)('**'), false, ([as, bs, cs], rest) => (0, util_1.isEndTightNodes)(bs) ? [
7842
7863
  [(0, typed_dom_1.html)('strong', (0, typed_dom_1.defrag)(bs))],
7843
7864
  rest
7844
7865
  ] : [
@@ -7854,7 +7875,6 @@ require = function () {
7854
7875
  '../inline': 88,
7855
7876
  '../source': 128,
7856
7877
  '../util': 134,
7857
- './emphasis': 102,
7858
7878
  'spica/array': 6,
7859
7879
  'typed-dom': 26
7860
7880
  }
@@ -8630,7 +8650,7 @@ require = function () {
8630
8650
  function (_dereq_, module, exports) {
8631
8651
  'use strict';
8632
8652
  Object.defineProperty(exports, '__esModule', { value: true });
8633
- exports.stringify = exports.trimNodeEndBR = exports.trimNodeEnd = exports.trimNode = exports.isEndTightNodes = exports.isStartTightNodes = exports.startTight = exports.isStartLoose = exports.startLoose = exports.visualize = void 0;
8653
+ exports.stringify = exports.trimNodeEndBR = exports.trimNodeEnd = exports.trimNode = exports.isEndTightNodes = exports.isStartTightNodes = exports.startTight = exports.isStartLoose = exports.startLoose = exports.visualize = exports.delimiter = void 0;
8634
8654
  const global_1 = _dereq_('spica/global');
8635
8655
  const parser_1 = _dereq_('../combinator/data/parser');
8636
8656
  const combinator_1 = _dereq_('../combinator');
@@ -8671,7 +8691,11 @@ require = function () {
8671
8691
  'InvisibleComma',
8672
8692
  'ic'
8673
8693
  ];
8674
- const blankline = new RegExp(String.raw`^(?!$)(?:\\$|\\?[^\S\n]|&(?:${ invisibleHTMLEntityNames.join('|') });|<wbr>)+$`, 'gm');
8694
+ const blankline = new RegExp(String.raw`^(?:\\$|\\?[^\S\n]|&(?:${ invisibleHTMLEntityNames.join('|') });|<wbr>)+$`, 'gm');
8695
+ function delimiter(opener) {
8696
+ return new RegExp(String.raw`^(?:\s+|\\\s|&(?:${ invisibleHTMLEntityNames.join('|') });|<wbr>)?${ opener }`);
8697
+ }
8698
+ exports.delimiter = delimiter;
8675
8699
  function visualize(parser) {
8676
8700
  return (0, combinator_1.union)([
8677
8701
  (0, combinator_1.convert)(source => source.replace(blankline, line => line.replace(/[\\&<]/g, '\x1B$&')), (0, combinator_1.verify)(parser, (ns, rest, context) => !rest && hasVisible(ns, context))),
@@ -8729,7 +8753,6 @@ require = function () {
8729
8753
  case '\t':
8730
8754
  case '\n':
8731
8755
  return false;
8732
- case '\x1B':
8733
8756
  case '\\':
8734
8757
  return ((_a = source[1]) === null || _a === void 0 ? void 0 : _a.trimStart()) !== '';
8735
8758
  case '&':
package/markdown.d.ts CHANGED
@@ -572,7 +572,10 @@ export namespace MarkdownParser {
572
572
  Block<'reply/cite'>,
573
573
  Parser<HTMLSpanElement | HTMLBRElement, Context, [
574
574
  SourceParser.StrParser,
575
- InlineParser.AutolinkParser.AnchorParser,
575
+ Parser<HTMLAnchorElement, Context, [
576
+ InlineParser.AutolinkParser.AnchorParser,
577
+ Parser<HTMLAnchorElement, Context, []>,
578
+ ]>,
576
579
  ]> {
577
580
  }
578
581
  export interface QuoteParser extends
@@ -967,6 +970,7 @@ export namespace MarkdownParser {
967
970
  Inline<'mark'>,
968
971
  Parser<HTMLElement | string, Context, [
969
972
  InlineParser,
973
+ InlineParser,
970
974
  ]> {
971
975
  }
972
976
  export interface EmStrongParser extends
@@ -974,15 +978,15 @@ export namespace MarkdownParser {
974
978
  Inline<'emstrong'>,
975
979
  Parser<HTMLElement | string, Context, [
976
980
  InlineParser,
981
+ InlineParser,
977
982
  ]> {
978
983
  }
979
984
  export interface StrongParser extends
980
985
  // **abc**
981
986
  Inline<'strong'>,
982
987
  Parser<HTMLElement | string, Context, [
983
- EmphasisParser,
984
988
  InlineParser,
985
- SourceParser.StrParser,
989
+ InlineParser,
986
990
  ]> {
987
991
  }
988
992
  export interface EmphasisParser extends
@@ -991,6 +995,7 @@ export namespace MarkdownParser {
991
995
  Parser<HTMLElement | string, Context, [
992
996
  StrongParser,
993
997
  InlineParser,
998
+ InlineParser,
994
999
  ]> {
995
1000
  }
996
1001
  export interface CodeParser extends
package/package-lock.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "securemark",
3
- "version": "0.233.3",
3
+ "version": "0.234.2",
4
4
  "lockfileVersion": 1,
5
5
  "requires": true,
6
6
  "dependencies": {
@@ -3030,9 +3030,9 @@
3030
3030
  "dev": true
3031
3031
  },
3032
3032
  "electron-to-chromium": {
3033
- "version": "1.4.95",
3034
- "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.95.tgz",
3035
- "integrity": "sha512-h2VAMV/hPtmAeiDkwA8c5sjS+cWt6GlQL4ERdrOUWu7cRIG5IRk9uwR9f0utP+hPJ9ZZsADTq9HpbuT46eBYAg==",
3033
+ "version": "1.4.96",
3034
+ "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.96.tgz",
3035
+ "integrity": "sha512-DPNjvNGPabv6FcyjzLAN4C0psN/GgD9rSGvMTuv81SeXG/EX3mCz0wiw9N1tUEnfQXYCJi3H8M0oFPRziZh7rw==",
3036
3036
  "dev": true
3037
3037
  },
3038
3038
  "elliptic": {
@@ -3210,9 +3210,9 @@
3210
3210
  }
3211
3211
  },
3212
3212
  "es-abstract": {
3213
- "version": "1.19.1",
3214
- "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.19.1.tgz",
3215
- "integrity": "sha512-2vJ6tjA/UfqLm2MPs7jxVybLoB8i1t1Jd9R3kISld20sIxPcTbLuggQOUxeWeAvIUkduv/CfMjuh4WmiXr2v9w==",
3213
+ "version": "1.19.2",
3214
+ "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.19.2.tgz",
3215
+ "integrity": "sha512-gfSBJoZdlL2xRiOCy0g8gLMryhoe1TlimjzU99L/31Z8QEGIhVQI+EWwt5lT+AuU9SnorVupXFqqOGqGfsyO6w==",
3216
3216
  "dev": true,
3217
3217
  "requires": {
3218
3218
  "call-bind": "^1.0.2",
@@ -3221,15 +3221,15 @@
3221
3221
  "get-intrinsic": "^1.1.1",
3222
3222
  "get-symbol-description": "^1.0.0",
3223
3223
  "has": "^1.0.3",
3224
- "has-symbols": "^1.0.2",
3224
+ "has-symbols": "^1.0.3",
3225
3225
  "internal-slot": "^1.0.3",
3226
3226
  "is-callable": "^1.2.4",
3227
- "is-negative-zero": "^2.0.1",
3227
+ "is-negative-zero": "^2.0.2",
3228
3228
  "is-regex": "^1.1.4",
3229
3229
  "is-shared-array-buffer": "^1.0.1",
3230
3230
  "is-string": "^1.0.7",
3231
- "is-weakref": "^1.0.1",
3232
- "object-inspect": "^1.11.0",
3231
+ "is-weakref": "^1.0.2",
3232
+ "object-inspect": "^1.12.0",
3233
3233
  "object-keys": "^1.1.1",
3234
3234
  "object.assign": "^4.1.2",
3235
3235
  "string.prototype.trimend": "^1.0.4",
@@ -4608,9 +4608,9 @@
4608
4608
  "dev": true
4609
4609
  },
4610
4610
  "gauge": {
4611
- "version": "4.0.3",
4612
- "resolved": "https://registry.npmjs.org/gauge/-/gauge-4.0.3.tgz",
4613
- "integrity": "sha512-ICw1DhAwMtb22rYFwEHgJcx1JCwJGv3x6G0OQUq56Nge+H4Q8JEwr8iveS0XFlsUNSI67F5ffMGK25bK4Pmskw==",
4611
+ "version": "4.0.4",
4612
+ "resolved": "https://registry.npmjs.org/gauge/-/gauge-4.0.4.tgz",
4613
+ "integrity": "sha512-f9m+BEN5jkg6a0fZjleidjN51VE1X+mPFQ2DJ0uv1V39oCLCbsGe6yjbBnp7eK7z/+GAon99a3nHuqbuuthyPg==",
4614
4614
  "dev": true,
4615
4615
  "requires": {
4616
4616
  "aproba": "^1.0.3 || ^2.0.0",
@@ -8918,9 +8918,9 @@
8918
8918
  "dev": true
8919
8919
  },
8920
8920
  "proc-log": {
8921
- "version": "2.0.0",
8922
- "resolved": "https://registry.npmjs.org/proc-log/-/proc-log-2.0.0.tgz",
8923
- "integrity": "sha512-I/35MfCX2H8jBUhKN8JB8nmqvQo/nKdrBodBY7L3RhDSPPyvOHwLYNmPuhwuJq7a7C3vgFKWGQM+ecPStcvOHA==",
8921
+ "version": "2.0.1",
8922
+ "resolved": "https://registry.npmjs.org/proc-log/-/proc-log-2.0.1.tgz",
8923
+ "integrity": "sha512-Kcmo2FhfDTXdcbfDH76N7uBYHINxc/8GW7UAVuVP9I+Va3uHSerrnKV6dLooga/gh7GlgzuCCr/eoldnL1muGw==",
8924
8924
  "dev": true
8925
8925
  },
8926
8926
  "process": {
@@ -11500,9 +11500,9 @@
11500
11500
  },
11501
11501
  "dependencies": {
11502
11502
  "ansi-regex": {
11503
- "version": "3.0.0",
11504
- "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz",
11505
- "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=",
11503
+ "version": "3.0.1",
11504
+ "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.1.tgz",
11505
+ "integrity": "sha512-+O9Jct8wf++lXxxFc4hc8LsjaSq0HFzzL7cVsw8pRDIPdjKD2mT4ytDZlLuSBZ4cLKZFXIrMGO7DbQCtMJJMKw==",
11506
11506
  "dev": true
11507
11507
  },
11508
11508
  "is-fullwidth-code-point": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "securemark",
3
- "version": "0.233.3",
3
+ "version": "0.234.2",
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",
@@ -8,7 +8,8 @@ export interface Ctx {
8
8
  export type Parser<T, C extends Ctx = Ctx, D extends Parser<unknown, C>[] = any>
9
9
  = (source: string, context: C) => Result<T, C, D>;
10
10
  export type Result<T, C extends Ctx = Ctx, D extends Parser<unknown, C>[] = any>
11
- = readonly [T[], string, C?, D?]
11
+ = readonly [T[], string, C, D]
12
+ | readonly [T[], string]
12
13
  | undefined;
13
14
  export type Tree<P extends Parser<unknown>> = P extends Parser<infer T> ? T : never;
14
15
  export type SubParsers<P extends Parser<unknown>> = P extends Parser<unknown, any, infer D> ? D : never;
@@ -53,10 +53,10 @@ describe('Unit: parser/api/parse', () => {
53
53
  ['<p>&lt;wbr&gt;<br>a</p>']);
54
54
  assert.deepStrictEqual(
55
55
  [...parse('[#\n<wbr>\n#]').children].map(el => el.outerHTML),
56
- ['<p><span class="comment">[# &lt;wbr&gt; #]</span></p>']);
56
+ ['<p><span class="comment"><input type="checkbox"><span>[#<br>&lt;wbr&gt;<br>#]</span></span></p>']);
57
57
  assert.deepStrictEqual(
58
58
  [...parse('[#\n<wbr>\n#]\na').children].map(el => el.outerHTML),
59
- ['<p><span class="comment">[# &lt;wbr&gt; #]</span><br>a</p>']);
59
+ ['<p><span class="comment"><input type="checkbox"><span>[#<br>&lt;wbr&gt;<br>#]</span></span><br>a</p>']);
60
60
  });
61
61
 
62
62
  it('linebreak', () => {
@@ -20,11 +20,19 @@ describe('Unit: parser/block/paragraph', () => {
20
20
  assert.deepStrictEqual(inspect(parser('a\\ \n')), [['<p>a</p>'], '']);
21
21
  assert.deepStrictEqual(inspect(parser('a\\\n')), [['<p>a</p>'], '']);
22
22
  assert.deepStrictEqual(inspect(parser('a\\\nb')), [['<p>a<span class="linebreak"> </span>b</p>'], '']);
23
+ assert.deepStrictEqual(inspect(parser('a&NewLine;b')), [['<p>a&amp;NewLine;b</p>'], '']);
24
+ assert.deepStrictEqual(inspect(parser('&Tab;&NewLine;')), [['<p>&amp;Tab;&amp;NewLine;</p>'], '']);
23
25
  assert.deepStrictEqual(inspect(parser('<wbr>')), [['<p>&lt;wbr&gt;</p>'], '']);
24
26
  assert.deepStrictEqual(inspect(parser('<wbr>\n')), [['<p>&lt;wbr&gt;</p>'], '']);
25
27
  assert.deepStrictEqual(inspect(parser('<wbr>\na')), [['<p>&lt;wbr&gt;<br>a</p>'], '']);
26
28
  assert.deepStrictEqual(inspect(parser('a\n<wbr>\n')), [['<p>a<br>&lt;wbr&gt;</p>'], '']);
27
29
  assert.deepStrictEqual(inspect(parser('a\n<wbr>\nb')), [['<p>a<br>&lt;wbr&gt;<br>b</p>'], '']);
30
+ assert.deepStrictEqual(inspect(parser('*a\n<wbr>*\nb')), [['<p>*a<br><wbr>*<br>b</p>'], '']);
31
+ assert.deepStrictEqual(inspect(parser('**a\n<wbr>**\nb')), [['<p>**a<br><wbr>**<br>b</p>'], '']);
32
+ assert.deepStrictEqual(inspect(parser('***a\n<wbr>***\nb')), [['<p>***a<br><wbr>***<br>b</p>'], '']);
33
+ assert.deepStrictEqual(inspect(parser('***a*b\n<wbr>**\nc')), [['<p>**<em>a</em>b<br><wbr>**<br>c</p>'], '']);
34
+ assert.deepStrictEqual(inspect(parser('***a**b\n<wbr>*\nc')), [['<p>*<strong>a</strong>b<br><wbr>*<br>c</p>'], '']);
35
+ assert.deepStrictEqual(inspect(parser('==a\n<wbr>==\nb')), [['<p>==a<br><wbr>==<br>b</p>'], '']);
28
36
  assert.deepStrictEqual(inspect(parser(' a')), [['<p>a</p>'], '']);
29
37
  });
30
38
 
@@ -47,13 +55,13 @@ describe('Unit: parser/block/paragraph', () => {
47
55
  });
48
56
 
49
57
  it('comment', () => {
50
- assert.deepStrictEqual(inspect(parser('[# a #]')), [['<p><span class="comment">[# a #]</span></p>'], '']);
51
- assert.deepStrictEqual(inspect(parser('[# a #]b')), [['<p><span class="comment">[# a #]</span>b</p>'], '']);
52
- assert.deepStrictEqual(inspect(parser('[# a #]\nb')), [['<p><span class="comment">[# a #]</span><br>b</p>'], '']);
53
- assert.deepStrictEqual(inspect(parser('[## a ##]')), [['<p><span class="comment">[## a ##]</span></p>'], '']);
54
- assert.deepStrictEqual(inspect(parser('[#\n<wbr>\n#]')), [['<p><span class="comment">[# &lt;wbr&gt; #]</span></p>'], '']);
55
- assert.deepStrictEqual(inspect(parser('[#\n<wbr>\n#]a')), [['<p><span class="comment">[# &lt;wbr&gt; #]</span>a</p>'], '']);
56
- assert.deepStrictEqual(inspect(parser('[#\n<wbr>\n#]\na')), [['<p><span class="comment">[# &lt;wbr&gt; #]</span><br>a</p>'], '']);
58
+ assert.deepStrictEqual(inspect(parser('[# a #]')), [['<p><span class="comment"><input type="checkbox"><span>[# a #]</span></span></p>'], '']);
59
+ assert.deepStrictEqual(inspect(parser('[# a #]b')), [['<p><span class="comment"><input type="checkbox"><span>[# a #]</span></span>b</p>'], '']);
60
+ assert.deepStrictEqual(inspect(parser('[# a #]\nb')), [['<p><span class="comment"><input type="checkbox"><span>[# a #]</span></span><br>b</p>'], '']);
61
+ assert.deepStrictEqual(inspect(parser('[## a ##]')), [['<p><span class="comment"><input type="checkbox"><span>[## a ##]</span></span></p>'], '']);
62
+ assert.deepStrictEqual(inspect(parser('[#\n<wbr>\n#]')), [['<p><span class="comment"><input type="checkbox"><span>[#<br>&lt;wbr&gt;<br>#]</span></span></p>'], '']);
63
+ assert.deepStrictEqual(inspect(parser('[#\n<wbr>\n#]a')), [['<p><span class="comment"><input type="checkbox"><span>[#<br>&lt;wbr&gt;<br>#]</span></span>a</p>'], '']);
64
+ assert.deepStrictEqual(inspect(parser('[#\n<wbr>\n#]\na')), [['<p><span class="comment"><input type="checkbox"><span>[#<br>&lt;wbr&gt;<br>#]</span></span><br>a</p>'], '']);
57
65
  });
58
66
 
59
67
  it('template', () => {
@@ -13,15 +13,14 @@ describe('Unit: parser/block/reply/cite', () => {
13
13
  assert.deepStrictEqual(inspect(parser('>\n')), undefined);
14
14
  assert.deepStrictEqual(inspect(parser('>>')), undefined);
15
15
  assert.deepStrictEqual(inspect(parser('>> ')), undefined);
16
- assert.deepStrictEqual(inspect(parser('>>0A')), undefined);
17
16
  assert.deepStrictEqual(inspect(parser('>>0 a')), undefined);
18
- assert.deepStrictEqual(inspect(parser('>>A')), undefined);
19
17
  assert.deepStrictEqual(inspect(parser('>>/')), undefined);
20
18
  assert.deepStrictEqual(inspect(parser('>>\\')), undefined);
21
19
  assert.deepStrictEqual(inspect(parser('>>01#')), undefined);
22
20
  assert.deepStrictEqual(inspect(parser('>>01@')), undefined);
23
21
  assert.deepStrictEqual(inspect(parser('>>https://host')), undefined);
24
22
  assert.deepStrictEqual(inspect(parser('>>tel:1234567890')), undefined);
23
+ assert.deepStrictEqual(inspect(parser('>>..')), undefined);
25
24
  assert.deepStrictEqual(inspect(parser('>> 0')), undefined);
26
25
  assert.deepStrictEqual(inspect(parser(' >>0')), undefined);
27
26
  assert.deepStrictEqual(inspect(parser('\\>>0')), undefined);
@@ -39,6 +38,7 @@ describe('Unit: parser/block/reply/cite', () => {
39
38
  assert.deepStrictEqual(inspect(parser('>>0\n>>>1')), [['<span class="cite">&gt;<a href="?at=0" class="anchor" data-depth="1">&gt;0</a></span>', '<br>', '<span class="cite">&gt;&gt;<a href="?at=1" class="anchor" data-depth="2">&gt;1</a></span>', '<br>'], '']);
40
39
  assert.deepStrictEqual(inspect(parser('>>>0\n>>')), [['<span class="cite">&gt;&gt;<a href="?at=0" class="anchor" data-depth="2">&gt;0</a></span>', '<br>'], '>>']);
41
40
  assert.deepStrictEqual(inspect(parser('>>>0\n>>1')), [['<span class="cite">&gt;&gt;<a href="?at=0" class="anchor" data-depth="2">&gt;0</a></span>', '<br>', '<span class="cite">&gt;<a href="?at=1" class="anchor" data-depth="1">&gt;1</a></span>', '<br>'], '']);
41
+ assert.deepStrictEqual(inspect(parser('>>.')), [['<span class="cite">&gt;<a class="anchor" data-depth="1">&gt;.</a></span>', '<br>'], '']);
42
42
  });
43
43
 
44
44
  });
@@ -1,5 +1,5 @@
1
1
  import { ReplyParser } from '../../block';
2
- import { tails, line, validate, creator, reverse, fmap } from '../../../combinator';
2
+ import { union, tails, line, validate, focus, creator, reverse, fmap } from '../../../combinator';
3
3
  import { anchor } from '../../inline/autolink/anchor';
4
4
  import { str } from '../../source';
5
5
  import { html, define, defrag } from 'typed-dom';
@@ -8,7 +8,12 @@ export const cite: ReplyParser.CiteParser = creator(line(fmap(validate(
8
8
  '>>',
9
9
  reverse(tails([
10
10
  str(/^>*(?=>>[^>\s]+[^\S\n]*(?:$|\n))/),
11
- anchor,
11
+ union([
12
+ anchor,
13
+ // Subject page representation.
14
+ // リンクの実装は後で検討
15
+ focus(/^>>\.[^\S\n]*(?:$|\n)/, () => [[html('a', { class: 'anchor' }, '>>.')], '']),
16
+ ]),
12
17
  ]))),
13
18
  ([el, quotes = '']: [HTMLElement, string?]) => [
14
19
  html('span', { class: 'cite' }, defrag([
@@ -9,6 +9,13 @@ import { visualize } from '../util';
9
9
  import { html, defrag } from 'typed-dom';
10
10
  import { push, pop } from 'spica/array';
11
11
 
12
+ /*
13
+ 必ず対象指定から始まる
14
+ 対象がページである場合>>.を表現方法とする
15
+ 対象をURLで指定すべき(引用ツリーにルートを追加する)場合はない
16
+ 対象と引用は1:N(分割)、N:1(統合)のみ可能、N:N(混合)は不可能
17
+ */
18
+
12
19
  export const reply: ReplyParser = block(validate('>', localize(fmap(
13
20
  inits([
14
21
  some(inits([
@@ -17,10 +24,9 @@ export const reply: ReplyParser = block(validate('>', localize(fmap(
17
24
  ])),
18
25
  some(subsequence([
19
26
  some(quote),
20
- fmap(
21
- rewrite(
22
- some(anyline, delimiter),
23
- trim(visualize(some(inline)))),
27
+ fmap(rewrite(
28
+ some(anyline, delimiter),
29
+ trim(visualize(some(inline)))),
24
30
  ns => push(ns, [html('br')])),
25
31
  ])),
26
32
  ]),
@@ -10,8 +10,6 @@ describe('Unit: parser/inline/autolink/anchor', () => {
10
10
  assert.deepStrictEqual(inspect(parser('')), undefined);
11
11
  assert.deepStrictEqual(inspect(parser('>')), undefined);
12
12
  assert.deepStrictEqual(inspect(parser('>>')), undefined);
13
- assert.deepStrictEqual(inspect(parser('>>0A')), undefined);
14
- assert.deepStrictEqual(inspect(parser('>>A')), undefined);
15
13
  assert.deepStrictEqual(inspect(parser('>>-0')), undefined);
16
14
  assert.deepStrictEqual(inspect(parser('>>01#')), undefined);
17
15
  assert.deepStrictEqual(inspect(parser('>>01@')), undefined);
@@ -24,10 +22,13 @@ describe('Unit: parser/inline/autolink/anchor', () => {
24
22
  it('valid', () => {
25
23
  assert.deepStrictEqual(inspect(parser('>>0')), [['<a href="?at=0" class="anchor">&gt;&gt;0</a>'], '']);
26
24
  assert.deepStrictEqual(inspect(parser('>>a')), [['<a href="?at=a" class="anchor">&gt;&gt;a</a>'], '']);
25
+ assert.deepStrictEqual(inspect(parser('>>A')), [['<a href="?at=A" class="anchor">&gt;&gt;A</a>'], '']);
27
26
  assert.deepStrictEqual(inspect(parser('>>0-')), [['<a href="?at=0" class="anchor">&gt;&gt;0</a>'], '-']);
28
27
  assert.deepStrictEqual(inspect(parser('>>0-a')), [['<a href="?at=0-a" class="anchor">&gt;&gt;0-a</a>'], '']);
29
- assert.deepStrictEqual(inspect(parser('>>0-A')), [['<a href="?at=0" class="anchor">&gt;&gt;0</a>'], '-A']);
28
+ assert.deepStrictEqual(inspect(parser('>>0-A')), [['<a href="?at=0-A" class="anchor">&gt;&gt;0-A</a>'], '']);
30
29
  assert.deepStrictEqual(inspect(parser('>>0--a')), [['<a href="?at=0" class="anchor">&gt;&gt;0</a>'], '--a']);
30
+ assert.deepStrictEqual(inspect(parser('>>2000-01-31-23-59-59-999-JST')), [['<a href="?at=2000-01-31-23-59-59-999-JST" class="anchor">&gt;&gt;2000-01-31-23-59-59-999-JST</a>'], '']);
31
+ assert.deepStrictEqual(inspect(parser('>>A/2000-01-31-23-59-59-JST')), [['<a href="/@A/timeline/2000-01-31-23-59-59-JST" class="anchor">&gt;&gt;A/2000-01-31-23-59-59-JST</a>'], '']);
31
32
  });
32
33
 
33
34
  });