securemark 0.291.0 → 0.291.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 +4 -0
- package/dist/index.js +17 -13
- package/package.json +1 -1
- package/src/combinator/control/manipulation/indent.ts +6 -2
- package/src/combinator/control/manipulation/surround.ts +6 -6
- package/src/parser/block/table.ts +2 -2
- package/src/parser/inline/reference.ts +2 -2
- package/src/parser/inline/ruby.ts +7 -7
package/CHANGELOG.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! securemark v0.291.
|
|
1
|
+
/*! securemark v0.291.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("Prism"), require("DOMPurify"));
|
|
@@ -2742,8 +2742,12 @@ const bind_1 = __webpack_require__(994);
|
|
|
2742
2742
|
const match_1 = __webpack_require__(1638);
|
|
2743
2743
|
const surround_1 = __webpack_require__(5781);
|
|
2744
2744
|
const memoize_1 = __webpack_require__(6925);
|
|
2745
|
-
function indent(opener, parser, separation = false) {
|
|
2746
|
-
if (typeof opener === 'function')
|
|
2745
|
+
function indent(opener, parser = false, separation = false) {
|
|
2746
|
+
if (typeof opener === 'function') {
|
|
2747
|
+
separation = parser;
|
|
2748
|
+
parser = opener;
|
|
2749
|
+
opener = /^([ \t])\1*/;
|
|
2750
|
+
}
|
|
2747
2751
|
return (0, bind_1.bind)((0, block_1.block)((0, match_1.match)(opener, (0, memoize_1.memoize)(([indent]) => (0, some_1.some)((0, line_1.line)((0, surround_1.open)(indent, ({
|
|
2748
2752
|
source
|
|
2749
2753
|
}) => [[source], '']))), ([indent]) => indent.length * 2 + +(indent[0] === ' '), {})), separation), (lines, rest, context) => {
|
|
@@ -2979,7 +2983,7 @@ function surround(opener, parser, closer, optional = false, f, g, backtracks = [
|
|
|
2979
2983
|
if (!nodesM && !optional) return void revert(context, linebreak);
|
|
2980
2984
|
if (rest.length === sme_.length) return void revert(context, linebreak);
|
|
2981
2985
|
context.recent = [sme_.slice(0, sme_.length - me_.length), me_.slice(0, me_.length - e_.length), e_.slice(0, e_.length - rest.length)];
|
|
2982
|
-
const result = nodesE ? f ? f([nodesS, nodesM, nodesE], rest, context) : [(0, array_1.push)((0, array_1.unshift)(nodesS, nodesM ?? []), nodesE), rest] : g ? g([nodesS, nodesM
|
|
2986
|
+
const result = nodesE ? f ? f([nodesS, nodesM, nodesE], rest, context) : [(0, array_1.push)((0, array_1.unshift)(nodesS, nodesM ?? []), nodesE), rest] : g ? g([nodesS, nodesM], rest, context) : undefined;
|
|
2983
2987
|
if (result) {
|
|
2984
2988
|
context.linebreak ||= linebreak;
|
|
2985
2989
|
} else {
|
|
@@ -5428,9 +5432,9 @@ const row = (parser, optional) => (0, combinator_1.fallback)((0, combinator_1.fm
|
|
|
5428
5432
|
}, [(0, dom_1.html)('td', source.replace('\n', ''))])], '']));
|
|
5429
5433
|
const align = (0, combinator_1.fmap)((0, combinator_1.open)('|', (0, combinator_1.union)([(0, combinator_1.focus)(/^:-+:?/, ({
|
|
5430
5434
|
source
|
|
5431
|
-
}) => [[source
|
|
5435
|
+
}) => [[source.at(-1) === ':' ? 'center' : 'start'], ''], false), (0, combinator_1.focus)(/^-+:?/, ({
|
|
5432
5436
|
source
|
|
5433
|
-
}) => [[source
|
|
5437
|
+
}) => [[source.at(-1) === ':' ? 'end' : ''], ''], false)])), ns => [(0, dom_1.html)('td', (0, dom_1.defrag)(ns))]);
|
|
5434
5438
|
const cell = (0, combinator_1.surround)(/^\|\s*(?=\S)/, (0, combinator_1.trimStart)((0, combinator_1.union)([(0, combinator_1.close)(inline_1.medialink, /^\s*(?=\||$)/), (0, combinator_1.close)(inline_1.media, /^\s*(?=\||$)/), (0, combinator_1.close)(inline_1.shortmedia, /^\s*(?=\||$)/), (0, visibility_1.trimBlank)((0, combinator_1.some)(inline_1.inline, /^\|/, [[/^[|\\]?\s*$/, 9]]))])), /^[^|]*/, true);
|
|
5435
5439
|
const head = (0, combinator_1.fmap)(cell, ns => [(0, dom_1.html)('th', (0, dom_1.defrag)(ns))]);
|
|
5436
5440
|
const data = (0, combinator_1.fmap)(cell, ns => [(0, dom_1.html)('td', (0, dom_1.defrag)(ns))]);
|
|
@@ -6929,7 +6933,7 @@ exports.reference = (0, combinator_1.lazy)(() => (0, combinator_1.constraint)(64
|
|
|
6929
6933
|
return context.state & 128 /* State.annotation */ ? [(0, array_1.unshift)(as, bs), rest] : undefined;
|
|
6930
6934
|
}, [3 | 16 /* Backtrack.doublebracket */, 1 | 8 /* Backtrack.bracket */])));
|
|
6931
6935
|
// Chicago-Style
|
|
6932
|
-
const abbr = (0, combinator_1.surround)('^', (0, combinator_1.union)([(0, source_1.str)(/^(?=[A-Z])(?:[0-9A-Za-z]'?|(?:[-.:]|\.?\??,? ?)(?!['\-.:?, ]))+/)]), /^\|?(?=]])|^\|[^\S\n]*/, true, ([, ns], rest) => ns ? [["\u001B" /* Command.Escape */, ns[0].trimEnd()], rest.replace(visibility_1.blank.start, '')] : [[''], `^${rest}`], ([
|
|
6936
|
+
const abbr = (0, combinator_1.surround)((0, source_1.str)('^'), (0, combinator_1.union)([(0, source_1.str)(/^(?=[A-Z])(?:[0-9A-Za-z]'?|(?:[-.:]|\.?\??,? ?)(?!['\-.:?, ]))+/)]), /^\|?(?=]])|^\|[^\S\n]*/, true, ([, ns], rest) => ns ? [["\u001B" /* Command.Escape */, ns[0].trimEnd()], rest.replace(visibility_1.blank.start, '')] : [[''], `^${rest}`], ([as, bs = ['']], rest) => [[''], as[0] + bs[0] + rest]);
|
|
6933
6937
|
function attributes(ns) {
|
|
6934
6938
|
switch (ns[0]) {
|
|
6935
6939
|
case '':
|
|
@@ -6994,10 +6998,10 @@ const source_1 = __webpack_require__(8745);
|
|
|
6994
6998
|
const visibility_1 = __webpack_require__(6364);
|
|
6995
6999
|
const array_1 = __webpack_require__(6876);
|
|
6996
7000
|
const dom_1 = __webpack_require__(394);
|
|
6997
|
-
exports.ruby = (0, combinator_1.lazy)(() => (0, combinator_1.bind)((0, combinator_1.inits)([(0, combinator_1.dup)((0, combinator_1.surround)('[',
|
|
7001
|
+
exports.ruby = (0, combinator_1.lazy)(() => (0, combinator_1.bind)((0, combinator_1.inits)([(0, combinator_1.dup)((0, combinator_1.surround)('[', text, ']', false, ([, ns], rest) => {
|
|
6998
7002
|
ns && ns.at(-1) === '' && ns.pop();
|
|
6999
7003
|
return (0, visibility_1.isTightNodeStart)(ns) ? [ns, rest] : undefined;
|
|
7000
|
-
}, undefined, [3 | 32 /* Backtrack.ruby */, 1 | 8 /* Backtrack.bracket */])), (0, combinator_1.dup)((0, combinator_1.surround)('(',
|
|
7004
|
+
}, undefined, [3 | 32 /* Backtrack.ruby */, 1 | 8 /* Backtrack.bracket */])), (0, combinator_1.dup)((0, combinator_1.surround)('(', text, ')', false, undefined, undefined, [3 | 32 /* Backtrack.ruby */, 1 | 8 /* Backtrack.bracket */]))]), ([texts, rubies], rest, context) => {
|
|
7001
7005
|
if (rubies === undefined) {
|
|
7002
7006
|
const head = context.recent.reduce((a, b) => a + b.length, rest.length);
|
|
7003
7007
|
return void (0, combinator_1.setBacktrack)(context, [2 | 32 /* Backtrack.ruby */], head);
|
|
@@ -7011,7 +7015,7 @@ exports.ruby = (0, combinator_1.lazy)(() => (0, combinator_1.bind)((0, combinato
|
|
|
7011
7015
|
return [[(0, dom_1.html)('ruby', (0, dom_1.defrag)((0, array_1.unshift)([texts.join(' ')], [(0, dom_1.html)('rp', '('), (0, dom_1.html)('rt', rubies.join(' ').trim()), (0, dom_1.html)('rp', ')')])))], rest];
|
|
7012
7016
|
}
|
|
7013
7017
|
}));
|
|
7014
|
-
const
|
|
7018
|
+
const text = ({
|
|
7015
7019
|
source,
|
|
7016
7020
|
context
|
|
7017
7021
|
}) => {
|
|
@@ -7030,7 +7034,6 @@ const rtext = ({
|
|
|
7030
7034
|
if (result) {
|
|
7031
7035
|
acc[acc.length - 1] += (0, parser_1.eval)(result)[0];
|
|
7032
7036
|
source = (0, parser_1.exec)(result) ?? source.slice(1);
|
|
7033
|
-
state ||= acc.at(-1).trimStart() !== '';
|
|
7034
7037
|
continue;
|
|
7035
7038
|
}
|
|
7036
7039
|
// fallthrough
|
|
@@ -7038,21 +7041,22 @@ const rtext = ({
|
|
|
7038
7041
|
default:
|
|
7039
7042
|
{
|
|
7040
7043
|
if (source[0].trimStart() === '') {
|
|
7044
|
+
state ||= acc.at(-1).trimStart() !== '';
|
|
7041
7045
|
acc.push('');
|
|
7042
7046
|
source = source.slice(1);
|
|
7043
7047
|
continue;
|
|
7044
7048
|
}
|
|
7045
|
-
const result = (0, source_1.
|
|
7049
|
+
const result = (0, source_1.txt)({
|
|
7046
7050
|
source,
|
|
7047
7051
|
context
|
|
7048
7052
|
});
|
|
7049
7053
|
acc[acc.length - 1] += (0, parser_1.eval)(result)[0] ?? source.slice(0, source.length - (0, parser_1.exec)(result).length);
|
|
7050
7054
|
source = (0, parser_1.exec)(result);
|
|
7051
|
-
state ||= acc.at(-1).trimStart() !== '';
|
|
7052
7055
|
continue;
|
|
7053
7056
|
}
|
|
7054
7057
|
}
|
|
7055
7058
|
}
|
|
7059
|
+
state ||= acc.at(-1).trimStart() !== '';
|
|
7056
7060
|
return state ? [acc, source] : undefined;
|
|
7057
7061
|
};
|
|
7058
7062
|
//function attributes(texts: string[], rubies: string[]): Record<string, string> {
|
package/package.json
CHANGED
|
@@ -9,8 +9,12 @@ import { memoize } from 'spica/memoize';
|
|
|
9
9
|
|
|
10
10
|
export function indent<P extends Parser<unknown>>(parser: P, separation?: boolean): P;
|
|
11
11
|
export function indent<P extends Parser<unknown>>(opener: RegExp, parser: P, separation?: boolean): P;
|
|
12
|
-
export function indent<N>(opener: RegExp | Parser<N>, parser
|
|
13
|
-
if (typeof opener === 'function')
|
|
12
|
+
export function indent<N>(opener: RegExp | Parser<N>, parser: Parser<N> | boolean = false, separation = false): Parser<N> {
|
|
13
|
+
if (typeof opener === 'function') {
|
|
14
|
+
separation = parser as boolean;
|
|
15
|
+
parser = opener;
|
|
16
|
+
opener = /^([ \t])\1*/;
|
|
17
|
+
}
|
|
14
18
|
assert(parser);
|
|
15
19
|
return bind(block(match(
|
|
16
20
|
opener,
|
|
@@ -6,35 +6,35 @@ export function surround<P extends Parser<unknown>, S = string>(
|
|
|
6
6
|
opener: string | RegExp | Parser<S, Context<P>>, parser: IntermediateParser<P>, closer: string | RegExp | Parser<S, Context<P>>,
|
|
7
7
|
optional?: false,
|
|
8
8
|
f?: (rss: [S[], SubNode<P>[], S[]], rest: string, context: Context<P>) => Result<Node<P>, Context<P>, SubParsers<P>>,
|
|
9
|
-
g?: (rss: [S[], SubNode<P>[]
|
|
9
|
+
g?: (rss: [S[], SubNode<P>[]], rest: string, context: Context<P>) => Result<Node<P>, Context<P>, SubParsers<P>>,
|
|
10
10
|
backtracks?: readonly number[],
|
|
11
11
|
): P;
|
|
12
12
|
export function surround<P extends Parser<unknown>, S = string>(
|
|
13
13
|
opener: string | RegExp | Parser<S, Context<P>>, parser: IntermediateParser<P>, closer: string | RegExp | Parser<S, Context<P>>,
|
|
14
14
|
optional?: boolean,
|
|
15
15
|
f?: (rss: [S[], SubNode<P>[] | undefined, S[]], rest: string, context: Context<P>) => Result<Node<P>, Context<P>, SubParsers<P>>,
|
|
16
|
-
g?: (rss: [S[], SubNode<P>[] | undefined
|
|
16
|
+
g?: (rss: [S[], SubNode<P>[] | undefined], rest: string, context: Context<P>) => Result<Node<P>, Context<P>, SubParsers<P>>,
|
|
17
17
|
backtracks?: readonly number[],
|
|
18
18
|
): P;
|
|
19
19
|
export function surround<P extends Parser<unknown>, S = string>(
|
|
20
20
|
opener: string | RegExp | Parser<S, Context<P>>, parser: P, closer: string | RegExp | Parser<S, Context<P>>,
|
|
21
21
|
optional?: false,
|
|
22
22
|
f?: (rss: [S[], Node<P>[], S[]], rest: string, context: Context<P>) => Result<Node<P>, Context<P>, SubParsers<P>>,
|
|
23
|
-
g?: (rss: [S[], Node<P>[]
|
|
23
|
+
g?: (rss: [S[], Node<P>[]], rest: string, context: Context<P>) => Result<Node<P>, Context<P>, SubParsers<P>>,
|
|
24
24
|
backtracks?: readonly number[],
|
|
25
25
|
): P;
|
|
26
26
|
export function surround<P extends Parser<unknown>, S = string>(
|
|
27
27
|
opener: string | RegExp | Parser<S, Context<P>>, parser: P, closer: string | RegExp | Parser<S, Context<P>>,
|
|
28
28
|
optional?: boolean,
|
|
29
29
|
f?: (rss: [S[], Node<P>[] | undefined, S[]], rest: string, context: Context<P>) => Result<Node<P>, Context<P>, SubParsers<P>>,
|
|
30
|
-
g?: (rss: [S[], Node<P>[] | undefined
|
|
30
|
+
g?: (rss: [S[], Node<P>[] | undefined], rest: string, context: Context<P>) => Result<Node<P>, Context<P>, SubParsers<P>>,
|
|
31
31
|
backtracks?: readonly number[],
|
|
32
32
|
): P;
|
|
33
33
|
export function surround<N>(
|
|
34
34
|
opener: string | RegExp | Parser<N>, parser: Parser<N>, closer: string | RegExp | Parser<N>,
|
|
35
35
|
optional: boolean = false,
|
|
36
36
|
f?: (rss: [N[], N[], N[]], rest: string, context: Ctx) => Result<N>,
|
|
37
|
-
g?: (rss: [N[], N[]
|
|
37
|
+
g?: (rss: [N[], N[]], rest: string, context: Ctx) => Result<N>,
|
|
38
38
|
backtracks: readonly number[] = [],
|
|
39
39
|
): Parser<N> {
|
|
40
40
|
switch (typeof opener) {
|
|
@@ -79,7 +79,7 @@ export function surround<N>(
|
|
|
79
79
|
? f([nodesS, nodesM!, nodesE], rest, context)
|
|
80
80
|
: [push(unshift(nodesS, nodesM ?? []), nodesE), rest] satisfies [N[], string]
|
|
81
81
|
: g
|
|
82
|
-
? g([nodesS, nodesM
|
|
82
|
+
? g([nodesS, nodesM!], rest, context)
|
|
83
83
|
: undefined;
|
|
84
84
|
if (result) {
|
|
85
85
|
context.linebreak ||= linebreak;
|
|
@@ -40,9 +40,9 @@ const align: AlignParser = fmap(open(
|
|
|
40
40
|
'|',
|
|
41
41
|
union([
|
|
42
42
|
focus(/^:-+:?/, ({ source }) =>
|
|
43
|
-
[[source
|
|
43
|
+
[[source.at(-1) === ':' ? 'center' : 'start'], ''], false),
|
|
44
44
|
focus(/^-+:?/, ({ source }) =>
|
|
45
|
-
[[source
|
|
45
|
+
[[source.at(-1) === ':' ? 'end' : ''], ''], false),
|
|
46
46
|
])),
|
|
47
47
|
ns => [html('td', defrag(ns))]);
|
|
48
48
|
|
|
@@ -91,12 +91,12 @@ export const reference: ReferenceParser = lazy(() => constraint(State.reference,
|
|
|
91
91
|
|
|
92
92
|
// Chicago-Style
|
|
93
93
|
const abbr: ReferenceParser.AbbrParser = surround(
|
|
94
|
-
'^',
|
|
94
|
+
str('^'),
|
|
95
95
|
union([str(/^(?=[A-Z])(?:[0-9A-Za-z]'?|(?:[-.:]|\.?\??,? ?)(?!['\-.:?, ]))+/)]),
|
|
96
96
|
/^\|?(?=]])|^\|[^\S\n]*/,
|
|
97
97
|
true,
|
|
98
98
|
([, ns], rest) => ns ? [[Command.Escape, ns[0].trimEnd()], rest.replace(blank.start, '')] : [[''], `^${rest}`],
|
|
99
|
-
([, , rest
|
|
99
|
+
([as, bs = ['']], rest) => [[''], as[0] + bs[0] + rest]);
|
|
100
100
|
|
|
101
101
|
function attributes(ns: (string | HTMLElement)[]): Record<string, string | undefined> {
|
|
102
102
|
switch (ns[0]) {
|
|
@@ -3,7 +3,7 @@ import { Backtrack } from '../context';
|
|
|
3
3
|
import { eval, exec } from '../../combinator/data/parser';
|
|
4
4
|
import { inits, surround, setBacktrack, dup, lazy, bind } from '../../combinator';
|
|
5
5
|
import { unsafehtmlentity } from './htmlentity';
|
|
6
|
-
import {
|
|
6
|
+
import { txt } from '../source';
|
|
7
7
|
import { isTightNodeStart } from '../visibility';
|
|
8
8
|
import { unshift, push } from 'spica/array';
|
|
9
9
|
import { html, defrag } from 'typed-dom/dom';
|
|
@@ -11,7 +11,7 @@ import { html, defrag } from 'typed-dom/dom';
|
|
|
11
11
|
export const ruby: RubyParser = lazy(() => bind(
|
|
12
12
|
inits([
|
|
13
13
|
dup(surround(
|
|
14
|
-
'[',
|
|
14
|
+
'[', text, ']',
|
|
15
15
|
false,
|
|
16
16
|
([, ns], rest) => {
|
|
17
17
|
ns && ns.at(-1) === '' && ns.pop();
|
|
@@ -20,7 +20,7 @@ export const ruby: RubyParser = lazy(() => bind(
|
|
|
20
20
|
undefined,
|
|
21
21
|
[3 | Backtrack.ruby, 1 | Backtrack.bracket])),
|
|
22
22
|
dup(surround(
|
|
23
|
-
'(',
|
|
23
|
+
'(', text, ')',
|
|
24
24
|
false, undefined, undefined,
|
|
25
25
|
[3 | Backtrack.ruby, 1 | Backtrack.bracket])),
|
|
26
26
|
]),
|
|
@@ -62,7 +62,7 @@ export const ruby: RubyParser = lazy(() => bind(
|
|
|
62
62
|
}
|
|
63
63
|
}));
|
|
64
64
|
|
|
65
|
-
const
|
|
65
|
+
const text: RubyParser.TextParser = ({ source, context }) => {
|
|
66
66
|
const acc = [''];
|
|
67
67
|
let state = false;
|
|
68
68
|
while (source !== '') {
|
|
@@ -75,26 +75,26 @@ const rtext: RubyParser.TextParser = ({ source, context }) => {
|
|
|
75
75
|
if (result) {
|
|
76
76
|
acc[acc.length - 1] += eval(result)[0];
|
|
77
77
|
source = exec(result) ?? source.slice(1);
|
|
78
|
-
state ||= acc.at(-1)!.trimStart() !== '';
|
|
79
78
|
continue;
|
|
80
79
|
}
|
|
81
80
|
// fallthrough
|
|
82
81
|
}
|
|
83
82
|
default: {
|
|
84
83
|
if (source[0].trimStart() === '') {
|
|
84
|
+
state ||= acc.at(-1)!.trimStart() !== '';
|
|
85
85
|
acc.push('');
|
|
86
86
|
source = source.slice(1);
|
|
87
87
|
continue;
|
|
88
88
|
}
|
|
89
|
-
const result =
|
|
89
|
+
const result = txt({ source, context })!;
|
|
90
90
|
assert(result);
|
|
91
91
|
acc[acc.length - 1] += eval(result)[0] ?? source.slice(0, source.length - exec(result).length);
|
|
92
92
|
source = exec(result);
|
|
93
|
-
state ||= acc.at(-1)!.trimStart() !== '';
|
|
94
93
|
continue;
|
|
95
94
|
}
|
|
96
95
|
}
|
|
97
96
|
}
|
|
97
|
+
state ||= acc.at(-1)!.trimStart() !== '';
|
|
98
98
|
return state
|
|
99
99
|
? [acc, source]
|
|
100
100
|
: undefined;
|