securemark 0.229.0 → 0.230.0

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.230.0
4
+
5
+ - Change table syntax's cell syntax not to depend on trailing whitespace.
6
+
3
7
  ## 0.229.0
4
8
 
5
9
  - Change table syntax's alignment syntax to remove cell type declaration.
@@ -1,4 +1,4 @@
1
- /*! securemark v0.229.0 https://github.com/falsandtru/securemark | (c) 2017, falsandtru | UNLICENSED */
1
+ /*! securemark v0.230.0 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) {
@@ -5263,17 +5263,17 @@ require = function () {
5263
5263
  ]), ns => !(0, alias_1.isArray)(ns[0]) ? (0, array_1.unshift)([[[]]], ns) : ns)));
5264
5264
  const alignment = /^[-=<>]+(?:\/[-=^v]*)?(?=[^\S\n]*\n)/;
5265
5265
  const align = (0, combinator_1.line)((0, combinator_1.fmap)((0, combinator_1.union)([(0, source_1.str)(alignment)]), ([s]) => s.split('/').map(s => s.split(''))));
5266
- const delimiter = /^[-=<>]+(?:\/[-=^v]*)?(?=[^\S\n]*\n)|^[#:](?:(?!:\D|0)\d*:(?!0)\d*)?!*(?=[^\S\n])/;
5267
- const head = (0, combinator_1.creator)((0, combinator_1.block)((0, combinator_1.fmap)((0, combinator_1.open)((0, source_1.str)(/^#(?:(?!:\D|0)\d*:(?!0)\d*)?!*(?=[^\S\n])/), (0, combinator_1.rewrite)((0, combinator_1.inits)([
5266
+ const delimiter = /^[-=<>]+(?:\/[-=^v]*)?(?=[^\S\n]*\n)|^[#:](?:(?!:\D|0)\d*:(?!0)\d*)?!*(?=\s)/;
5267
+ const head = (0, combinator_1.creator)((0, combinator_1.block)((0, combinator_1.fmap)((0, combinator_1.open)((0, source_1.str)(/^#(?:(?!:\D|0)\d*:(?!0)\d*)?!*(?=\s)/), (0, combinator_1.rewrite)((0, combinator_1.inits)([
5268
5268
  source_1.anyline,
5269
5269
  (0, combinator_1.some)(source_1.contentline, delimiter)
5270
5270
  ]), (0, combinator_1.trim)((0, util_1.visualize)((0, combinator_1.some)((0, combinator_1.union)([inline_1.inline]))))), true), ns => [(0, typed_dom_1.html)('th', attributes(ns.shift()), (0, typed_dom_1.defrag)(ns))]), false));
5271
- const data = (0, combinator_1.creator)((0, combinator_1.block)((0, combinator_1.fmap)((0, combinator_1.open)((0, source_1.str)(/^:(?:(?!:\D|0)\d*:(?!0)\d*)?!*(?=[^\S\n])/), (0, combinator_1.rewrite)((0, combinator_1.inits)([
5271
+ const data = (0, combinator_1.creator)((0, combinator_1.block)((0, combinator_1.fmap)((0, combinator_1.open)((0, source_1.str)(/^:(?:(?!:\D|0)\d*:(?!0)\d*)?!*(?=\s)/), (0, combinator_1.rewrite)((0, combinator_1.inits)([
5272
5272
  source_1.anyline,
5273
5273
  (0, combinator_1.some)(source_1.contentline, delimiter)
5274
5274
  ]), (0, combinator_1.trim)((0, util_1.visualize)((0, combinator_1.some)((0, combinator_1.union)([inline_1.inline]))))), true), ns => [(0, typed_dom_1.html)('td', attributes(ns.shift()), (0, typed_dom_1.defrag)(ns))]), false));
5275
5275
  const dataline = (0, combinator_1.creator)((0, combinator_1.line)((0, combinator_1.rewrite)(source_1.contentline, (0, combinator_1.union)([
5276
- (0, combinator_1.validate)(/^!+[^\S\n]/, (0, combinator_1.convert)(source => `:${ source }`, data)),
5276
+ (0, combinator_1.validate)(/^!+\s/, (0, combinator_1.convert)(source => `:${ source }`, data)),
5277
5277
  (0, combinator_1.convert)(source => `: ${ source }`, data)
5278
5278
  ]))));
5279
5279
  function attributes(source) {
@@ -5555,7 +5555,8 @@ require = function () {
5555
5555
  const inline_1 = _dereq_('../inline');
5556
5556
  const source_1 = _dereq_('../source');
5557
5557
  const typed_dom_1 = _dereq_('typed-dom');
5558
- exports.ilist = (0, combinator_1.lazy)(() => (0, combinator_1.block)((0, combinator_1.fmap)((0, combinator_1.validate)(/^[-+*](?=[^\S\n]|\n[^\S\n]*\S)/, (0, combinator_1.context)({ syntax: { inline: { media: false } } }, (0, combinator_1.some)((0, combinator_1.creator)((0, combinator_1.union)([(0, combinator_1.fmap)((0, combinator_1.fallback)((0, combinator_1.inits)([
5558
+ exports.ilist = (0, combinator_1.lazy)(() => (0, combinator_1.block)((0, combinator_1.validate)(/^[-+*](?=[^\S\n]|\n[^\S\n]*\S)/, (0, combinator_1.context)({ syntax: { inline: { media: false } } }, exports.ilist_))));
5559
+ exports.ilist_ = (0, combinator_1.lazy)(() => (0, combinator_1.block)((0, combinator_1.fmap)((0, combinator_1.validate)(/^[-+*](?:$|\s)/, (0, combinator_1.some)((0, combinator_1.creator)((0, combinator_1.union)([(0, combinator_1.fmap)((0, combinator_1.fallback)((0, combinator_1.inits)([
5559
5560
  (0, combinator_1.line)((0, combinator_1.open)(/^[-+*](?:$|\s)/, (0, combinator_1.trim)((0, combinator_1.some)(inline_1.inline)), true)),
5560
5561
  (0, combinator_1.indent)((0, combinator_1.union)([
5561
5562
  ulist_1.ulist_,
@@ -5565,13 +5566,12 @@ require = function () {
5565
5566
  ]), (0, combinator_1.rewrite)(source_1.contentline, source => [
5566
5567
  [(0, typed_dom_1.html)('span', source.replace('\n', ''))],
5567
5568
  ''
5568
- ])), ns => [(0, typed_dom_1.html)('li', (0, typed_dom_1.defrag)((0, ulist_1.fillFirstLine)(ns)))])]))))), es => [(0, typed_dom_1.html)('ul', {
5569
+ ])), ns => [(0, typed_dom_1.html)('li', (0, typed_dom_1.defrag)((0, ulist_1.fillFirstLine)(ns)))])])))), es => [(0, typed_dom_1.html)('ul', {
5569
5570
  class: 'invalid',
5570
5571
  'data-invalid-syntax': 'list',
5571
5572
  'data-invalid-type': 'syntax',
5572
5573
  'data-invalid-description': 'Use "-" instead of "+" or "*".'
5573
5574
  }, es)])));
5574
- exports.ilist_ = (0, combinator_1.convert)(source => source.replace(/^[-+*](?=$|\n)/, `$& `), exports.ilist);
5575
5575
  },
5576
5576
  {
5577
5577
  '../../combinator': 27,
@@ -5631,8 +5631,19 @@ require = function () {
5631
5631
  const typed_dom_1 = _dereq_('typed-dom');
5632
5632
  const memoize_1 = _dereq_('spica/memoize');
5633
5633
  const array_1 = _dereq_('spica/array');
5634
- exports.olist = (0, combinator_1.lazy)(() => (0, combinator_1.block)((0, combinator_1.match)(/^(?=(?:([0-9]+|[a-z]+|[A-Z]+)(?:-[0-9]+)*(\.)|\(([0-9]+|[a-z]+)(\))(?:-[0-9]+)*)(?=[^\S\n]|\n[^\S\n]*\S))/, (0, memoize_1.memoize)(ms => list(type(ms[1] || ms[3]), ms[2] || ms[4]), ms => type(ms[1] || ms[3]) + (ms[2] || ms[4])))));
5635
- const list = (type, delim) => (0, combinator_1.fmap)((0, combinator_1.context)({ syntax: { inline: { media: false } } }, (0, combinator_1.some)((0, combinator_1.creator)((0, combinator_1.union)([(0, combinator_1.fmap)((0, combinator_1.fallback)((0, combinator_1.inits)([
5634
+ const openers = {
5635
+ '.': /^(?:[0-9]+|[a-z]+|[A-Z]+)(?:-(?!-)[0-9]*)*(?![^\S\n])\.?(?=$|\s)/,
5636
+ '(': /^\((?:[0-9]*|[a-z]*)(?![^)\n])\)?(?:-(?!-)[0-9]*)*(?=$|\s)/
5637
+ };
5638
+ exports.olist = (0, combinator_1.lazy)(() => (0, combinator_1.block)((0, combinator_1.validate)([
5639
+ /^(?=([0-9]+|[a-z]+|[A-Z]+)(?:-[0-9]+)*\.(?=[^\S\n]|\n[^\S\n]*\S))/,
5640
+ /^(?=\(([0-9]+|[a-z]+)\)(?:-[0-9]+)*(?=[^\S\n]|\n[^\S\n]*\S))/
5641
+ ], (0, combinator_1.context)({ syntax: { inline: { media: false } } }, exports.olist_))));
5642
+ exports.olist_ = (0, combinator_1.lazy)(() => (0, combinator_1.block)((0, combinator_1.union)([
5643
+ (0, combinator_1.match)(new RegExp(`^(?=${ openers['.'].source.replace('?:', '') })`), (0, memoize_1.memoize)(ms => list(type(ms[1]), '.'), ms => type(ms[1]))),
5644
+ (0, combinator_1.match)(new RegExp(`^(?=${ openers['('].source.replace('?:', '') })`), (0, memoize_1.memoize)(ms => list(type(ms[1]), '('), ms => type(ms[1])))
5645
+ ])));
5646
+ const list = (type, delim) => (0, combinator_1.fmap)((0, combinator_1.some)((0, combinator_1.creator)((0, combinator_1.union)([(0, combinator_1.fmap)((0, combinator_1.fallback)((0, combinator_1.inits)([
5636
5647
  (0, combinator_1.line)((0, combinator_1.open)(items[delim], (0, combinator_1.trim)((0, combinator_1.subsequence)([
5637
5648
  ulist_1.checkbox,
5638
5649
  (0, combinator_1.trimStart)((0, combinator_1.some)(inline_1.inline))
@@ -5642,18 +5653,17 @@ require = function () {
5642
5653
  exports.olist_,
5643
5654
  ilist_1.ilist_
5644
5655
  ]))
5645
- ]), iitem), ns => [(0, typed_dom_1.html)('li', { 'data-marker': ns[0] }, (0, typed_dom_1.defrag)((0, ulist_1.fillFirstLine)((0, array_1.shift)(ns)[1])))])])))), es => [format((0, typed_dom_1.html)('ol', es), type, delim)]);
5656
+ ]), iitem), ns => [(0, typed_dom_1.html)('li', { 'data-marker': ns[0] }, (0, typed_dom_1.defrag)((0, ulist_1.fillFirstLine)((0, array_1.shift)(ns)[1])))])]))), es => [format((0, typed_dom_1.html)('ol', es), type, delim)]);
5646
5657
  const items = {
5647
- '.': (0, combinator_1.focus)(/^(?:[0-9]+|[a-z]+|[A-Z]+)(?:-(?!-)[0-9]*)*(?![^\S\n])\.?(?=$|\s)/, source => [
5658
+ '.': (0, combinator_1.focus)(openers['.'], source => [
5648
5659
  [`${ source.split('.', 1)[0] }.`],
5649
5660
  ''
5650
5661
  ]),
5651
- ')': (0, combinator_1.focus)(/^\((?:[0-9]*|[a-z]*)(?![^)\n])\)?(?:-(?!-)[0-9]*)*(?=$|\s)/, source => [
5662
+ '(': (0, combinator_1.focus)(openers['('], source => [
5652
5663
  [source.trimEnd().replace(/^\($/, '(1)').replace(/^\((\w+)\)?$/, '($1)')],
5653
5664
  ''
5654
5665
  ])
5655
5666
  };
5656
- exports.olist_ = (0, combinator_1.convert)(source => source[0] !== '(' ? source.replace(/^((?:[0-9]+|[a-z]+|[A-Z]+)(?:-(?!-)[0-9]*)*)\.?(?=$|\n)/, `$1. `) : source.replace(/^\((?=$|\n)/, `(1) `).replace(/^\(((?:[0-9]+|[a-z]+))\)?((?:-(?!-)[0-9]*)*(?=$|\n))/, `($1)$2 `), exports.olist);
5657
5667
  const iitem = (0, combinator_1.rewrite)(source_1.contentline, source => [
5658
5668
  [
5659
5669
  '',
@@ -5970,7 +5980,7 @@ require = function () {
5970
5980
  function (_dereq_, module, exports) {
5971
5981
  'use strict';
5972
5982
  Object.defineProperty(exports, '__esModule', { value: true });
5973
- exports.fillFirstLine = exports.ulist_ = exports.checkbox = exports.ulist = void 0;
5983
+ exports.fillFirstLine = exports.checkbox = exports.ulist_ = exports.ulist = void 0;
5974
5984
  const combinator_1 = _dereq_('../../combinator');
5975
5985
  const olist_1 = _dereq_('./olist');
5976
5986
  const ilist_1 = _dereq_('./ilist');
@@ -5978,7 +5988,8 @@ require = function () {
5978
5988
  const typed_dom_1 = _dereq_('typed-dom');
5979
5989
  const array_1 = _dereq_('spica/array');
5980
5990
  const source_1 = _dereq_('../source');
5981
- exports.ulist = (0, combinator_1.lazy)(() => (0, combinator_1.block)((0, combinator_1.fmap)((0, combinator_1.validate)(/^-(?=[^\S\n]|\n[^\S\n]*\S)/, (0, combinator_1.context)({ syntax: { inline: { media: false } } }, (0, combinator_1.some)((0, combinator_1.creator)((0, combinator_1.union)([(0, combinator_1.fmap)((0, combinator_1.fallback)((0, combinator_1.inits)([
5991
+ exports.ulist = (0, combinator_1.lazy)(() => (0, combinator_1.block)((0, combinator_1.validate)(/^-(?=[^\S\n]|\n[^\S\n]*\S)/, (0, combinator_1.context)({ syntax: { inline: { media: false } } }, exports.ulist_))));
5992
+ exports.ulist_ = (0, combinator_1.lazy)(() => (0, combinator_1.block)((0, combinator_1.fmap)((0, combinator_1.validate)(/^-(?=$|\s)/, (0, combinator_1.some)((0, combinator_1.creator)((0, combinator_1.union)([(0, combinator_1.fmap)((0, combinator_1.fallback)((0, combinator_1.inits)([
5982
5993
  (0, combinator_1.line)((0, combinator_1.open)(/^-(?:$|\s)/, (0, combinator_1.trim)((0, combinator_1.subsequence)([
5983
5994
  exports.checkbox,
5984
5995
  (0, combinator_1.trimStart)((0, combinator_1.some)(inline_1.inline))
@@ -5988,12 +5999,11 @@ require = function () {
5988
5999
  olist_1.olist_,
5989
6000
  ilist_1.ilist_
5990
6001
  ]))
5991
- ]), iitem), ns => [(0, typed_dom_1.html)('li', (0, typed_dom_1.defrag)(fillFirstLine(ns)))])]))))), es => [format((0, typed_dom_1.html)('ul', es))])));
6002
+ ]), iitem), ns => [(0, typed_dom_1.html)('li', (0, typed_dom_1.defrag)(fillFirstLine(ns)))])])))), es => [format((0, typed_dom_1.html)('ul', es))])));
5992
6003
  exports.checkbox = (0, combinator_1.focus)(/^\[[xX ]\](?=$|\s)/, source => [
5993
6004
  [(0, typed_dom_1.html)('span', { class: 'checkbox' }, source[1].trimStart() ? '\u2611' : '\u2610')],
5994
6005
  ''
5995
6006
  ]);
5996
- exports.ulist_ = (0, combinator_1.convert)(source => source.replace(/^-(?=$|\n)/, `$& `), exports.ulist);
5997
6007
  const iitem = (0, combinator_1.rewrite)(source_1.contentline, source => [
5998
6008
  [(0, typed_dom_1.html)('span', {
5999
6009
  class: 'invalid',
package/markdown.d.ts CHANGED
@@ -123,12 +123,12 @@ export namespace MarkdownParser {
123
123
  // - item
124
124
  Block<'ulist'>,
125
125
  Parser<HTMLUListElement, Context, [
126
- UListParser.ListItemParser,
126
+ UListParser.ItemParser,
127
127
  ]> {
128
128
  }
129
129
  export namespace UListParser {
130
- export interface ListItemParser extends
131
- Block<'ulist/listitem'>,
130
+ export interface ItemParser extends
131
+ Block<'ulist/item'>,
132
132
  Parser<HTMLLIElement, Context, [
133
133
  Parser<HTMLElement | string, Context, [
134
134
  InlineParser,
@@ -148,12 +148,19 @@ export namespace MarkdownParser {
148
148
  // (a)-1 item
149
149
  Block<'olist'>,
150
150
  Parser<HTMLOListElement, Context, [
151
- OListParser.ListItemParser,
151
+ OListParser.ListParser,
152
+ OListParser.ListParser,
152
153
  ]> {
153
154
  }
154
155
  export namespace OListParser {
155
- export interface ListItemParser extends
156
- Block<'olist/listitem'>,
156
+ export interface ListParser extends
157
+ Block<'olist/list'>,
158
+ Parser<HTMLOListElement, Context, [
159
+ OListParser.ItemParser,
160
+ ]> {
161
+ }
162
+ export interface ItemParser extends
163
+ Block<'olist/item'>,
157
164
  Parser<HTMLLIElement, Context, [
158
165
  Parser<HTMLElement | string, Context, [
159
166
  InlineParser,
@@ -172,12 +179,12 @@ export namespace MarkdownParser {
172
179
  // * item
173
180
  Block<'ilist'>,
174
181
  Parser<HTMLUListElement, Context, [
175
- IListParser.ListItemParser,
182
+ IListParser.ItemParser,
176
183
  ]> {
177
184
  }
178
185
  export namespace IListParser {
179
- export interface ListItemParser extends
180
- Block<'ilist/listitem'>,
186
+ export interface ItemParser extends
187
+ Block<'ilist/item'>,
181
188
  Parser<HTMLLIElement, Context, [
182
189
  InlineParser,
183
190
  Parser<HTMLUListElement | HTMLOListElement, Context, [
package/package-lock.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "securemark",
3
- "version": "0.229.0",
3
+ "version": "0.230.0",
4
4
  "lockfileVersion": 1,
5
5
  "requires": true,
6
6
  "dependencies": {
@@ -4125,9 +4125,9 @@
4125
4125
  }
4126
4126
  },
4127
4127
  "fs-extra": {
4128
- "version": "10.0.0",
4129
- "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.0.0.tgz",
4130
- "integrity": "sha512-C5owb14u9eJwizKGdchcDUQeFtlSHHthBk8pbX9Vc1PFZrLombudjDnNns88aYslCyF6IY5SUw3Roz6xShcEIQ==",
4128
+ "version": "10.0.1",
4129
+ "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.0.1.tgz",
4130
+ "integrity": "sha512-NbdoVMZso2Lsrn/QwLXOy6rm0ufY2zEOKCDzJR/0kBsb0E6qed0P3iYK+Ath3BfvXEeu4JhEtXLgILx5psUfag==",
4131
4131
  "dev": true,
4132
4132
  "requires": {
4133
4133
  "graceful-fs": "^4.2.0",
@@ -4178,20 +4178,31 @@
4178
4178
  "dev": true
4179
4179
  },
4180
4180
  "gauge": {
4181
- "version": "4.0.1",
4182
- "resolved": "https://registry.npmjs.org/gauge/-/gauge-4.0.1.tgz",
4183
- "integrity": "sha512-zJ4jePUHR8cceduZ53b6temRalyGpkC2Kc2r3ecNphmL+uWNoJ3YcOcUjpbG6WwoE/Ef6/+aEZz63neI2WIa1Q==",
4181
+ "version": "4.0.2",
4182
+ "resolved": "https://registry.npmjs.org/gauge/-/gauge-4.0.2.tgz",
4183
+ "integrity": "sha512-aSPRm2CvA9R8QyU5eXMFPd+cYkyxLsXHd2l5/FOH2V/eml//M04G6KZOmTap07O1PvEwNcl2NndyLfK8g3QrKA==",
4184
4184
  "dev": true,
4185
4185
  "requires": {
4186
4186
  "ansi-regex": "^5.0.1",
4187
4187
  "aproba": "^1.0.3 || ^2.0.0",
4188
- "color-support": "^1.1.2",
4189
- "console-control-strings": "^1.0.0",
4188
+ "color-support": "^1.1.3",
4189
+ "console-control-strings": "^1.1.0",
4190
4190
  "has-unicode": "^2.0.1",
4191
- "signal-exit": "^3.0.0",
4191
+ "signal-exit": "^3.0.7",
4192
4192
  "string-width": "^4.2.3",
4193
4193
  "strip-ansi": "^6.0.1",
4194
- "wide-align": "^1.1.2"
4194
+ "wide-align": "^1.1.5"
4195
+ },
4196
+ "dependencies": {
4197
+ "wide-align": {
4198
+ "version": "1.1.5",
4199
+ "resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.5.tgz",
4200
+ "integrity": "sha512-eDMORYaPNZ4sQIuuYPDHdQvf4gyCF9rEEV/yPxGfwPkRodwEgiMUUXTx/dex+Me0wxx53S+NgUHaP7y3MGlDmg==",
4201
+ "dev": true,
4202
+ "requires": {
4203
+ "string-width": "^1.0.2 || 2 || 3 || 4"
4204
+ }
4205
+ }
4195
4206
  }
4196
4207
  },
4197
4208
  "gensync": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "securemark",
3
- "version": "0.229.0",
3
+ "version": "0.230.0",
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",
@@ -42,12 +42,9 @@ describe('Unit: parser/block/extension/table', () => {
42
42
  assert.deepStrictEqual(
43
43
  inspect(parser('~~~table\n0\n\n~~~')),
44
44
  [[html('table', [html('thead'), html('tbody', [html('tr', [html('td', '0')])]), html('tfoot')]).outerHTML], '']);
45
- assert.deepStrictEqual(
46
- inspect(parser('~~~table\n#\n~~~')),
47
- [[html('table', [html('thead'), html('tbody', [html('tr', [html('td', '#')])]), html('tfoot'),]).outerHTML], '']);
48
45
  assert.deepStrictEqual(
49
46
  inspect(parser('~~~table\n:\n~~~')),
50
- [[html('table', [html('thead'), html('tbody', [html('tr', [html('td', ':')])]), html('tfoot'),]).outerHTML], '']);
47
+ [[html('table', [html('thead'), html('tbody', [html('tr', [html('td')])]), html('tfoot'),]).outerHTML], '']);
51
48
  assert.deepStrictEqual(
52
49
  inspect(parser('~~~table\n1.1\n~~~')),
53
50
  [[html('table', [
@@ -237,6 +234,9 @@ describe('Unit: parser/block/extension/table', () => {
237
234
  });
238
235
 
239
236
  it('head', () => {
237
+ assert.deepStrictEqual(
238
+ inspect(parser('~~~table\n#\n~~~')),
239
+ [[html('table', [html('thead', [html('tr', [html('th')])]), html('tbody'), html('tfoot'),]).outerHTML], '']);
240
240
  assert.deepStrictEqual(
241
241
  inspect(parser('~~~table\n-\n# 1.1\n~~~')),
242
242
  [[html('table', [
@@ -73,10 +73,10 @@ const align: AlignParser = line(fmap(
73
73
  union([str(alignment)]),
74
74
  ([s]) => s.split('/').map(s => s.split(''))));
75
75
 
76
- const delimiter = /^[-=<>]+(?:\/[-=^v]*)?(?=[^\S\n]*\n)|^[#:](?:(?!:\D|0)\d*:(?!0)\d*)?!*(?=[^\S\n])/;
76
+ const delimiter = /^[-=<>]+(?:\/[-=^v]*)?(?=[^\S\n]*\n)|^[#:](?:(?!:\D|0)\d*:(?!0)\d*)?!*(?=\s)/;
77
77
 
78
78
  const head: CellParser.HeadParser = creator(block(fmap(open(
79
- str(/^#(?:(?!:\D|0)\d*:(?!0)\d*)?!*(?=[^\S\n])/),
79
+ str(/^#(?:(?!:\D|0)\d*:(?!0)\d*)?!*(?=\s)/),
80
80
  rewrite(
81
81
  inits([
82
82
  anyline,
@@ -88,7 +88,7 @@ const head: CellParser.HeadParser = creator(block(fmap(open(
88
88
  false));
89
89
 
90
90
  const data: CellParser.DataParser = creator(block(fmap(open(
91
- str(/^:(?:(?!:\D|0)\d*:(?!0)\d*)?!*(?=[^\S\n])/),
91
+ str(/^:(?:(?!:\D|0)\d*:(?!0)\d*)?!*(?=\s)/),
92
92
  rewrite(
93
93
  inits([
94
94
  anyline,
@@ -103,7 +103,7 @@ const dataline: CellParser.DatalineParser = creator(line(
103
103
  rewrite(
104
104
  contentline,
105
105
  union([
106
- validate(/^!+[^\S\n]/, convert(source => `:${source}`, data)),
106
+ validate(/^!+\s/, convert(source => `:${source}`, data)),
107
107
  convert(source => `: ${source}`, data),
108
108
  ]))));
109
109
 
@@ -1,14 +1,18 @@
1
1
  import { IListParser } from '../block';
2
- import { union, inits, some, block, line, validate, indent, rewrite, context, creator, open, convert, trim, fallback, lazy, fmap } from '../../combinator';
2
+ import { union, inits, some, block, line, validate, indent, rewrite, context, creator, open, trim, fallback, lazy, fmap } from '../../combinator';
3
3
  import { ulist_, fillFirstLine } from './ulist';
4
4
  import { olist_ } from './olist';
5
5
  import { inline } from '../inline';
6
6
  import { contentline } from '../source';
7
7
  import { html, defrag } from 'typed-dom';
8
8
 
9
- export const ilist: IListParser = lazy(() => block(fmap(validate(
9
+ export const ilist: IListParser = lazy(() => block(validate(
10
10
  /^[-+*](?=[^\S\n]|\n[^\S\n]*\S)/,
11
11
  context({ syntax: { inline: { media: false } } },
12
+ ilist_))));
13
+
14
+ export const ilist_: IListParser = lazy(() => block(fmap(validate(
15
+ /^[-+*](?:$|\s)/,
12
16
  some(creator(union([
13
17
  fmap(fallback(
14
18
  inits([
@@ -17,7 +21,7 @@ export const ilist: IListParser = lazy(() => block(fmap(validate(
17
21
  ]),
18
22
  rewrite(contentline, source => [[html('span', source.replace('\n', ''))], ''])),
19
23
  ns => [html('li', defrag(fillFirstLine(ns)))]),
20
- ]))))),
24
+ ])))),
21
25
  es => [
22
26
  html('ul', {
23
27
  class: 'invalid',
@@ -26,7 +30,3 @@ export const ilist: IListParser = lazy(() => block(fmap(validate(
26
30
  'data-invalid-description': 'Use "-" instead of "+" or "*".',
27
31
  }, es),
28
32
  ])));
29
-
30
- export const ilist_: IListParser = convert(
31
- source => source.replace(/^[-+*](?=$|\n)/, `$& `),
32
- ilist);
@@ -1,6 +1,6 @@
1
1
  import { undefined } from 'spica/global';
2
2
  import { OListParser } from '../block';
3
- import { union, inits, subsequence, some, block, line, indent, focus, rewrite, context, creator, open, match, convert, trim, trimStart, fallback, lazy, fmap } from '../../combinator';
3
+ import { union, inits, subsequence, some, block, line, validate, indent, focus, rewrite, context, creator, open, match, trim, trimStart, fallback, lazy, fmap } from '../../combinator';
4
4
  import { checkbox, ulist_, fillFirstLine } from './ulist';
5
5
  import { ilist_ } from './ilist';
6
6
  import { inline } from '../inline';
@@ -9,14 +9,29 @@ import { html, define, defrag } from 'typed-dom';
9
9
  import { memoize } from 'spica/memoize';
10
10
  import { shift } from 'spica/array';
11
11
 
12
- export const olist: OListParser = lazy(() => block(match(
13
- /^(?=(?:([0-9]+|[a-z]+|[A-Z]+)(?:-[0-9]+)*(\.)|\(([0-9]+|[a-z]+)(\))(?:-[0-9]+)*)(?=[^\S\n]|\n[^\S\n]*\S))/,
14
- memoize(
15
- ms => list(type(ms[1] || ms[3]), ms[2] || ms[4]),
16
- ms => type(ms[1] || ms[3]) + (ms[2] || ms[4])))));
12
+ const openers = {
13
+ '.': /^(?:[0-9]+|[a-z]+|[A-Z]+)(?:-(?!-)[0-9]*)*(?![^\S\n])\.?(?=$|\s)/,
14
+ '(': /^\((?:[0-9]*|[a-z]*)(?![^)\n])\)?(?:-(?!-)[0-9]*)*(?=$|\s)/,
15
+ } as const;
17
16
 
18
- const list = (type: string, delim: string): OListParser => fmap(
17
+ export const olist: OListParser = lazy(() => block(validate(
18
+ [
19
+ /^(?=([0-9]+|[a-z]+|[A-Z]+)(?:-[0-9]+)*\.(?=[^\S\n]|\n[^\S\n]*\S))/,
20
+ /^(?=\(([0-9]+|[a-z]+)\)(?:-[0-9]+)*(?=[^\S\n]|\n[^\S\n]*\S))/,
21
+ ],
19
22
  context({ syntax: { inline: { media: false } } },
23
+ olist_))));
24
+
25
+ export const olist_: OListParser = lazy(() => block(union([
26
+ match(
27
+ new RegExp(`^(?=${openers['.'].source.replace('?:', '')})`),
28
+ memoize(ms => list(type(ms[1]), '.'), ms => type(ms[1]))),
29
+ match(
30
+ new RegExp(`^(?=${openers['('].source.replace('?:', '')})`),
31
+ memoize(ms => list(type(ms[1]), '('), ms => type(ms[1]))),
32
+ ])));
33
+
34
+ const list = (type: string, delim: string): OListParser.ListParser => fmap(
20
35
  some(creator(union([
21
36
  fmap(fallback(
22
37
  inits([
@@ -25,28 +40,18 @@ const list = (type: string, delim: string): OListParser => fmap(
25
40
  ]),
26
41
  iitem),
27
42
  (ns: [string, ...(HTMLElement | string)[]]) => [html('li', { 'data-marker': ns[0] }, defrag(fillFirstLine(shift(ns)[1])))]),
28
- ])))),
43
+ ]))),
29
44
  es => [format(html('ol', es), type, delim)]);
30
45
 
31
46
  const items = {
32
47
  '.': focus(
33
- /^(?:[0-9]+|[a-z]+|[A-Z]+)(?:-(?!-)[0-9]*)*(?![^\S\n])\.?(?=$|\s)/,
48
+ openers['.'],
34
49
  (source: string) => [[`${source.split('.', 1)[0]}.`], '']),
35
- ')': focus(
36
- /^\((?:[0-9]*|[a-z]*)(?![^)\n])\)?(?:-(?!-)[0-9]*)*(?=$|\s)/,
50
+ '(': focus(
51
+ openers['('],
37
52
  (source: string) => [[source.trimEnd().replace(/^\($/, '(1)').replace(/^\((\w+)\)?$/, '($1)')], '']),
38
53
  } as const;
39
54
 
40
- export const olist_: OListParser = convert(
41
- source =>
42
- source[0] !== '('
43
- ? source
44
- .replace(/^((?:[0-9]+|[a-z]+|[A-Z]+)(?:-(?!-)[0-9]*)*)\.?(?=$|\n)/, `$1. `)
45
- : source
46
- .replace(/^\((?=$|\n)/, `(1) `)
47
- .replace(/^\(((?:[0-9]+|[a-z]+))\)?((?:-(?!-)[0-9]*)*(?=$|\n))/, `($1)$2 `),
48
- olist);
49
-
50
55
  const iitem = rewrite(contentline, source => [[
51
56
  '',
52
57
  html('span', {
@@ -1,5 +1,5 @@
1
1
  import { UListParser } from '../block';
2
- import { union, inits, subsequence, some, block, line, validate, indent, focus, rewrite, context, creator, open, convert, trim, trimStart, fallback, lazy, fmap } from '../../combinator';
2
+ import { union, inits, subsequence, some, block, line, validate, indent, focus, rewrite, context, creator, open, trim, trimStart, fallback, lazy, fmap } from '../../combinator';
3
3
  import { olist_ } from './olist';
4
4
  import { ilist_ } from './ilist';
5
5
  import { inline } from '../inline';
@@ -7,9 +7,13 @@ import { html, defrag } from 'typed-dom';
7
7
  import { unshift } from 'spica/array';
8
8
  import { contentline } from '../source';
9
9
 
10
- export const ulist: UListParser = lazy(() => block(fmap(validate(
10
+ export const ulist: UListParser = lazy(() => block(validate(
11
11
  /^-(?=[^\S\n]|\n[^\S\n]*\S)/,
12
12
  context({ syntax: { inline: { media: false } } },
13
+ ulist_))));
14
+
15
+ export const ulist_: UListParser = lazy(() => block(fmap(validate(
16
+ /^-(?=$|\s)/,
13
17
  some(creator(union([
14
18
  fmap(fallback(
15
19
  inits([
@@ -18,7 +22,7 @@ export const ulist: UListParser = lazy(() => block(fmap(validate(
18
22
  ]),
19
23
  iitem),
20
24
  ns => [html('li', defrag(fillFirstLine(ns)))]),
21
- ]))))),
25
+ ])))),
22
26
  es => [format(html('ul', es))])));
23
27
 
24
28
  export const checkbox = focus(
@@ -27,10 +31,6 @@ export const checkbox = focus(
27
31
  html('span', { class: 'checkbox' }, source[1].trimStart() ? '☑' : '☐'),
28
32
  ], '']);
29
33
 
30
- export const ulist_: UListParser = convert(
31
- source => source.replace(/^-(?=$|\n)/, `$& `),
32
- ulist);
33
-
34
34
  const iitem = rewrite(contentline, source => [[
35
35
  html('span', {
36
36
  class: 'invalid',