securemark 0.299.3 → 0.299.4

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.
Files changed (41) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/dist/index.js +2054 -2095
  3. package/index.ts +2 -2
  4. package/package.json +1 -1
  5. package/src/{parser/api → api}/bind.test.ts +2 -2
  6. package/src/{parser/api → api}/bind.ts +5 -5
  7. package/src/{parser/api → api}/body.test.ts +1 -1
  8. package/src/{parser/api → api}/cache.ts +1 -1
  9. package/src/{parser/api → api}/header.test.ts +1 -1
  10. package/src/{parser/api → api}/header.ts +2 -2
  11. package/src/{parser/api → api}/normalize.test.ts +1 -1
  12. package/src/{parser/api → api}/parse.test.ts +3 -3
  13. package/src/{parser/api → api}/parse.ts +5 -5
  14. package/src/combinator/data/{node.ts → list/list.ts} +4 -4
  15. package/src/combinator/data/parser/inits.ts +3 -3
  16. package/src/combinator/data/parser/sequence.ts +3 -3
  17. package/src/combinator/data/parser/subsequence.ts +3 -3
  18. package/src/combinator/data/parser/tails.ts +3 -3
  19. package/src/combinator/data/parser.ts +1 -1
  20. package/src/parser/block/blockquote.ts +1 -1
  21. package/src/parser/block/extension/aside.ts +1 -1
  22. package/src/parser/block/extension/example.ts +1 -1
  23. package/src/parser/inline/link.ts +2 -2
  24. package/src/parser/inline/media.ts +1 -1
  25. package/src/parser/node.ts +1 -1
  26. package/src/parser/visibility.ts +1 -1
  27. package/src/{parser/processor → processor}/figure.test.ts +4 -4
  28. package/src/{parser/processor → processor}/figure.ts +2 -2
  29. package/src/{parser/processor → processor}/note.test.ts +3 -3
  30. package/src/{parser/processor → processor}/note.ts +2 -2
  31. package/src/renderer/render/media/pdf.ts +1 -1
  32. package/src/renderer/render/media/twitter.ts +1 -1
  33. package/src/renderer/render/media.test.ts +1 -2
  34. package/src/renderer/render.test.ts +1 -1
  35. package/src/util/info.test.ts +1 -1
  36. package/src/util/quote.test.ts +1 -1
  37. package/src/util/toc.test.ts +1 -1
  38. package/src/parser.ts +0 -1
  39. /package/src/{parser/api → api}/body.ts +0 -0
  40. /package/src/{parser/api → api}/normalize.ts +0 -0
  41. /package/src/{parser/api.ts → api.ts} +0 -0
package/index.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import 'spica/global';
2
2
 
3
- export * from './src/parser';
4
- export * from './src/util';
3
+ export * from './src/api';
5
4
  export * from './src/renderer';
5
+ export * from './src/util';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "securemark",
3
- "version": "0.299.3",
3
+ "version": "0.299.4",
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",
@@ -1,8 +1,8 @@
1
- import { Progress } from '../../..';
1
+ import { Progress } from '../..';
2
2
  import { bind } from './bind';
3
3
  import { frag, html } from 'typed-dom/dom';
4
4
 
