securemark 0.293.4 → 0.294.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 +8 -0
- package/dist/index.js +868 -564
- package/markdown.d.ts +13 -13
- package/package.json +3 -3
- package/src/combinator/control/constraint/block.test.ts +6 -6
- package/src/combinator/control/constraint/contract.ts +3 -3
- package/src/combinator/control/constraint/line.test.ts +7 -7
- package/src/combinator/control/constraint/line.ts +1 -1
- package/src/combinator/control/manipulation/clear.ts +2 -3
- package/src/combinator/control/manipulation/convert.ts +2 -2
- package/src/combinator/control/manipulation/duplicate.ts +4 -5
- package/src/combinator/control/manipulation/fence.ts +2 -2
- package/src/combinator/control/manipulation/indent.test.ts +2 -2
- package/src/combinator/control/manipulation/indent.ts +4 -4
- package/src/combinator/control/manipulation/reverse.ts +2 -2
- package/src/combinator/control/manipulation/scope.ts +3 -4
- package/src/combinator/control/manipulation/surround.ts +14 -15
- package/src/combinator/control/monad/bind.ts +6 -6
- package/src/combinator/control/monad/fmap.ts +7 -7
- package/src/combinator/data/data.ts +135 -0
- package/src/combinator/data/parser/context.test.ts +16 -15
- package/src/combinator/data/parser/context.ts +5 -4
- package/src/combinator/data/parser/inits.ts +6 -7
- package/src/combinator/data/parser/sequence.test.ts +3 -3
- package/src/combinator/data/parser/sequence.ts +6 -7
- package/src/combinator/data/parser/some.test.ts +3 -3
- package/src/combinator/data/parser/some.ts +4 -4
- package/src/combinator/data/parser/subsequence.test.ts +4 -4
- package/src/combinator/data/parser/subsequence.ts +3 -3
- package/src/combinator/data/parser/tails.ts +3 -3
- package/src/combinator/data/parser/union.test.ts +3 -3
- package/src/combinator/data/parser.ts +16 -7
- package/src/debug.test.ts +6 -5
- package/src/parser/api/bind.ts +6 -8
- package/src/parser/api/header.ts +1 -1
- package/src/parser/api/normalize.ts +2 -4
- package/src/parser/api/parse.ts +3 -1
- package/src/parser/block/blockquote.ts +6 -4
- package/src/parser/block/codeblock.ts +8 -7
- package/src/parser/block/dlist.ts +9 -8
- package/src/parser/block/extension/aside.ts +27 -21
- package/src/parser/block/extension/example.ts +29 -26
- package/src/parser/block/extension/fig.ts +1 -1
- package/src/parser/block/extension/figbase.ts +6 -5
- package/src/parser/block/extension/figure.ts +23 -19
- package/src/parser/block/extension/message.ts +35 -24
- package/src/parser/block/extension/placeholder.ts +17 -13
- package/src/parser/block/extension/table.ts +47 -40
- package/src/parser/block/heading.test.ts +3 -12
- package/src/parser/block/heading.ts +12 -8
- package/src/parser/block/ilist.ts +13 -12
- package/src/parser/block/mathblock.ts +21 -17
- package/src/parser/block/mediablock.ts +7 -5
- package/src/parser/block/olist.ts +15 -5
- package/src/parser/block/pagebreak.ts +2 -1
- package/src/parser/block/paragraph.ts +3 -1
- package/src/parser/block/reply/cite.ts +20 -15
- package/src/parser/block/reply/quote.ts +9 -7
- package/src/parser/block/reply.ts +7 -3
- package/src/parser/block/sidefence.ts +8 -7
- package/src/parser/block/table.ts +23 -22
- package/src/parser/block/ulist.ts +16 -12
- package/src/parser/block.ts +7 -6
- package/src/parser/header.test.ts +3 -1
- package/src/parser/header.ts +20 -20
- package/src/parser/inline/annotation.ts +3 -1
- package/src/parser/inline/autolink/account.ts +3 -2
- package/src/parser/inline/autolink/anchor.ts +3 -2
- package/src/parser/inline/autolink/channel.ts +5 -4
- package/src/parser/inline/autolink/email.ts +4 -3
- package/src/parser/inline/autolink/hashnum.ts +3 -2
- package/src/parser/inline/autolink/hashtag.ts +4 -3
- package/src/parser/inline/autolink/url.ts +7 -6
- package/src/parser/inline/bracket.ts +16 -15
- package/src/parser/inline/code.ts +5 -4
- package/src/parser/inline/deletion.ts +5 -5
- package/src/parser/inline/emphasis.ts +4 -3
- package/src/parser/inline/emstrong.test.ts +18 -18
- package/src/parser/inline/emstrong.ts +39 -30
- package/src/parser/inline/extension/index.ts +22 -19
- package/src/parser/inline/extension/indexee.ts +2 -2
- package/src/parser/inline/extension/indexer.ts +2 -1
- package/src/parser/inline/extension/label.ts +7 -3
- package/src/parser/inline/extension/placeholder.ts +6 -6
- package/src/parser/inline/html.ts +27 -28
- package/src/parser/inline/htmlentity.ts +9 -8
- package/src/parser/inline/insertion.ts +5 -5
- package/src/parser/inline/italic.ts +5 -5
- package/src/parser/inline/link.ts +36 -38
- package/src/parser/inline/mark.ts +7 -7
- package/src/parser/inline/math.ts +5 -4
- package/src/parser/inline/media.ts +33 -32
- package/src/parser/inline/reference.ts +19 -20
- package/src/parser/inline/remark.ts +11 -11
- package/src/parser/inline/ruby.ts +50 -53
- package/src/parser/inline/strong.ts +4 -3
- package/src/parser/inline/template.ts +16 -15
- package/src/parser/inline.test.ts +3 -3
- package/src/parser/segment.ts +3 -1
- package/src/parser/source/escapable.ts +9 -8
- package/src/parser/source/line.ts +4 -3
- package/src/parser/source/str.ts +2 -2
- package/src/parser/source/text.ts +19 -26
- package/src/parser/source/unescapable.ts +6 -5
- package/src/parser/util.ts +16 -30
- package/src/parser/visibility.ts +19 -20
package/src/parser/visibility.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { MarkdownParser } from '../../markdown';
|
|
2
2
|
import { Command } from './context';
|
|
3
|
-
import { Parser, Input, eval, failsafe } from '../combinator/data/parser';
|
|
3
|
+
import { Parser, Input, List, Data, eval, failsafe } from '../combinator/data/parser';
|
|
4
4
|
import { convert, fmap } from '../combinator';
|
|
5
5
|
import { unsafehtmlentity } from './inline/htmlentity';
|
|
6
6
|
import { invisibleHTMLEntityNames } from './api/normalize';
|
|
7
|
-
import { push } from 'spica/array';
|
|
8
7
|
|
|
9
8
|
export namespace blank {
|
|
10
9
|
export const line = new RegExp(
|
|
@@ -94,7 +93,7 @@ function isTightStart(input: Input<MarkdownParser.Context>, except?: string): bo
|
|
|
94
93
|
switch (true) {
|
|
95
94
|
case source.length - position > 2
|
|
96
95
|
&& source[position + 1] !== ' '
|
|
97
|
-
&& eval(unsafehtmlentity(input))?.
|
|
96
|
+
&& eval(unsafehtmlentity(input))?.head?.value.trimStart() === '':
|
|
98
97
|
context.position = position;
|
|
99
98
|
return false;
|
|
100
99
|
}
|
|
@@ -114,18 +113,17 @@ function isTightStart(input: Input<MarkdownParser.Context>, except?: string): bo
|
|
|
114
113
|
}
|
|
115
114
|
}
|
|
116
115
|
|
|
117
|
-
export function isLooseNodeStart(nodes:
|
|
116
|
+
export function isLooseNodeStart(nodes: List<Data<HTMLElement | string>>): boolean {
|
|
118
117
|
if (nodes.length === 0) return true;
|
|
119
|
-
for (
|
|
120
|
-
const node = nodes[i];
|
|
118
|
+
for (const { value: node } of nodes) {
|
|
121
119
|
if (isVisible(node)) return true;
|
|
122
120
|
if (typeof node === 'object' && node.tagName === 'BR') break;
|
|
123
121
|
}
|
|
124
122
|
return false;
|
|
125
123
|
}
|
|
126
|
-
export function isTightNodeStart(nodes:
|
|
124
|
+
export function isTightNodeStart(nodes: List<Data<HTMLElement | string>>): boolean {
|
|
127
125
|
if (nodes.length === 0) return true;
|
|
128
|
-
return isVisible(nodes
|
|
126
|
+
return isVisible(nodes.head!.value, 0);
|
|
129
127
|
}
|
|
130
128
|
//export function isTightNodeEnd(nodes: readonly (HTMLElement | string)[]): boolean {
|
|
131
129
|
// if (nodes.length === 0) return true;
|
|
@@ -173,12 +171,12 @@ export function trimBlankStart<N>(parser: Parser<N>): Parser<N> {
|
|
|
173
171
|
reg.test(source);
|
|
174
172
|
context.position = reg.lastIndex || position;
|
|
175
173
|
return context.position === source.length
|
|
176
|
-
?
|
|
174
|
+
? new List()
|
|
177
175
|
: parser(input);
|
|
178
176
|
});
|
|
179
177
|
}
|
|
180
178
|
export function trimBlankEnd<P extends Parser<HTMLElement | string>>(parser: P): P;
|
|
181
|
-
export function trimBlankEnd<N extends HTMLElement
|
|
179
|
+
export function trimBlankEnd<N extends HTMLElement>(parser: Parser<N>): Parser<string | N> {
|
|
182
180
|
return fmap(parser, trimBlankNodeEnd);
|
|
183
181
|
}
|
|
184
182
|
//export function trimBlankNode<N extends HTMLElement | string>(nodes: N[]): N[] {
|
|
@@ -200,21 +198,22 @@ export function trimBlankEnd<N extends HTMLElement | string>(parser: Parser<N>):
|
|
|
200
198
|
// }
|
|
201
199
|
// return nodes;
|
|
202
200
|
//}
|
|
203
|
-
export function trimBlankNodeEnd<N extends HTMLElement
|
|
201
|
+
export function trimBlankNodeEnd<N extends HTMLElement>(nodes: List<Data<string | N>>): List<Data<string | N>> {
|
|
204
202
|
const skip = nodes.length > 0 &&
|
|
205
|
-
typeof nodes.
|
|
206
|
-
nodes.
|
|
207
|
-
?
|
|
208
|
-
:
|
|
209
|
-
for (let node = nodes
|
|
210
|
-
if (typeof node === 'string') {
|
|
211
|
-
const str = node.trimEnd();
|
|
203
|
+
typeof nodes.last?.value === 'object' &&
|
|
204
|
+
nodes.last.value.className === 'indexer'
|
|
205
|
+
? nodes.pop()
|
|
206
|
+
: undefined;
|
|
207
|
+
for (let node = nodes.last; nodes.length > 0 && !isVisible((node = nodes.last!).value, -1);) {
|
|
208
|
+
if (typeof node.value === 'string') {
|
|
209
|
+
const str = node.value.trimEnd();
|
|
212
210
|
if (str.length > 0) {
|
|
213
|
-
|
|
211
|
+
node.value = str;
|
|
214
212
|
break;
|
|
215
213
|
}
|
|
216
214
|
}
|
|
217
215
|
nodes.pop();
|
|
218
216
|
}
|
|
219
|
-
|
|
217
|
+
skip && nodes.push(skip);
|
|
218
|
+
return nodes;
|
|
220
219
|
}
|