securemark 0.248.0 → 0.248.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.248.1
4
+
5
+ - Fix html parser.
6
+
3
7
  ## 0.248.0
4
8
 
5
9
  - Change html parser not to limit nesting patterns of HTML tags.
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! securemark v0.248.0 https://github.com/falsandtru/securemark | (c) 2017, falsandtru | UNLICENSED License */
1
+ /*! securemark v0.248.1 https://github.com/falsandtru/securemark | (c) 2017, falsandtru | UNLICENSED License */
2
2
  (function webpackUniversalModuleDefinition(root, factory) {
3
3
  if(typeof exports === 'object' && typeof module === 'object')
4
4
  module.exports = factory(require("DOMPurify"), require("Prism"));
@@ -2254,11 +2254,9 @@ const surround_1 = __webpack_require__(7130);
2254
2254
 
2255
2255
  const memoize_1 = __webpack_require__(1808);
2256
2256
 
2257
- const array_1 = __webpack_require__(8112);
2258
-
2259
2257
  function indent(parser, separation = false) {
2260
2258
  return (0, bind_1.bind)((0, block_1.block)((0, match_1.match)(/^(?=(([ \t])\2*))/, (0, memoize_1.memoize)(([, indent]) => (0, some_1.some)((0, line_1.line)((0, surround_1.open)(indent, source => [[unline(source)], '']))), ([, indent]) => indent.length * 2 + +(indent[0] === ' '), [])), separation), (nodes, rest, context) => {
2261
- const result = parser((0, array_1.join)(nodes, '\n'), context);
2259
+ const result = parser(nodes.join('\n'), context);
2262
2260
  return result && (0, parser_1.exec)(result) === '' ? [(0, parser_1.eval)(result), rest] : global_1.undefined;
2263
2261
  });
2264
2262
  }
@@ -5914,8 +5912,6 @@ const util_1 = __webpack_require__(9437);
5914
5912
 
5915
5913
  const dom_1 = __webpack_require__(3252);
5916
5914
 
5917
- const array_1 = __webpack_require__(8112);
5918
-
5919
5915
  exports.index = (0, combinator_1.lazy)(() => (0, combinator_1.creator)((0, combinator_1.validate)('[#', ']', '\n', (0, combinator_1.fmap)((0, indexee_1.indexee)((0, combinator_1.fmap)((0, combinator_1.surround)('[#', (0, combinator_1.guard)(context => context.syntax?.inline?.index ?? true, (0, util_1.startTight)((0, combinator_1.context)({
5920
5916
  syntax: {
5921
5917
  inline: {
@@ -5935,7 +5931,7 @@ exports.index = (0, combinator_1.lazy)(() => (0, combinator_1.creator)((0, combi
5935
5931
  }, el.childNodes)]))));
5936
5932
  const signature = (0, combinator_1.lazy)(() => (0, combinator_1.creator)((0, combinator_1.fmap)((0, combinator_1.open)('|#', (0, util_1.startTight)((0, combinator_1.some)((0, combinator_1.union)([bracket, source_1.txt]), ']'))), ns => [(0, dom_1.html)('span', {
5937
5933
  class: 'indexer',
5938
- 'data-index': (0, indexee_1.identity)((0, array_1.join)(ns)).slice(6)
5934
+ 'data-index': (0, indexee_1.identity)(ns.join('')).slice(6)
5939
5935
  })])));
5940
5936
  const bracket = (0, combinator_1.lazy)(() => (0, combinator_1.creator)((0, combinator_1.union)([(0, combinator_1.surround)((0, source_1.str)('('), (0, combinator_1.some)((0, combinator_1.union)([bracket, source_1.txt]), ')'), (0, source_1.str)(')'), true), (0, combinator_1.surround)((0, source_1.str)('['), (0, combinator_1.some)((0, combinator_1.union)([bracket, source_1.txt]), ']'), (0, source_1.str)(']'), true), (0, combinator_1.surround)((0, source_1.str)('{'), (0, combinator_1.some)((0, combinator_1.union)([bracket, source_1.txt]), '}'), (0, source_1.str)('}'), true), (0, combinator_1.surround)((0, source_1.str)('"'), (0, combinator_1.some)(source_1.txt, '"'), (0, source_1.str)('"'), true)])));
5941
5937
 
@@ -6075,8 +6071,6 @@ const source_1 = __webpack_require__(6743);
6075
6071
 
6076
6072
  const dom_1 = __webpack_require__(3252);
6077
6073
 
6078
- const array_1 = __webpack_require__(8112);
6079
-
6080
6074
  const body = (0, source_1.str)(/^\$[A-Za-z]*(?:(?:-[A-Za-z][0-9A-Za-z]*)+|-(?:(?:0|[1-9][0-9]*)\.)*(?:0|[1-9][0-9]*)(?![0-9A-Za-z]))/);
6081
6075
  exports.segment = (0, combinator_1.clear)((0, combinator_1.validate)(['[$', '$'], (0, combinator_1.union)([(0, combinator_1.surround)('[', body, ']'), body])));
6082
6076
  exports.label = (0, combinator_1.creator)((0, combinator_1.validate)(['[$', '$'], (0, combinator_1.fmap)((0, combinator_1.guard)(context => context.syntax?.inline?.label ?? true, (0, combinator_1.union)([(0, combinator_1.surround)('[', body, ']'), body])), ([text]) => [(0, dom_1.html)('a', {
@@ -6105,7 +6099,7 @@ function increment(number, position) {
6105
6099
  ms[i] = i < ns.length ? i + 1 < position ? +ns[i] : +ns[i] + 1 : i + 1 < position ? 0 : 1;
6106
6100
  }
6107
6101
 
6108
- return (0, array_1.join)(ms, '.');
6102
+ return ms.join('.');
6109
6103
  }
6110
6104
 
6111
6105
  /***/ }),
@@ -6183,7 +6177,7 @@ const attrspec = {
6183
6177
  };
6184
6178
  Object.setPrototypeOf(attrspec, null);
6185
6179
  Object.values(attrspec).forEach(o => Object.setPrototypeOf(o, null));
6186
- exports.html = (0, combinator_1.lazy)(() => (0, combinator_1.creator)((0, combinator_1.validate)('<', (0, combinator_1.validate)(/^<[a-z]+(?=[^\S\n]|>)/, (0, combinator_1.union)([(0, combinator_1.match)(/^(?=<(wbr)(?=[^\S\n]|>))/, (0, memoize_1.memoize)(([, tag]) => (0, combinator_1.surround)(`<${tag}`, (0, combinator_1.some)((0, combinator_1.union)([exports.attribute])), /^\s*>/, true, ([, bs = []], rest) => [[(0, dom_1.html)(tag, attributes('html', [], attrspec[tag], bs))], rest]), ([, tag]) => tags.indexOf(tag), [])), (0, combinator_1.match)(/^(?=<(sup|sub|small|bdo|bdi)(?=[^\S\n]|>))/, (0, memoize_1.memoize)(([, tag]) => (0, combinator_1.validate)(`<${tag}`, `</${tag}>`, (0, combinator_1.surround)((0, combinator_1.surround)((0, source_1.str)(`<${tag}`), (0, combinator_1.some)(exports.attribute), (0, source_1.str)(/^\s*>/), true), (0, util_1.startLoose)((0, combinator_1.some)((0, combinator_1.union)([(0, combinator_1.some)(inline_1.inline, (0, util_1.blank)(/\n/, `</${tag}>`)), (0, combinator_1.open)(/^\n/, (0, combinator_1.some)(inline_1.inline, `</${tag}>`), true)]), `</${tag}>`), `</${tag}>`), (0, source_1.str)(`</${tag}>`), false, ([as, bs, cs], rest) => [[elem(tag, as, (0, dom_1.defrag)(bs), cs)], rest], ([as, bs], rest) => as.length === 1 ? [(0, array_1.unshift)(as, bs), rest] : global_1.undefined)), ([, tag]) => tags.indexOf(tag), [])), (0, combinator_1.match)(/^(?=<([a-z]+)(?=[^\S\n]|>))/, (0, memoize_1.memoize)(([, tag]) => (0, combinator_1.validate)(`<${tag}`, `</${tag}>`, (0, combinator_1.surround)((0, combinator_1.surround)((0, source_1.str)(`<${tag}`), (0, combinator_1.some)(exports.attribute), (0, source_1.str)(/^\s*>/), true), (0, util_1.startLoose)((0, combinator_1.some)((0, combinator_1.union)([(0, combinator_1.some)(inline_1.inline, (0, util_1.blank)(/\n/, `</${tag}>`)), (0, combinator_1.open)(/^\n/, (0, combinator_1.some)(inline_1.inline, `</${tag}>`), true)]), `</${tag}>`), `</${tag}>`), (0, source_1.str)(`</${tag}>`), false, ([as, bs, cs], rest) => [[elem(tag, as, (0, dom_1.defrag)(bs), cs)], rest], ([as, bs], rest) => as.length === 1 ? [(0, array_1.unshift)(as, bs), rest] : global_1.undefined)), ([, tag]) => tag, new cache_1.Cache(10000)))])))));
6180
+ exports.html = (0, combinator_1.lazy)(() => (0, combinator_1.creator)((0, combinator_1.validate)('<', (0, combinator_1.validate)(/^<[a-z]+(?=[^\S\n]|>)/, (0, combinator_1.union)([(0, combinator_1.match)(/^(?=<(wbr)(?=[^\S\n]|>))/, (0, memoize_1.memoize)(([, tag]) => (0, combinator_1.surround)(`<${tag}`, (0, combinator_1.some)((0, combinator_1.union)([exports.attribute])), /^\s*>/, true, ([, bs = []], rest) => [[(0, dom_1.html)(tag, attributes('html', [], attrspec[tag], bs))], rest]), ([, tag]) => tags.indexOf(tag), [])), (0, combinator_1.match)(/^(?=<(sup|sub|small|bdo|bdi)(?=[^\S\n]|>))/, (0, memoize_1.memoize)(([, tag]) => (0, combinator_1.surround)((0, combinator_1.surround)((0, source_1.str)(`<${tag}`), (0, combinator_1.some)(exports.attribute), (0, source_1.str)(/^\s*>/), true), (0, util_1.startLoose)((0, combinator_1.some)((0, combinator_1.union)([(0, combinator_1.some)(inline_1.inline, (0, util_1.blank)(/\n/, `</${tag}>`)), (0, combinator_1.open)(/^\n/, (0, combinator_1.some)(inline_1.inline, `</${tag}>`), true)]), `</${tag}>`), `</${tag}>`), (0, source_1.str)(`</${tag}>`), false, ([as, bs, cs], rest) => [[elem(tag, as, (0, dom_1.defrag)(bs), cs)], rest]), ([, tag]) => tags.indexOf(tag), [])), (0, combinator_1.match)(/^(?=<([a-z]+)(?=[^\S\n]|>))/, (0, memoize_1.memoize)(([, tag]) => (0, combinator_1.surround)((0, combinator_1.surround)((0, source_1.str)(`<${tag}`), (0, combinator_1.some)(exports.attribute), (0, source_1.str)(/^\s*>/), true), (0, util_1.startLoose)((0, combinator_1.some)((0, combinator_1.union)([(0, combinator_1.some)(inline_1.inline, (0, util_1.blank)(/\n/, `</${tag}>`)), (0, combinator_1.open)(/^\n/, (0, combinator_1.some)(inline_1.inline, `</${tag}>`), true)]), `</${tag}>`), `</${tag}>`), (0, source_1.str)(`</${tag}>`), false, ([as, bs, cs], rest) => [[elem(tag, as, (0, dom_1.defrag)(bs), cs)], rest]), ([, tag]) => tag, new cache_1.Cache(10000)))])))));
6187
6181
  exports.attribute = (0, combinator_1.union)([(0, source_1.str)(/^[^\S\n]+[a-z]+(?:-[a-z]+)*(?:="(?:\\[^\n]|[^\\\n"])*")?(?=[^\S\n]|>)/)]);
6188
6182
 
6189
6183
  function elem(tag, as, bs, cs) {
@@ -6220,7 +6214,7 @@ function attributes(syntax, classes, spec, params) {
6220
6214
  invalid ||= !!spec && !requiredAttributes(spec).every(name => name in attrs);
6221
6215
 
6222
6216
  if (invalid) {
6223
- attrs['class'] = (0, array_1.join)(classes.includes('invalid') ? classes : (0, array_1.unshift)(classes, ['invalid']), ' ');
6217
+ attrs['class'] = (classes.includes('invalid') ? classes : (0, array_1.unshift)(classes, ['invalid'])).join(' ');
6224
6218
  attrs['data-invalid-syntax'] = syntax;
6225
6219
  attrs['data-invalid-type'] = 'argument';
6226
6220
  attrs['data-invalid-message'] = 'Invalid argument';
@@ -6537,7 +6531,7 @@ const optspec = {
6537
6531
  rel: global_1.undefined
6538
6532
  };
6539
6533
  Object.setPrototypeOf(optspec, null);
6540
- exports.media = (0, combinator_1.lazy)(() => (0, combinator_1.creator)(10, (0, combinator_1.validate)(['![', '!{'], '}', '\n', (0, combinator_1.bind)((0, combinator_1.verify)((0, combinator_1.fmap)((0, combinator_1.open)('!', (0, combinator_1.guard)(context => context.syntax?.inline?.media ?? true, (0, combinator_1.tails)([(0, combinator_1.dup)((0, combinator_1.surround)(/^\[(?!\s*\\\s)/, (0, combinator_1.some)((0, combinator_1.union)([htmlentity_1.unsafehtmlentity, bracket, source_1.txt]), ']', /^\\?\n/), ']', true)), (0, combinator_1.dup)((0, combinator_1.surround)(/^{(?![{}])/, (0, combinator_1.inits)([link_1.uri, (0, combinator_1.some)(option)]), /^[^\S\n]*}/))]))), ([as, bs]) => bs ? [[(0, array_1.join)(as).trim() || (0, array_1.join)(as)], bs] : [[''], as]), ([[text]]) => text === '' || text.trim() !== ''), ([[text], params], rest, context) => {
6534
+ exports.media = (0, combinator_1.lazy)(() => (0, combinator_1.creator)(10, (0, combinator_1.validate)(['![', '!{'], '}', '\n', (0, combinator_1.bind)((0, combinator_1.verify)((0, combinator_1.fmap)((0, combinator_1.open)('!', (0, combinator_1.guard)(context => context.syntax?.inline?.media ?? true, (0, combinator_1.tails)([(0, combinator_1.dup)((0, combinator_1.surround)(/^\[(?!\s*\\\s)/, (0, combinator_1.some)((0, combinator_1.union)([htmlentity_1.unsafehtmlentity, bracket, source_1.txt]), ']', /^\\?\n/), ']', true)), (0, combinator_1.dup)((0, combinator_1.surround)(/^{(?![{}])/, (0, combinator_1.inits)([link_1.uri, (0, combinator_1.some)(option)]), /^[^\S\n]*}/))]))), ([as, bs]) => bs ? [[as.join('').trim() || as.join('')], bs] : [[''], as]), ([[text]]) => text === '' || text.trim() !== ''), ([[text], params], rest, context) => {
6541
6535
  const INSECURE_URI = params.shift();
6542
6536
  const url = new url_1.ReadonlyURL((0, link_1.resolve)(INSECURE_URI, context.host ?? global_1.location, context.url ?? context.host ?? global_1.location), context.host?.href || global_1.location.href);
6543
6537
  let cache;
@@ -6552,7 +6546,7 @@ exports.media = (0, combinator_1.lazy)(() => (0, combinator_1.creator)(10, (0, c
6552
6546
  if (context.syntax?.inline?.link === false || cache && cache.tagName !== 'IMG') return [[el], rest];
6553
6547
  return (0, combinator_1.fmap)(link_1.link, ([link]) => [(0, dom_1.define)(link, {
6554
6548
  target: '_blank'
6555
- }, [el])])(`{ ${INSECURE_URI}${(0, array_1.join)(params)} }${rest}`, context);
6549
+ }, [el])])(`{ ${INSECURE_URI}${params.join('')} }${rest}`, context);
6556
6550
  }))));
6557
6551
  const bracket = (0, combinator_1.lazy)(() => (0, combinator_1.union)([(0, combinator_1.surround)((0, source_1.str)('('), (0, combinator_1.some)((0, combinator_1.union)([htmlentity_1.unsafehtmlentity, bracket, source_1.txt]), ')'), (0, source_1.str)(')'), true, global_1.undefined, ([as, bs = []], rest) => [(0, array_1.unshift)(as, bs), rest]), (0, combinator_1.surround)((0, source_1.str)('['), (0, combinator_1.some)((0, combinator_1.union)([htmlentity_1.unsafehtmlentity, bracket, source_1.txt]), ']'), (0, source_1.str)(']'), true, global_1.undefined, ([as, bs = []], rest) => [(0, array_1.unshift)(as, bs), rest]), (0, combinator_1.surround)((0, source_1.str)('{'), (0, combinator_1.some)((0, combinator_1.union)([htmlentity_1.unsafehtmlentity, bracket, source_1.txt]), '}'), (0, source_1.str)('}'), true, global_1.undefined, ([as, bs = []], rest) => [(0, array_1.unshift)(as, bs), rest]), (0, combinator_1.surround)((0, source_1.str)('"'), (0, combinator_1.some)((0, combinator_1.union)([htmlentity_1.unsafehtmlentity, source_1.txt]), '"'), (0, source_1.str)('"'), true)]));
6558
6552
  const option = (0, combinator_1.union)([(0, combinator_1.fmap)((0, source_1.str)(/^[^\S\n]+[1-9][0-9]*x[1-9][0-9]*(?=[^\S\n]|})/), ([opt]) => [` width="${opt.slice(1).split('x')[0]}"`, ` height="${opt.slice(1).split('x')[1]}"`]), (0, combinator_1.fmap)((0, source_1.str)(/^[^\S\n]+[1-9][0-9]*:[1-9][0-9]*(?=[^\S\n]|})/), ([opt]) => [` aspect-ratio="${opt.slice(1).split(':').join('/')}"`]), link_1.option]);
@@ -6694,7 +6688,7 @@ exports.ruby = (0, combinator_1.lazy)(() => (0, combinator_1.creator)((0, combin
6694
6688
  return [[(0, dom_1.html)('ruby', attributes(texts, rubies), (0, dom_1.defrag)((0, array_1.push)([...texts[0]].reduce((acc, _, i, texts) => (0, array_1.push)(acc, (0, array_1.unshift)([texts[i]], i < rubies.length && rubies[i] ? [(0, dom_1.html)('rp', '('), (0, dom_1.html)('rt', rubies[i]), (0, dom_1.html)('rp', ')')] : [(0, dom_1.html)('rt')])), []), tail)))], rest];
6695
6689
 
6696
6690
  default:
6697
- return [[(0, dom_1.html)('ruby', attributes(texts, rubies), (0, dom_1.defrag)((0, array_1.push)((0, array_1.unshift)([(0, array_1.join)(texts, ' ')], [(0, dom_1.html)('rp', '('), (0, dom_1.html)('rt', (0, array_1.join)(rubies, ' ').trim()), (0, dom_1.html)('rp', ')')]), tail)))], rest];
6691
+ return [[(0, dom_1.html)('ruby', attributes(texts, rubies), (0, dom_1.defrag)((0, array_1.push)((0, array_1.unshift)([texts.join(' ')], [(0, dom_1.html)('rp', '('), (0, dom_1.html)('rt', rubies.join(' ').trim()), (0, dom_1.html)('rp', ')')]), tail)))], rest];
6698
6692
  }
6699
6693
  }))));
6700
6694
  const text = (0, combinator_1.creator)((source, context) => {
@@ -6731,7 +6725,7 @@ const text = (0, combinator_1.creator)((source, context) => {
6731
6725
  }
6732
6726
  }
6733
6727
 
6734
- return (0, array_1.join)(acc).trimStart() ? [[acc], ''] : global_1.undefined;
6728
+ return acc.join('').trimStart() ? [[acc], ''] : global_1.undefined;
6735
6729
  });
6736
6730
 
6737
6731
  function attributes(texts, rubies) {
@@ -7026,16 +7020,16 @@ function* figure(target, footnotes, opts = {}) {
7026
7020
  }
7027
7021
 
7028
7022
  const group = label.split('-', 1)[0];
7029
- let number = (0, label_1.number)(label, numbers.has(group) && !(0, label_1.isFixed)(label) ? (0, array_1.join)(numbers.get(group).split('.').slice(0, bases.length), '.') : base);
7023
+ let number = (0, label_1.number)(label, numbers.has(group) && !(0, label_1.isFixed)(label) ? numbers.get(group).split('.').slice(0, bases.length).join('.') : base);
7030
7024
 
7031
7025
  if (number.endsWith('.0')) {
7032
7026
  if (group !== '$' || tagName === 'FIGURE' && def.firstChild) continue;
7033
7027
 
7034
7028
  if (number.startsWith('0.')) {
7035
- number = (0, array_1.join)(index.slice(0).reduce((ns, _, i, xs) => {
7029
+ number = index.slice(0).reduce((ns, _, i, xs) => {
7036
7030
  i === ns.length ? xs.length = i : ns[i] = +ns[i] > +xs[i] ? ns[i] : +ns[i] === 0 ? xs[i] : `${+xs[i] + 1}`;
7037
7031
  return ns;
7038
- }, number.split('.')), '.');
7032
+ }, number.split('.')).join('.');
7039
7033
  }
7040
7034
 
7041
7035
  base = number;
@@ -7114,7 +7108,7 @@ const messages = {
7114
7108
 
7115
7109
  function increment(bases, el) {
7116
7110
  const index = (+el.tagName[1] - 1 || 1) - 1;
7117
- return index + 1 < bases.length ? (0, array_1.join)(bases.slice(0, index + 2).map((v, i) => {
7111
+ return index + 1 < bases.length ? bases.slice(0, index + 2).map((v, i) => {
7118
7112
  switch (true) {
7119
7113
  case i < index:
7120
7114
  return v;
@@ -7125,7 +7119,7 @@ function increment(bases, el) {
7125
7119
  default:
7126
7120
  return 0;
7127
7121
  }
7128
- }), '.') : '';
7122
+ }).join('.') : '';
7129
7123
  }
7130
7124
 
7131
7125
  function capitalize(label) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "securemark",
3
- "version": "0.248.0",
3
+ "version": "0.248.1",
4
4
  "description": "Secure markdown renderer working on browsers for user input data.",
5
5
  "private": false,
6
6
  "homepage": "https://github.com/falsandtru/securemark",
@@ -7,7 +7,6 @@ import { bind } from '../monad/bind';
7
7
  import { match } from './match';
8
8
  import { open } from './surround';
9
9
  import { memoize } from 'spica/memoize';
10
- import { join } from 'spica/array';
11
10
 
12
11
  export function indent<P extends Parser<unknown>>(parser: P, separation?: boolean): P;
13
12
  export function indent<T>(parser: Parser<T>, separation = false): Parser<T> {
@@ -19,7 +18,7 @@ export function indent<T>(parser: Parser<T>, separation = false): Parser<T> {
19
18
  some(line(open(indent, source => [[unline(source)], '']))),
20
19
  ([, indent]) => indent.length * 2 + +(indent[0] === ' '), [])), separation),
21
20
  (nodes, rest, context) => {
22
- const result = parser(join(nodes, '\n'), context);
21
+ const result = parser(nodes.join('\n'), context);
23
22
  return result && exec(result) === ''
24
23
  ? [eval(result), rest]
25
24
  : undefined;
@@ -6,7 +6,6 @@ import { indexee, identity } from './indexee';
6
6
  import { txt, str, stropt } from '../../source';
7
7
  import { startTight, trimNodeEnd } from '../../util';
8
8
  import { html, define, defrag } from 'typed-dom/dom';
9
- import { join } from 'spica/array';
10
9
 
11
10
  import IndexParser = ExtensionParser.IndexParser;
12
11
 
@@ -44,7 +43,7 @@ const signature: IndexParser.SignatureParser = lazy(() => creator(fmap(open(
44
43
  '|#',
45
44
  startTight(some(union([bracket, txt]), ']'))),
46
45
  ns => [
47
- html('span', { class: 'indexer', 'data-index': identity(join(ns)).slice(6) }),
46
+ html('span', { class: 'indexer', 'data-index': identity(ns.join('')).slice(6) }),
48
47
  ])));
49
48
 
50
49
  const bracket: IndexParser.SignatureParser.BracketParser = lazy(() => creator(union([
@@ -3,7 +3,6 @@ import { ExtensionParser } from '../../inline';
3
3
  import { union, validate, guard, creator, surround, clear, fmap } from '../../../combinator';
4
4
  import { str } from '../../source';
5
5
  import { html } from 'typed-dom/dom';
6
- import { join } from 'spica/array';
7
6
 
8
7
  const body = str(/^\$[A-Za-z]*(?:(?:-[A-Za-z][0-9A-Za-z]*)+|-(?:(?:0|[1-9][0-9]*)\.)*(?:0|[1-9][0-9]*)(?![0-9A-Za-z]))/);
9
8
 
@@ -48,5 +47,5 @@ function increment(number: string, position: number): string {
48
47
  ? 0
49
48
  : 1;
50
49
  }
51
- return join(ms, '.');
50
+ return ms.join('.');
52
51
  }
@@ -8,7 +8,7 @@ import { startLoose, blank } from '../util';
8
8
  import { html as h, defrag } from 'typed-dom/dom';
9
9
  import { memoize } from 'spica/memoize';
10
10
  import { Cache } from 'spica/cache';
11
- import { unshift, push, splice, join } from 'spica/array';
11
+ import { unshift, push, splice } from 'spica/array';
12
12
 
13
13
  const tags = Object.freeze(['wbr', 'sup', 'sub', 'small', 'bdo', 'bdi']);
14
14
  const attrspec = {
@@ -33,7 +33,6 @@ export const html: HTMLParser = lazy(() => creator(validate('<', validate(/^<[a-
33
33
  /^(?=<(sup|sub|small|bdo|bdi)(?=[^\S\n]|>))/,
34
34
  memoize(
35
35
  ([, tag]) =>
36
- validate(`<${tag}`, `</${tag}>`,
37
36
  surround<HTMLParser.TagParser, string>(surround(
38
37
  str(`<${tag}`), some(attribute), str(/^\s*>/), true),
39
38
  startLoose(some(union([
@@ -42,15 +41,12 @@ export const html: HTMLParser = lazy(() => creator(validate('<', validate(/^<[a-
42
41
  ]), `</${tag}>`), `</${tag}>`),
43
42
  str(`</${tag}>`), false,
44
43
  ([as, bs, cs], rest) =>
45
- [[elem(tag, as, defrag(bs), cs)], rest],
46
- ([as, bs], rest) =>
47
- as.length === 1 ? [unshift(as, bs), rest] : undefined)),
44
+ [[elem(tag, as, defrag(bs), cs)], rest]),
48
45
  ([, tag]) => tags.indexOf(tag), [])),
49
46
  match(
50
47
  /^(?=<([a-z]+)(?=[^\S\n]|>))/,
51
48
  memoize(
52
49
  ([, tag]) =>
53
- validate(`<${tag}`, `</${tag}>`,
54
50
  surround<HTMLParser.TagParser, string>(surround(
55
51
  str(`<${tag}`), some(attribute), str(/^\s*>/), true),
56
52
  startLoose(some(union([
@@ -59,9 +55,7 @@ export const html: HTMLParser = lazy(() => creator(validate('<', validate(/^<[a-
59
55
  ]), `</${tag}>`), `</${tag}>`),
60
56
  str(`</${tag}>`), false,
61
57
  ([as, bs, cs], rest) =>
62
- [[elem(tag, as, defrag(bs), cs)], rest],
63
- ([as, bs], rest) =>
64
- as.length === 1 ? [unshift(as, bs), rest] : undefined)),
58
+ [[elem(tag, as, defrag(bs), cs)], rest]),
65
59
  ([, tag]) => tag,
66
60
  new Cache(10000))),
67
61
  ])))));
@@ -122,7 +116,7 @@ export function attributes(
122
116
  }
123
117
  invalid ||= !!spec && !requiredAttributes(spec).every(name => name in attrs);
124
118
  if (invalid) {
125
- attrs['class'] = join(classes.includes('invalid') ? classes : unshift(classes, ['invalid']), ' ');
119
+ attrs['class'] = (classes.includes('invalid') ? classes : unshift(classes, ['invalid'])).join(' ');
126
120
  attrs['data-invalid-syntax'] = syntax;
127
121
  attrs['data-invalid-type'] = 'argument';
128
122
  attrs['data-invalid-message'] = 'Invalid argument';
@@ -7,7 +7,7 @@ import { unsafehtmlentity } from './htmlentity';
7
7
  import { txt, str } from '../source';
8
8
  import { html, define } from 'typed-dom/dom';
9
9
  import { ReadonlyURL } from 'spica/url';
10
- import { unshift, push, join } from 'spica/array';
10
+ import { unshift, push } from 'spica/array';
11
11
 
12
12
  const optspec = {
13
13
  'width': [],
@@ -28,7 +28,7 @@ export const media: MediaParser = lazy(() => creator(10, validate(['![', '!{'],
28
28
  true)),
29
29
  dup(surround(/^{(?![{}])/, inits([uri, some(option)]), /^[^\S\n]*}/)),
30
30
  ]))),
31
- ([as, bs]) => bs ? [[join(as).trim() || join(as)], bs] : [[''], as]),
31
+ ([as, bs]) => bs ? [[as.join('').trim() || as.join('')], bs] : [[''], as]),
32
32
  ([[text]]) => text === '' || text.trim() !== ''),
33
33
  ([[text], params], rest, context) => {
34
34
  assert(text === text.trim());
@@ -52,7 +52,7 @@ export const media: MediaParser = lazy(() => creator(10, validate(['![', '!{'],
52
52
  return fmap(
53
53
  link as MediaParser,
54
54
  ([link]) => [define(link, { target: '_blank' }, [el])])
55
- (`{ ${INSECURE_URI}${join(params)} }${rest}`, context);
55
+ (`{ ${INSECURE_URI}${params.join('')} }${rest}`, context);
56
56
  }))));
57
57
 
58
58
  const bracket: MediaParser.TextParser.BracketParser = lazy(() => union([
@@ -6,7 +6,7 @@ import { unsafehtmlentity } from './htmlentity';
6
6
  import { text as txt } from '../source';
7
7
  import { isStartTightNodes } from '../util';
8
8
  import { html, defrag } from 'typed-dom/dom';
9
- import { unshift, push, join } from 'spica/array';
9
+ import { unshift, push } from 'spica/array';
10
10
 
11
11
  export const ruby: RubyParser = lazy(() => creator(validate('[', ')', '\n', bind(verify(
12
12
  sequence([
@@ -39,8 +39,8 @@ export const ruby: RubyParser = lazy(() => creator(validate('[', ')', '\n', bind
39
39
  default:
40
40
  assert(rubies.length > 0);
41
41
  return [[html('ruby', attributes(texts, rubies), defrag(push(unshift(
42
- [join(texts, ' ')],
43
- [html('rp', '('), html('rt', join(rubies, ' ').trim()), html('rp', ')')]), tail)))
42
+ [texts.join(' ')],
43
+ [html('rp', '('), html('rt', rubies.join(' ').trim()), html('rp', ')')]), tail)))
44
44
  ], rest];
45
45
  }
46
46
  }))));
@@ -74,7 +74,7 @@ const text: RubyParser.TextParser = creator((source, context) => {
74
74
  }
75
75
  }
76
76
  }
77
- return join(acc).trimStart()
77
+ return acc.join('').trimStart()
78
78
  ? [[acc], '']
79
79
  : undefined;
80
80
  });
@@ -157,6 +157,7 @@ describe('Unit: parser/inline', () => {
157
157
  assert.deepStrictEqual(inspect(parser('<http://host>')), [['<', '<a href="http://host" target="_blank">http://host</a>', '>'], '']);
158
158
  assert.deepStrictEqual(inspect(parser('<<small>a<</small>')), [['<', '<small>a&lt;</small>'], '']);
159
159
  assert.deepStrictEqual(inspect(parser('<sup><sub>a</sub>')), [['<', 'sup', '>', '<sub>a</sub>'], '']);
160
+ assert.deepStrictEqual(inspect(parser('*<small>*`</small>`')), [['<em>&lt;small&gt;</em>', '<code data-src="`</small>`">&lt;/small&gt;</code>'], '']);
160
161
  assert.deepStrictEqual(inspect(parser('[~http://host')), [['[', '~', '<a href="http://host" target="_blank">http://host</a>'], '']);
161
162
  assert.deepStrictEqual(inspect(parser('[~a@b')), [['[', '~', '<a class="email" href="mailto:a@b">a@b</a>'], '']);
162
163
  assert.deepStrictEqual(inspect(parser('[~~a~~]')), [['[', '<del>a</del>', ']'], '']);
@@ -2,7 +2,7 @@ import { Infinity, Set, Map } from 'spica/global';
2
2
  import { number as calculate, isFixed } from '../inline/extension/label';
3
3
  import { define } from 'typed-dom/dom';
4
4
  import { MultiMap } from 'spica/multimap';
5
- import { push, join } from 'spica/array';
5
+ import { push } from 'spica/array';
6
6
 
7
7
  export function* figure(
8
8
  target: ParentNode & Node,
@@ -85,7 +85,7 @@ export function* figure(
85
85
  let number = calculate(
86
86
  label,
87
87
  numbers.has(group) && !isFixed(label)
88
- ? join(numbers.get(group)!.split('.').slice(0, bases.length), '.')
88
+ ? numbers.get(group)!.split('.').slice(0, bases.length).join('.')
89
89
  : base);
90
90
  assert(def.matches('figure') || number.endsWith('.0'));
91
91
  if (number.endsWith('.0')) {
@@ -94,19 +94,18 @@ export function* figure(
94
94
  if (group !== '$' || tagName === 'FIGURE' && def.firstChild) continue;
95
95
  if (number.startsWith('0.')) {
96
96
  assert(number.endsWith('.0'));
97
- number = join(
98
- index.slice(0)
99
- .reduce((ns, _, i, xs) => {
100
- i === ns.length
101
- ? xs.length = i
102
- : ns[i] = +ns[i] > +xs[i]
103
- ? ns[i]
104
- : +ns[i] === 0
105
- ? xs[i]
106
- : `${+xs[i] + 1}`;
107
- return ns;
108
- }, number.split('.')),
109
- '.');
97
+ number = index.slice(0)
98
+ .reduce((ns, _, i, xs) => {
99
+ i === ns.length
100
+ ? xs.length = i
101
+ : ns[i] = +ns[i] > +xs[i]
102
+ ? ns[i]
103
+ : +ns[i] === 0
104
+ ? xs[i]
105
+ : `${+xs[i] + 1}`;
106
+ return ns;
107
+ }, number.split('.'))
108
+ .join('.');
110
109
  }
111
110
  base = number;
112
111
  bases = index = base.split('.');
@@ -184,8 +183,8 @@ function increment(bases: readonly string[], el: HTMLHeadingElement): string {
184
183
  const index = (+el.tagName[1] - 1 || 1) - 1;
185
184
  assert(index >= 0);
186
185
  return index + 1 < bases.length
187
- ? join(
188
- bases.slice(0, index + 2).map((v, i) => {
186
+ ? bases.slice(0, index + 2)
187
+ .map((v, i) => {
189
188
  switch (true) {
190
189
  case i < index:
191
190
  return v;
@@ -194,8 +193,8 @@ function increment(bases: readonly string[], el: HTMLHeadingElement): string {
194
193
  default:
195
194
  return 0;
196
195
  }
197
- }),
198
- '.')
196
+ })
197
+ .join('.')
199
198
  : '';
200
199
  }
201
200