5
- describe('Unit: parser/api/bind', () => {
5
+ describe('Unit: api/bind', () => {
6
6
  describe('bind', () => {
7
7
  function inspect(iter: IterableIterator<Progress>, count = Infinity) {
8
8
  const acc: (string | undefined)[] = [];
@@ -1,8 +1,8 @@
1
- import { ParserSettings, Progress } from '../../..';
2
- import { Context, Options, Segment } from '../context';
3
- import { input } from '../../combinator/data/parser';
4
- import { segment } from '../segment';
5
- import { block } from '../block';
1
+ import { ParserSettings, Progress } from '../..';
2
+ import { Context, Options, Segment } from '../parser/context';
3
+ import { input } from '../combinator/data/parser';
4
+ import { segment } from '../parser/segment';
5
+ import { block } from '../parser/block';
6
6
  import { headers } from './header';
7
7
  import { figure } from '../processor/figure';
8
8
  import { note } from '../processor/note';
@@ -1,6 +1,6 @@
1
1
  import { body } from './body';
2
2
 
3
- describe('Unit: parser/api/body', () => {
3
+ describe('Unit: api/body', () => {
4
4
  describe('body', () => {
5
5
  it('basic', () => {
6
6
  assert.deepStrictEqual(body(''), '');
@@ -1,4 +1,4 @@
1
- import { Caches } from '../../..';
1
+ import { Caches } from '../..';
2
2
  import { TClock } from 'spica/tclock';
3
3
  import { TLRU } from 'spica/tlru';
4
4
 
@@ -1,6 +1,6 @@
1
1
  import { headers } from './header';
2
2
 
3
- describe('Unit: parser/api/header', () => {
3
+ describe('Unit: api/header', () => {
4
4
  describe('headers', () => {
5
5
  it('basic', () => {
6
6
  assert.deepStrictEqual(headers(''), []);
@@ -1,5 +1,5 @@
1
- import { Context } from '../context';
2
- import { header as h } from '../header';
1
+ import { Context } from '../parser/context';
2
+ import { header as h } from '../parser/header';
3
3
 
4
4
  export function header(source: string): string {
5
5
  const [, pos = 0] = parse(source);
@@ -1,6 +1,6 @@
1
1
  import { normalize, escape } from './normalize';
2
2
 
3
- describe('Unit: parser/normalize', () => {
3
+ describe('Unit: normalize', () => {
4
4
  describe('normalize', () => {
5
5
  it('controls', () => {
6
6
  assert(normalize('\r') === '\n');
@@ -1,9 +1,9 @@
1
1
  import { parse } from './parse';
2
- import { Context } from '../context';
2
+ import { Context } from '../parser/context';
3
3
  import { html } from 'typed-dom/dom';
4
- import { normalize } from '../../debug.test';
4
+ import { normalize } from '../debug.test';
5
5
 
6
- describe('Unit: parser/api/parse', () => {
6
+ describe('Unit: api/parse', () => {
7
7
  describe('parse', () => {
8
8
  it('huge input', () => {
9
9
  assert.deepStrictEqual(
@@ -1,8 +1,8 @@
1
- import { ParserOptions } from '../../..';
2
- import { input } from '../../combinator/data/parser';
3
- import { Context, Options, Segment } from '../context';
4
- import { segment } from '../segment';
5
- import { block } from '../block';
1
+ import { ParserOptions } from '../..';
2
+ import { input } from '../combinator/data/parser';
3
+ import { Context, Options, Segment } from '../parser/context';
4
+ import { segment } from '../parser/segment';
5
+ import { block } from '../parser/block';
6
6
  import { headers } from './header';
7
7
  import { figure } from '../processor/figure';
8
8
  import { note } from '../processor/note';
@@ -1,4 +1,4 @@
1
- import { Parser, Context } from './parser';
1
+ import { Parser, Context } from '../parser';
2
2
 
3
3
  export class List<N extends List.Node = List.Node, C extends Context = Context, D extends Parser<unknown, C>[] = any> {
4
4
  constructor(nodes?: ArrayLike<N>) {
@@ -134,8 +134,8 @@ export class List<N extends List.Node = List.Node, C extends Context = Context,
134
134
  }
135
135
  }
136
136
  export namespace List {
137
- export class Node {
138
- public next?: this = undefined;
139
- public prev?: this = undefined;
137
+ export interface Node {
138
+ next?: this;
139
+ prev?: this;
140
140
  }
141
141
  }
@@ -1,7 +1,7 @@
1
1
  import { Parser, List, Node, Context } from '../parser';
2
2
 
3
- export function inits<P extends Parser>(parsers: Parser.SubParsers<P>): Parser.SubNode<P> extends Parser.Node<P> ? P : Parser<Parser.SubNode<P>, Parser.Context<P>, Parser.SubParsers<P>>;
4
- export function inits<N, D extends Parser<N>[]>(parsers: D): Parser<N, Context, D> {
3
+ export function inits<P extends Parser>(parsers: Parser.SubParsers<P>, delimitation?: boolean): Parser.SubNode<P> extends Parser.Node<P> ? P : Parser<Parser.SubNode<P>, Parser.Context<P>, Parser.SubParsers<P>>;
4
+ export function inits<N, D extends Parser<N>[]>(parsers: D, delimitation = false): Parser<N, Context, D> {
5
5
  assert(parsers.every(f => f));
6
6
  if (parsers.length === 1) return parsers[0];
7
7
  return input => {
@@ -10,7 +10,7 @@ export function inits<N, D extends Parser<N>[]>(parsers: D): Parser<N, Context,
10
10
  let nodes: List<Node<N>> | undefined;
11
11
  for (let len = parsers.length, i = 0; i < len; ++i) {
12
12
  if (context.position === source.length) break;
13
- if (context.delimiters.test(input)) break;
13
+ if (delimitation && context.delimiters.test(input)) break;
14
14
  const result = parsers[i](input);
15
15
  if (result === undefined) break;
16
16
  nodes = nodes?.import(result) ?? result;
@@ -1,7 +1,7 @@
1
1
  import { Parser, List, Node, Context, failsafe } from '../parser';
2
2
 
3
- export function sequence<P extends Parser>(parsers: Parser.SubParsers<P>): Parser.SubNode<P> extends Parser.Node<P> ? P : Parser<Parser.SubNode<P>, Parser.Context<P>, Parser.SubParsers<P>>;
4
- export function sequence<N, D extends Parser<N>[]>(parsers: D): Parser<N, Context, D> {
3
+ export function sequence<P extends Parser>(parsers: Parser.SubParsers<P>, delimitation?: boolean): Parser.SubNode<P> extends Parser.Node<P> ? P : Parser<Parser.SubNode<P>, Parser.Context<P>, Parser.SubParsers<P>>;
4
+ export function sequence<N, D extends Parser<N>[]>(parsers: D, delimitation = false): Parser<N, Context, D> {
5
5
  assert(parsers.every(f => f));
6
6
  if (parsers.length === 1) return parsers[0];
7
7
  return failsafe(input => {
@@ -10,7 +10,7 @@ export function sequence<N, D extends Parser<N>[]>(parsers: D): Parser<N, Contex
10
10
  let nodes: List<Node<N>> | undefined;
11
11
  for (let len = parsers.length, i = 0; i < len; ++i) {
12
12
  if (context.position === source.length) return;
13
- if (context.delimiters.test(input)) return;
13
+ if (delimitation && context.delimiters.test(input)) return;
14
14
  const result = parsers[i](input);
15
15
  if (result === undefined) return;
16
16
  nodes = nodes?.import(result) ?? result;
@@ -2,12 +2,12 @@ import { Parser, Context } from '../parser';
2
2
  import { union } from './union';
3
3
  import { inits } from './inits';
4
4
 
5
- export function subsequence<P extends Parser>(parsers: Parser.SubParsers<P>): Parser.SubNode<P> extends Parser.Node<P> ? P : Parser<Parser.SubNode<P>, Parser.Context<P>, Parser.SubParsers<P>>;
6
- export function subsequence<N, D extends Parser<N>[]>(parsers: D): Parser<N, Context, D> {
5
+ export function subsequence<P extends Parser>(parsers: Parser.SubParsers<P>, delimitation?: boolean): Parser.SubNode<P> extends Parser.Node<P> ? P : Parser<Parser.SubNode<P>, Parser.Context<P>, Parser.SubParsers<P>>;
6
+ export function subsequence<N, D extends Parser<N>[]>(parsers: D, delimitation = false): Parser<N, Context, D> {
7
7
  assert(parsers.every(f => f));
8
8
  return union(
9
9
  parsers.map((_, i) =>
10
10
  i + 1 < parsers.length
11
- ? inits([parsers[i], subsequence(parsers.slice(i + 1))])
11
+ ? inits([parsers[i], subsequence(parsers.slice(i + 1), delimitation)], delimitation)
12
12
  : parsers[i]) as D);
13
13
  }
@@ -2,7 +2,7 @@ import { Parser, Context } from '../parser';
2
2
  import { union } from './union';
3
3
  import { sequence } from './sequence';
4
4
 
5
- export function tails<P extends Parser>(parsers: Parser.SubParsers<P>): Parser.SubNode<P> extends Parser.Node<P> ? P : Parser<Parser.SubNode<P>, Parser.Context<P>, Parser.SubParsers<P>>;
6
- export function tails<N, D extends Parser<N>[]>(parsers: D): Parser<N, Context, D> {
7
- return union(parsers.map((_, i) => sequence(parsers.slice(i))) as D);
5
+ export function tails<P extends Parser>(parsers: Parser.SubParsers<P>, delimitation?: boolean): Parser.SubNode<P> extends Parser.Node<P> ? P : Parser<Parser.SubNode<P>, Parser.Context<P>, Parser.SubParsers<P>>;
6
+ export function tails<N, D extends Parser<N>[]>(parsers: D, delimitation?: boolean): Parser<N, Context, D> {
7
+ return union(parsers.map((_, i) => sequence(parsers.slice(i), delimitation)) as D);
8
8
  }
@@ -1,4 +1,4 @@
1
- import { List } from './node';
1
+ import { List } from './list/list';
2
2
  import { Delimiters } from './delimiter';
3
3
 
4
4
  export type Parser<N = unknown, C extends Context = Context, D extends Parser<unknown, C>[] = any>
@@ -5,7 +5,7 @@ import { union, some, spend, recursion, block, validate, rewrite, open, convert,
5
5
  import { autolink } from '../autolink';
6
6
  import { contentline } from '../source';
7
7
  import { unwrap, randomID } from '../util';
8
- import { parse } from '../api/parse';
8
+ import { parse } from '../../api/parse';
9
9
  import { html, defrag } from 'typed-dom/dom';
10
10
 
11
11
  export const segment: BlockquoteParser.SegmentParser = block(union([
@@ -4,7 +4,7 @@ import { List, Node } from '../../../combinator/data/parser';
4
4
  import { recursion, block, fence, fmap } from '../../../combinator';
5
5
  import { identity } from '../../inline/extension/indexee';
6
6
  import { unwrap, invalid, randomID } from '../../util';
7
- import { parse } from '../../api/parse';
7
+ import { parse } from '../../../api/parse';
8
8
  import { html } from 'typed-dom/dom';
9
9
 
10
10
  export const aside: ExtensionParser.AsideParser = block(recursion(Recursion.block, fmap(
@@ -4,7 +4,7 @@ import { List, Node, subinput } from '../../../combinator/data/parser';
4
4
  import { recursion, block, fence, fmap } from '../../../combinator';
5
5
  import { mathblock } from '../mathblock';
6
6
  import { unwrap, invalid, randomID } from '../../util';
7
- import { parse } from '../../api/parse';
7
+ import { parse } from '../../../api/parse';
8
8
  import { html } from 'typed-dom/dom';
9
9
 
10
10
  export const example: ExtensionParser.ExampleParser = block(recursion(Recursion.block, fmap(
@@ -35,7 +35,7 @@ export const textlink: LinkParser.TextLinkParser = lazy(() => bind(
35
35
  // 自己再帰的にパースしてもオプションの不要なパースによる計算量の増加により相殺される。
36
36
  dup(surround(
37
37
  /{(?![{}])/y,
38
- precedence(9, inits([uri, some(option)])),
38
+ inits([uri, some(option)]),
39
39
  / ?}/y,
40
40
  false, [],
41
41
  undefined,
@@ -83,7 +83,7 @@ export const medialink: LinkParser.MediaLinkParser = lazy(() => constraint(State
83
83
  ']')),
84
84
  dup(surround(
85
85
  /{(?![{}])/y,
86
- precedence(9, inits([uri, some(option)])),
86
+ inits([uri, some(option)]),
87
87
  / ?}/y)),
88
88
  ]),
89
89
  ([{ value: content }, { value: params }], context) =>
@@ -41,7 +41,7 @@ export const media: MediaParser = lazy(() => constraint(State.media, open(
41
41
  })),
42
42
  dup(surround(
43
43
  /{(?![{}])/y,
44
- precedence(9, inits([uri, some(option)])),
44
+ inits([uri, some(option)]),
45
45
  / ?}/y,
46
46
  false, [],
47
47
  undefined,
@@ -1,4 +1,4 @@
1
- import { invisibleBlankHTMLEntityNames } from './api/normalize';
1
+ import { invisibleBlankHTMLEntityNames } from '../api/normalize';
2
2
 
3
3
  export const enum Flag {
4
4
  none,
@@ -2,7 +2,7 @@ import { Parser, List, Node } from '../combinator/data/parser';
2
2
  import { Command } from './context';
3
3
  import { Flag } from './node';
4
4
  import { convert, fmap } from '../combinator';
5
- import { invisibleBlankHTMLEntityNames } from './api/normalize';
5
+ import { invisibleBlankHTMLEntityNames } from '../api/normalize';
6
6
 
7
7
  namespace blank {
8
8
  export const line = new RegExp(
@@ -1,12 +1,12 @@
1
1
  import { figure } from './figure';
2
- import { ParserOptions } from '../../..';
3
- import { parse as parse_ } from '../../parser';
2
+ import { ParserOptions } from '../..';
3
+ import { parse as parse_ } from '../api';
4
4
  import { html } from 'typed-dom/dom';
5
- import { normalize } from '../../debug.test';
5
+ import { normalize } from '../debug.test';
6
6
 
7
7
  const parse = (s: string, o?: ParserOptions) => parse_(s, { test: true, ...o });
8
8
 
9
- describe('Unit: parser/processor/figure', () => {
9
+ describe('Unit: processor/figure', () => {
10
10
  describe('figure', () => {
11
11
  it('empty', () => {
12
12
  const target = parse('');
@@ -1,5 +1,5 @@
1
- import { number as calculate, isFixed } from '../inline/extension/label';
2
- import { markInvalid, unmarkInvalid } from '../util';
1
+ import { number as calculate, isFixed } from '../parser/inline/extension/label';
2
+ import { markInvalid, unmarkInvalid } from '../parser/util';
3
3
  import { MultiQueue } from 'spica/queue';
4
4
  import { push } from 'spica/array';
5
5
  import { define } from 'typed-dom/dom';
@@ -1,11 +1,11 @@
1
1
  import { note } from './note';
2
- import { parse as parse_ } from '../../parser';
2
+ import { parse as parse_ } from '../api';
3
3
  import { html } from 'typed-dom/dom';
4
- import { normalize } from '../../debug.test';
4
+ import { normalize } from '../debug.test';
5
5
 
6
6
  const parse = (s: string) => parse_(s, { test: true });
7
7
 
8
- describe('Unit: parser/processor/note', () => {
8
+ describe('Unit: processor/note', () => {
9
9
  describe('annotation', () => {
10
10
  it('empty', () => {
11
11
  const target = parse('');
@@ -1,5 +1,5 @@
1
- import { identity, signature, text } from '../inline/extension/indexee';
2
- import { markInvalid, unmarkInvalid } from '../util';
1
+ import { identity, signature, text } from '../parser/inline/extension/indexee';
2
+ import { markInvalid, unmarkInvalid } from '../parser/util';
3
3
  import { memoize } from 'spica/memoize';
4
4
  import { html, define } from 'typed-dom/dom';
5
5
 
@@ -1,4 +1,4 @@
1
- import { parse } from '../../../parser';
1
+ import { parse } from '../../../api';
2
2
  import { html, define } from 'typed-dom/dom';
3
3
 
4
4
  const extensions = [
@@ -1,4 +1,4 @@
1
- import { parse } from '../../../parser';
1
+ import { parse } from '../../../api';
2
2
  import { html as h, define } from 'typed-dom/dom';
3
3
  import DOMPurify from 'dompurify';
4
4
 
@@ -1,7 +1,6 @@
1
1
  import { media } from './media';
2
- import { parse } from '../../parser';
2
+ import { parse, caches } from '../../api';
3
3
  import { html } from 'typed-dom/dom';
4
- import { caches } from '../../parser/api';
5
4
 
6
5
  describe('Unit: renderer/render/media', () => {
7
6
 
@@ -1,6 +1,6 @@
1
1
  import { render as render_ } from './render';
2
2
  import { RenderingOptions } from '../../';
3
- import { parse } from '../parser/api/parse';
3
+ import { parse } from '../api/parse';
4
4
 
5
5
  function render(target: HTMLElement, opts: RenderingOptions = {}): HTMLElement {
6
6
  render_(target, opts);
@@ -1,5 +1,5 @@
1
1
  import { info } from './info';
2
- import { parse } from '../parser';
2
+ import { parse } from '../api';
3
3
 
4
4
  describe('Unit: util/info', () => {
5
5
  describe('info', () => {
@@ -1,5 +1,5 @@
1
1
  import { quote } from './quote';
2
- import { parse } from '../parser';
2
+ import { parse } from '../api';
3
3
 
4
4
  describe('Unit: util/quote', () => {
5
5
  describe('quote', () => {
@@ -1,5 +1,5 @@
1
1
  import { toc } from './toc';
2
- import { parse } from '../parser';
2
+ import { parse } from '../api';
3
3
  import { html } from 'typed-dom/dom';
4
4
 
5
5
  describe('Unit: util/toc', () => {
package/src/parser.ts DELETED
@@ -1 +0,0 @@
1
- export * from './parser/api';
File without changes
File without changes
File without changes