@limetech/lime-elements 40.5.4 → 40.6.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 +11 -0
- package/dist/cjs/{index-ETPz91V5.js → index-zZvs6xK-.js} +9382 -9504
- package/dist/cjs/lime-elements.cjs.js +1 -1
- package/dist/cjs/limel-file-viewer.cjs.entry.js +1 -1
- package/dist/cjs/limel-markdown.cjs.entry.js +28 -4
- package/dist/cjs/limel-prosemirror-adapter.cjs.entry.js +2 -2
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/markdown-exporter-9p7d3Q76.js +6210 -0
- package/dist/cjs/{markdown-parser-YH5HSSgF.js → markdown-parser-Cgv5Y9Z4.js} +579 -848
- package/dist/collection/components/markdown/markdown-exporter.js +186 -0
- package/dist/collection/components/markdown/markdown-parser.js +2 -3
- package/dist/collection/components/markdown/markdown.js +54 -2
- package/dist/esm/{index-CbciMfiU.js → index-BN64nlbO.js} +9369 -9505
- package/dist/esm/lime-elements.js +1 -1
- package/dist/esm/limel-file-viewer.entry.js +1 -1
- package/dist/esm/limel-markdown.entry.js +28 -4
- package/dist/esm/limel-prosemirror-adapter.entry.js +2 -2
- package/dist/esm/loader.js +1 -1
- package/dist/esm/markdown-exporter--3_MaqwD.js +6208 -0
- package/dist/esm/{markdown-parser-DrxxGLF5.js → markdown-parser-DCf-3dKZ.js} +506 -791
- package/dist/lime-elements/lime-elements.esm.js +1 -1
- package/dist/lime-elements/{p-05afb316.entry.js → p-20658306.entry.js} +1 -1
- package/dist/lime-elements/p-BPzhuHcl.js +1 -0
- package/dist/lime-elements/p-CC4Usa-Q.js +7 -0
- package/dist/lime-elements/p-_UXAljNc.js +1 -0
- package/dist/lime-elements/p-dc9cd793.entry.js +1 -0
- package/dist/lime-elements/{p-10594468.entry.js → p-dd62042a.entry.js} +1 -1
- package/dist/types/components/markdown/markdown-exporter.d.ts +15 -0
- package/dist/types/components/markdown/markdown.d.ts +19 -0
- package/dist/types/components.d.ts +10 -0
- package/dist/types/global/shared-types/custom-element.types.d.ts +25 -0
- package/package.json +7 -1
- package/dist/lime-elements/p-6d5b23ad.entry.js +0 -1
- package/dist/lime-elements/p-C9xHOCE_.js +0 -7
- package/dist/lime-elements/p-DMNtoJ8I.js +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var _commonjsHelpers = require('./_commonjsHelpers-CFO10eej.js');
|
|
4
|
-
var index$
|
|
4
|
+
var index$1 = require('./index-zZvs6xK-.js');
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
*
|
|
@@ -3463,7 +3463,7 @@ function resolveAll(constructs, events, context) {
|
|
|
3463
3463
|
*/
|
|
3464
3464
|
|
|
3465
3465
|
/** @type {Construct} */
|
|
3466
|
-
const attention = {
|
|
3466
|
+
const attention$2 = {
|
|
3467
3467
|
name: 'attention',
|
|
3468
3468
|
tokenize: tokenizeAttention,
|
|
3469
3469
|
resolveAll: resolveAllAttention
|
|
@@ -10692,18 +10692,18 @@ const text$5 = {
|
|
|
10692
10692
|
[-3]: lineEnding,
|
|
10693
10693
|
[33]: labelStartImage,
|
|
10694
10694
|
[38]: characterReference,
|
|
10695
|
-
[42]: attention,
|
|
10695
|
+
[42]: attention$2,
|
|
10696
10696
|
[60]: [autolink, htmlText],
|
|
10697
10697
|
[91]: labelStartLink,
|
|
10698
10698
|
[92]: [hardBreakEscape, characterEscape],
|
|
10699
10699
|
[93]: labelEnd,
|
|
10700
|
-
[95]: attention,
|
|
10700
|
+
[95]: attention$2,
|
|
10701
10701
|
[96]: codeText
|
|
10702
10702
|
};
|
|
10703
10703
|
|
|
10704
10704
|
/** @satisfies {Extension['insideSpan']} */
|
|
10705
10705
|
const insideSpan = {
|
|
10706
|
-
null: [attention, resolver]
|
|
10706
|
+
null: [attention$2, resolver]
|
|
10707
10707
|
};
|
|
10708
10708
|
|
|
10709
10709
|
/** @satisfies {Extension['attentionMarkers']} */
|
|
@@ -10742,7 +10742,7 @@ var defaultConstructs = /*#__PURE__*/Object.freeze({
|
|
|
10742
10742
|
* @param {ParseOptions | null | undefined} [options]
|
|
10743
10743
|
* @returns {ParseContext}
|
|
10744
10744
|
*/
|
|
10745
|
-
function parse
|
|
10745
|
+
function parse(options) {
|
|
10746
10746
|
const settings = options || {};
|
|
10747
10747
|
const constructs =
|
|
10748
10748
|
/** @type {FullNormalizedExtension} */
|
|
@@ -10804,7 +10804,7 @@ function postprocess(events) {
|
|
|
10804
10804
|
* @returns {Array<Chunk>}
|
|
10805
10805
|
*/
|
|
10806
10806
|
|
|
10807
|
-
const search$
|
|
10807
|
+
const search$1 = /[\0\t\n\r]/g;
|
|
10808
10808
|
|
|
10809
10809
|
/**
|
|
10810
10810
|
* @returns {Preprocessor}
|
|
@@ -10848,8 +10848,8 @@ function preprocess() {
|
|
|
10848
10848
|
start = undefined;
|
|
10849
10849
|
}
|
|
10850
10850
|
while (startPosition < value.length) {
|
|
10851
|
-
search$
|
|
10852
|
-
match = search$
|
|
10851
|
+
search$1.lastIndex = startPosition;
|
|
10852
|
+
match = search$1.exec(value);
|
|
10853
10853
|
endPosition =
|
|
10854
10854
|
match && match.index !== undefined ? match.index : value.length;
|
|
10855
10855
|
code = value.charCodeAt(endPosition);
|
|
@@ -10944,91 +10944,6 @@ function decode($0, $1, $2) {
|
|
|
10944
10944
|
return decodeNamedCharacterReference($2) || $0
|
|
10945
10945
|
}
|
|
10946
10946
|
|
|
10947
|
-
/**
|
|
10948
|
-
* @typedef {import('unist').Node} Node
|
|
10949
|
-
* @typedef {import('unist').Point} Point
|
|
10950
|
-
* @typedef {import('unist').Position} Position
|
|
10951
|
-
*/
|
|
10952
|
-
|
|
10953
|
-
/**
|
|
10954
|
-
* @typedef NodeLike
|
|
10955
|
-
* @property {string} type
|
|
10956
|
-
* @property {PositionLike | null | undefined} [position]
|
|
10957
|
-
*
|
|
10958
|
-
* @typedef PointLike
|
|
10959
|
-
* @property {number | null | undefined} [line]
|
|
10960
|
-
* @property {number | null | undefined} [column]
|
|
10961
|
-
* @property {number | null | undefined} [offset]
|
|
10962
|
-
*
|
|
10963
|
-
* @typedef PositionLike
|
|
10964
|
-
* @property {PointLike | null | undefined} [start]
|
|
10965
|
-
* @property {PointLike | null | undefined} [end]
|
|
10966
|
-
*/
|
|
10967
|
-
|
|
10968
|
-
/**
|
|
10969
|
-
* Serialize the positional info of a point, position (start and end points),
|
|
10970
|
-
* or node.
|
|
10971
|
-
*
|
|
10972
|
-
* @param {Node | NodeLike | Point | PointLike | Position | PositionLike | null | undefined} [value]
|
|
10973
|
-
* Node, position, or point.
|
|
10974
|
-
* @returns {string}
|
|
10975
|
-
* Pretty printed positional info of a node (`string`).
|
|
10976
|
-
*
|
|
10977
|
-
* In the format of a range `ls:cs-le:ce` (when given `node` or `position`)
|
|
10978
|
-
* or a point `l:c` (when given `point`), where `l` stands for line, `c` for
|
|
10979
|
-
* column, `s` for `start`, and `e` for end.
|
|
10980
|
-
* An empty string (`''`) is returned if the given value is neither `node`,
|
|
10981
|
-
* `position`, nor `point`.
|
|
10982
|
-
*/
|
|
10983
|
-
function stringifyPosition(value) {
|
|
10984
|
-
// Nothing.
|
|
10985
|
-
if (!value || typeof value !== 'object') {
|
|
10986
|
-
return ''
|
|
10987
|
-
}
|
|
10988
|
-
|
|
10989
|
-
// Node.
|
|
10990
|
-
if ('position' in value || 'type' in value) {
|
|
10991
|
-
return position$2(value.position)
|
|
10992
|
-
}
|
|
10993
|
-
|
|
10994
|
-
// Position.
|
|
10995
|
-
if ('start' in value || 'end' in value) {
|
|
10996
|
-
return position$2(value)
|
|
10997
|
-
}
|
|
10998
|
-
|
|
10999
|
-
// Point.
|
|
11000
|
-
if ('line' in value || 'column' in value) {
|
|
11001
|
-
return point$4(value)
|
|
11002
|
-
}
|
|
11003
|
-
|
|
11004
|
-
// ?
|
|
11005
|
-
return ''
|
|
11006
|
-
}
|
|
11007
|
-
|
|
11008
|
-
/**
|
|
11009
|
-
* @param {Point | PointLike | null | undefined} point
|
|
11010
|
-
* @returns {string}
|
|
11011
|
-
*/
|
|
11012
|
-
function point$4(point) {
|
|
11013
|
-
return index$1(point && point.line) + ':' + index$1(point && point.column)
|
|
11014
|
-
}
|
|
11015
|
-
|
|
11016
|
-
/**
|
|
11017
|
-
* @param {Position | PositionLike | null | undefined} pos
|
|
11018
|
-
* @returns {string}
|
|
11019
|
-
*/
|
|
11020
|
-
function position$2(pos) {
|
|
11021
|
-
return point$4(pos && pos.start) + '-' + point$4(pos && pos.end)
|
|
11022
|
-
}
|
|
11023
|
-
|
|
11024
|
-
/**
|
|
11025
|
-
* @param {number | null | undefined} value
|
|
11026
|
-
* @returns {number}
|
|
11027
|
-
*/
|
|
11028
|
-
function index$1(value) {
|
|
11029
|
-
return value && typeof value === 'number' ? value : 1
|
|
11030
|
-
}
|
|
11031
|
-
|
|
11032
10947
|
/**
|
|
11033
10948
|
* @typedef {import('mdast').Break} Break
|
|
11034
10949
|
* @typedef {import('mdast').Blockquote} Blockquote
|
|
@@ -11096,7 +11011,7 @@ function fromMarkdown(value, encoding, options) {
|
|
|
11096
11011
|
}
|
|
11097
11012
|
return compiler(options)(
|
|
11098
11013
|
postprocess(
|
|
11099
|
-
parse
|
|
11014
|
+
parse(options).document().write(preprocess()(value, encoding, true))
|
|
11100
11015
|
)
|
|
11101
11016
|
)
|
|
11102
11017
|
}
|
|
@@ -11279,7 +11194,7 @@ function compiler(options) {
|
|
|
11279
11194
|
|
|
11280
11195
|
// Figure out `root` position.
|
|
11281
11196
|
tree.position = {
|
|
11282
|
-
start: point$
|
|
11197
|
+
start: point$1(
|
|
11283
11198
|
events.length > 0
|
|
11284
11199
|
? events[0][1].start
|
|
11285
11200
|
: {
|
|
@@ -11288,7 +11203,7 @@ function compiler(options) {
|
|
|
11288
11203
|
offset: 0
|
|
11289
11204
|
}
|
|
11290
11205
|
),
|
|
11291
|
-
end: point$
|
|
11206
|
+
end: point$1(
|
|
11292
11207
|
events.length > 0
|
|
11293
11208
|
? events[events.length - 2][1].end
|
|
11294
11209
|
: {
|
|
@@ -11496,7 +11411,7 @@ function compiler(options) {
|
|
|
11496
11411
|
this.stack.push(node);
|
|
11497
11412
|
this.tokenStack.push([token, errorHandler]);
|
|
11498
11413
|
node.position = {
|
|
11499
|
-
start: point$
|
|
11414
|
+
start: point$1(token.start),
|
|
11500
11415
|
// @ts-expect-error: `end` will be patched later.
|
|
11501
11416
|
end: undefined
|
|
11502
11417
|
};
|
|
@@ -11542,7 +11457,7 @@ function compiler(options) {
|
|
|
11542
11457
|
'Cannot close `' +
|
|
11543
11458
|
token.type +
|
|
11544
11459
|
'` (' +
|
|
11545
|
-
stringifyPosition({
|
|
11460
|
+
index$1.stringifyPosition({
|
|
11546
11461
|
start: token.start,
|
|
11547
11462
|
end: token.end
|
|
11548
11463
|
}) +
|
|
@@ -11556,7 +11471,7 @@ function compiler(options) {
|
|
|
11556
11471
|
handler.call(this, token, open[0]);
|
|
11557
11472
|
}
|
|
11558
11473
|
}
|
|
11559
|
-
node.position.end = point$
|
|
11474
|
+
node.position.end = point$1(token.end);
|
|
11560
11475
|
}
|
|
11561
11476
|
|
|
11562
11477
|
/**
|
|
@@ -11727,7 +11642,7 @@ function compiler(options) {
|
|
|
11727
11642
|
// Add a new text node.
|
|
11728
11643
|
tail = text();
|
|
11729
11644
|
tail.position = {
|
|
11730
|
-
start: point$
|
|
11645
|
+
start: point$1(token.start),
|
|
11731
11646
|
// @ts-expect-error: we’ll add `end` later.
|
|
11732
11647
|
end: undefined
|
|
11733
11648
|
};
|
|
@@ -11744,7 +11659,7 @@ function compiler(options) {
|
|
|
11744
11659
|
function onexitdata(token) {
|
|
11745
11660
|
const tail = this.stack.pop();
|
|
11746
11661
|
tail.value += this.sliceSerialize(token);
|
|
11747
|
-
tail.position.end = point$
|
|
11662
|
+
tail.position.end = point$1(token.end);
|
|
11748
11663
|
}
|
|
11749
11664
|
|
|
11750
11665
|
/**
|
|
@@ -11757,7 +11672,7 @@ function compiler(options) {
|
|
|
11757
11672
|
// If we’re at a hard break, include the line ending in there.
|
|
11758
11673
|
if (this.data.atHardBreak) {
|
|
11759
11674
|
const tail = context.children[context.children.length - 1];
|
|
11760
|
-
tail.position.end = point$
|
|
11675
|
+
tail.position.end = point$1(token.end);
|
|
11761
11676
|
this.data.atHardBreak = undefined;
|
|
11762
11677
|
return
|
|
11763
11678
|
}
|
|
@@ -11991,7 +11906,7 @@ function compiler(options) {
|
|
|
11991
11906
|
}
|
|
11992
11907
|
const tail = this.stack.pop();
|
|
11993
11908
|
tail.value += value;
|
|
11994
|
-
tail.position.end = point$
|
|
11909
|
+
tail.position.end = point$1(token.end);
|
|
11995
11910
|
}
|
|
11996
11911
|
|
|
11997
11912
|
/**
|
|
@@ -12175,7 +12090,7 @@ function compiler(options) {
|
|
|
12175
12090
|
* @returns {Point}
|
|
12176
12091
|
* unist point.
|
|
12177
12092
|
*/
|
|
12178
|
-
function point$
|
|
12093
|
+
function point$1(d) {
|
|
12179
12094
|
return {
|
|
12180
12095
|
line: d.line,
|
|
12181
12096
|
column: d.column,
|
|
@@ -12246,14 +12161,14 @@ function defaultOnError(left, right) {
|
|
|
12246
12161
|
'Cannot close `' +
|
|
12247
12162
|
left.type +
|
|
12248
12163
|
'` (' +
|
|
12249
|
-
stringifyPosition({
|
|
12164
|
+
index$1.stringifyPosition({
|
|
12250
12165
|
start: left.start,
|
|
12251
12166
|
end: left.end
|
|
12252
12167
|
}) +
|
|
12253
12168
|
'): a different token (`' +
|
|
12254
12169
|
right.type +
|
|
12255
12170
|
'`, ' +
|
|
12256
|
-
stringifyPosition({
|
|
12171
|
+
index$1.stringifyPosition({
|
|
12257
12172
|
start: right.start,
|
|
12258
12173
|
end: right.end
|
|
12259
12174
|
}) +
|
|
@@ -12264,7 +12179,7 @@ function defaultOnError(left, right) {
|
|
|
12264
12179
|
'Cannot close document, a token (`' +
|
|
12265
12180
|
right.type +
|
|
12266
12181
|
'`, ' +
|
|
12267
|
-
stringifyPosition({
|
|
12182
|
+
index$1.stringifyPosition({
|
|
12268
12183
|
start: right.start,
|
|
12269
12184
|
end: right.end
|
|
12270
12185
|
}) +
|
|
@@ -13082,102 +12997,6 @@ function strong$1(state, node) {
|
|
|
13082
12997
|
return state.applyData(node, result)
|
|
13083
12998
|
}
|
|
13084
12999
|
|
|
13085
|
-
/**
|
|
13086
|
-
* @typedef {import('unist').Node} Node
|
|
13087
|
-
* @typedef {import('unist').Point} Point
|
|
13088
|
-
* @typedef {import('unist').Position} Position
|
|
13089
|
-
*/
|
|
13090
|
-
|
|
13091
|
-
/**
|
|
13092
|
-
* @typedef NodeLike
|
|
13093
|
-
* @property {string} type
|
|
13094
|
-
* @property {PositionLike | null | undefined} [position]
|
|
13095
|
-
*
|
|
13096
|
-
* @typedef PositionLike
|
|
13097
|
-
* @property {PointLike | null | undefined} [start]
|
|
13098
|
-
* @property {PointLike | null | undefined} [end]
|
|
13099
|
-
*
|
|
13100
|
-
* @typedef PointLike
|
|
13101
|
-
* @property {number | null | undefined} [line]
|
|
13102
|
-
* @property {number | null | undefined} [column]
|
|
13103
|
-
* @property {number | null | undefined} [offset]
|
|
13104
|
-
*/
|
|
13105
|
-
|
|
13106
|
-
/**
|
|
13107
|
-
* Get the ending point of `node`.
|
|
13108
|
-
*
|
|
13109
|
-
* @param node
|
|
13110
|
-
* Node.
|
|
13111
|
-
* @returns
|
|
13112
|
-
* Point.
|
|
13113
|
-
*/
|
|
13114
|
-
const pointEnd$1 = point$2('end');
|
|
13115
|
-
|
|
13116
|
-
/**
|
|
13117
|
-
* Get the starting point of `node`.
|
|
13118
|
-
*
|
|
13119
|
-
* @param node
|
|
13120
|
-
* Node.
|
|
13121
|
-
* @returns
|
|
13122
|
-
* Point.
|
|
13123
|
-
*/
|
|
13124
|
-
const pointStart$1 = point$2('start');
|
|
13125
|
-
|
|
13126
|
-
/**
|
|
13127
|
-
* Get the positional info of `node`.
|
|
13128
|
-
*
|
|
13129
|
-
* @param {'end' | 'start'} type
|
|
13130
|
-
* Side.
|
|
13131
|
-
* @returns
|
|
13132
|
-
* Getter.
|
|
13133
|
-
*/
|
|
13134
|
-
function point$2(type) {
|
|
13135
|
-
return point
|
|
13136
|
-
|
|
13137
|
-
/**
|
|
13138
|
-
* Get the point info of `node` at a bound side.
|
|
13139
|
-
*
|
|
13140
|
-
* @param {Node | NodeLike | null | undefined} [node]
|
|
13141
|
-
* @returns {Point | undefined}
|
|
13142
|
-
*/
|
|
13143
|
-
function point(node) {
|
|
13144
|
-
const point = (node && node.position && node.position[type]) || {};
|
|
13145
|
-
|
|
13146
|
-
if (
|
|
13147
|
-
typeof point.line === 'number' &&
|
|
13148
|
-
point.line > 0 &&
|
|
13149
|
-
typeof point.column === 'number' &&
|
|
13150
|
-
point.column > 0
|
|
13151
|
-
) {
|
|
13152
|
-
return {
|
|
13153
|
-
line: point.line,
|
|
13154
|
-
column: point.column,
|
|
13155
|
-
offset:
|
|
13156
|
-
typeof point.offset === 'number' && point.offset > -1
|
|
13157
|
-
? point.offset
|
|
13158
|
-
: undefined
|
|
13159
|
-
}
|
|
13160
|
-
}
|
|
13161
|
-
}
|
|
13162
|
-
}
|
|
13163
|
-
|
|
13164
|
-
/**
|
|
13165
|
-
* Get the positional info of `node`.
|
|
13166
|
-
*
|
|
13167
|
-
* @param {Node | NodeLike | null | undefined} [node]
|
|
13168
|
-
* Node.
|
|
13169
|
-
* @returns {Position | undefined}
|
|
13170
|
-
* Position.
|
|
13171
|
-
*/
|
|
13172
|
-
function position$1(node) {
|
|
13173
|
-
const start = pointStart$1(node);
|
|
13174
|
-
const end = pointEnd$1(node);
|
|
13175
|
-
|
|
13176
|
-
if (start && end) {
|
|
13177
|
-
return {start, end}
|
|
13178
|
-
}
|
|
13179
|
-
}
|
|
13180
|
-
|
|
13181
13000
|
/**
|
|
13182
13001
|
* @import {Table} from 'mdast'
|
|
13183
13002
|
* @import {Element} from 'hast'
|
|
@@ -13222,8 +13041,8 @@ function table(state, node) {
|
|
|
13222
13041
|
children: state.wrap(rows, true)
|
|
13223
13042
|
};
|
|
13224
13043
|
|
|
13225
|
-
const start =
|
|
13226
|
-
const end =
|
|
13044
|
+
const start = index$1.pointStart(node.children[1]);
|
|
13045
|
+
const end = index$1.pointEnd(node.children[node.children.length - 1]);
|
|
13227
13046
|
if (start && end) body.position = {start, end};
|
|
13228
13047
|
tableContent.push(body);
|
|
13229
13048
|
}
|
|
@@ -13674,7 +13493,7 @@ function footer(state) {
|
|
|
13674
13493
|
type: 'element',
|
|
13675
13494
|
tagName: footnoteLabelTagName,
|
|
13676
13495
|
properties: {
|
|
13677
|
-
...index$
|
|
13496
|
+
...index$1.structuredClone(footnoteLabelProperties),
|
|
13678
13497
|
id: 'footnote-label'
|
|
13679
13498
|
},
|
|
13680
13499
|
children: [{type: 'text', value: footnoteLabel}]
|
|
@@ -13757,7 +13576,7 @@ function createState(tree, options) {
|
|
|
13757
13576
|
wrap
|
|
13758
13577
|
};
|
|
13759
13578
|
|
|
13760
|
-
index$
|
|
13579
|
+
index$1.visit(tree, function (node) {
|
|
13761
13580
|
if (node.type === 'definition' || node.type === 'footnoteDefinition') {
|
|
13762
13581
|
const map = node.type === 'definition' ? definitionById : footnoteById;
|
|
13763
13582
|
const id = String(node.identifier).toUpperCase();
|
|
@@ -13794,7 +13613,7 @@ function createState(tree, options) {
|
|
|
13794
13613
|
if (state.options.passThrough && state.options.passThrough.includes(type)) {
|
|
13795
13614
|
if ('children' in node) {
|
|
13796
13615
|
const {children, ...shallow} = node;
|
|
13797
|
-
const result = index$
|
|
13616
|
+
const result = index$1.structuredClone(shallow);
|
|
13798
13617
|
// @ts-expect-error: TS doesn’t understand…
|
|
13799
13618
|
result.children = state.all(node);
|
|
13800
13619
|
// @ts-expect-error: TS doesn’t understand…
|
|
@@ -13802,7 +13621,7 @@ function createState(tree, options) {
|
|
|
13802
13621
|
}
|
|
13803
13622
|
|
|
13804
13623
|
// @ts-expect-error: it’s custom.
|
|
13805
|
-
return index$
|
|
13624
|
+
return index$1.structuredClone(node)
|
|
13806
13625
|
}
|
|
13807
13626
|
|
|
13808
13627
|
const unknown = state.options.unknownHandler || defaultUnknownHandler;
|
|
@@ -13868,7 +13687,7 @@ function createState(tree, options) {
|
|
|
13868
13687
|
* Nothing.
|
|
13869
13688
|
*/
|
|
13870
13689
|
function patch$2(from, to) {
|
|
13871
|
-
if (from.position) to.position =
|
|
13690
|
+
if (from.position) to.position = index$1.position(from);
|
|
13872
13691
|
}
|
|
13873
13692
|
|
|
13874
13693
|
/**
|
|
@@ -13912,7 +13731,7 @@ function applyData(from, to) {
|
|
|
13912
13731
|
}
|
|
13913
13732
|
|
|
13914
13733
|
if (result.type === 'element' && hProperties) {
|
|
13915
|
-
Object.assign(result.properties, index$
|
|
13734
|
+
Object.assign(result.properties, index$1.structuredClone(hProperties));
|
|
13916
13735
|
}
|
|
13917
13736
|
|
|
13918
13737
|
if (
|
|
@@ -14298,12 +14117,12 @@ function escapeStringRegexp(string) {
|
|
|
14298
14117
|
*/
|
|
14299
14118
|
function findAndReplace(tree, list, options) {
|
|
14300
14119
|
const settings = options || {};
|
|
14301
|
-
const ignored = index$
|
|
14120
|
+
const ignored = index$1.convert(settings.ignore || []);
|
|
14302
14121
|
const pairs = toPairs(list);
|
|
14303
14122
|
let pairIndex = -1;
|
|
14304
14123
|
|
|
14305
14124
|
while (++pairIndex < pairs.length) {
|
|
14306
|
-
index$
|
|
14125
|
+
index$1.visitParents(tree, 'text', visitor);
|
|
14307
14126
|
}
|
|
14308
14127
|
|
|
14309
14128
|
/** @type {import('unist-util-visit-parents').BuildVisitor<Root, 'text'>} */
|
|
@@ -14736,8 +14555,8 @@ function splitUrl(url) {
|
|
|
14736
14555
|
|
|
14737
14556
|
let trail = trailExec[0];
|
|
14738
14557
|
let closingParenIndex = trail.indexOf(')');
|
|
14739
|
-
const openingParens = index$
|
|
14740
|
-
let closingParens = index$
|
|
14558
|
+
const openingParens = index$1.ccount(url, '(');
|
|
14559
|
+
let closingParens = index$1.ccount(url, ')');
|
|
14741
14560
|
|
|
14742
14561
|
while (closingParenIndex !== -1 && openingParens > closingParens) {
|
|
14743
14562
|
url += trail.slice(0, closingParenIndex + 1);
|
|
@@ -15448,17 +15267,59 @@ function toAlignment(value) {
|
|
|
15448
15267
|
: 0
|
|
15449
15268
|
}
|
|
15450
15269
|
|
|
15270
|
+
/**
|
|
15271
|
+
* @typedef {import('mdast').PhrasingContent} PhrasingContent
|
|
15272
|
+
*/
|
|
15273
|
+
|
|
15274
|
+
|
|
15275
|
+
/**
|
|
15276
|
+
* Check if the given value is *phrasing content*.
|
|
15277
|
+
*
|
|
15278
|
+
* > 👉 **Note**: Excludes `html`, which can be both phrasing or flow.
|
|
15279
|
+
*
|
|
15280
|
+
* @param node
|
|
15281
|
+
* Thing to check, typically `Node`.
|
|
15282
|
+
* @returns
|
|
15283
|
+
* Whether `value` is phrasing content.
|
|
15284
|
+
*/
|
|
15285
|
+
|
|
15286
|
+
const phrasing =
|
|
15287
|
+
/** @type {(node?: unknown) => node is PhrasingContent} */
|
|
15288
|
+
(
|
|
15289
|
+
index$1.convert([
|
|
15290
|
+
'break',
|
|
15291
|
+
'delete',
|
|
15292
|
+
'emphasis',
|
|
15293
|
+
'footnote',
|
|
15294
|
+
'footnoteReference',
|
|
15295
|
+
'image',
|
|
15296
|
+
'imageReference',
|
|
15297
|
+
'inlineCode',
|
|
15298
|
+
'link',
|
|
15299
|
+
'linkReference',
|
|
15300
|
+
'strong',
|
|
15301
|
+
'text'
|
|
15302
|
+
])
|
|
15303
|
+
);
|
|
15304
|
+
|
|
15451
15305
|
/**
|
|
15452
15306
|
* @import {Blockquote, Parents} from 'mdast'
|
|
15453
15307
|
* @import {Info, Map, State} from 'mdast-util-to-markdown'
|
|
15454
15308
|
*/
|
|
15455
15309
|
|
|
15456
15310
|
/**
|
|
15311
|
+
* Serialize a blockquote node.
|
|
15312
|
+
*
|
|
15457
15313
|
* @param {Blockquote} node
|
|
15314
|
+
* Node to serialize.
|
|
15458
15315
|
* @param {Parents | undefined} _
|
|
15316
|
+
* Parent node.
|
|
15459
15317
|
* @param {State} state
|
|
15318
|
+
* Info passed around.
|
|
15460
15319
|
* @param {Info} info
|
|
15320
|
+
* Info on surrounding context.
|
|
15461
15321
|
* @returns {string}
|
|
15322
|
+
* Serialized markdown.
|
|
15462
15323
|
*/
|
|
15463
15324
|
function blockquote(node, _, state, info) {
|
|
15464
15325
|
const exit = state.enter('blockquote');
|
|
@@ -15473,7 +15334,11 @@ function blockquote(node, _, state, info) {
|
|
|
15473
15334
|
return value
|
|
15474
15335
|
}
|
|
15475
15336
|
|
|
15476
|
-
/**
|
|
15337
|
+
/**
|
|
15338
|
+
* Indent lines w/ blockquote markers.
|
|
15339
|
+
*
|
|
15340
|
+
* @type {Map}
|
|
15341
|
+
*/
|
|
15477
15342
|
function map$1(line, _, blank) {
|
|
15478
15343
|
return '>' + (blank ? '' : ' ') + line
|
|
15479
15344
|
}
|
|
@@ -15483,9 +15348,14 @@ function map$1(line, _, blank) {
|
|
|
15483
15348
|
*/
|
|
15484
15349
|
|
|
15485
15350
|
/**
|
|
15351
|
+
* Check if a pattern is in scope based on the current stack of constructs.
|
|
15352
|
+
*
|
|
15486
15353
|
* @param {Array<ConstructName>} stack
|
|
15354
|
+
* Current stack of constructs.
|
|
15487
15355
|
* @param {Unsafe} pattern
|
|
15356
|
+
* Pattern to check.
|
|
15488
15357
|
* @returns {boolean}
|
|
15358
|
+
* Whether the pattern is in scope.
|
|
15489
15359
|
*/
|
|
15490
15360
|
function patternInScope(stack, pattern) {
|
|
15491
15361
|
return (
|
|
@@ -15495,10 +15365,16 @@ function patternInScope(stack, pattern) {
|
|
|
15495
15365
|
}
|
|
15496
15366
|
|
|
15497
15367
|
/**
|
|
15368
|
+
* Check if any of the constructs in the list are present in the stack.
|
|
15369
|
+
*
|
|
15498
15370
|
* @param {Array<ConstructName>} stack
|
|
15371
|
+
* Current stack of constructs.
|
|
15499
15372
|
* @param {Unsafe['inConstruct']} list
|
|
15373
|
+
* List of constructs to check for in the stack.
|
|
15500
15374
|
* @param {boolean} none
|
|
15375
|
+
* Value to return if the list is empty or not provided.
|
|
15501
15376
|
* @returns {boolean}
|
|
15377
|
+
* Whether any of the constructs in the list are present in the stack.
|
|
15502
15378
|
*/
|
|
15503
15379
|
function listInScope(stack, list, none) {
|
|
15504
15380
|
if (typeof list === 'string') {
|
|
@@ -15527,23 +15403,34 @@ function listInScope(stack, list, none) {
|
|
|
15527
15403
|
|
|
15528
15404
|
|
|
15529
15405
|
/**
|
|
15406
|
+
* Serialize a break node.
|
|
15407
|
+
*
|
|
15530
15408
|
* @param {Break} _
|
|
15409
|
+
* Node to serialize.
|
|
15531
15410
|
* @param {Parents | undefined} _1
|
|
15411
|
+
* Parent node.
|
|
15532
15412
|
* @param {State} state
|
|
15413
|
+
* Info passed around.
|
|
15533
15414
|
* @param {Info} info
|
|
15415
|
+
* Info on surrounding context.
|
|
15534
15416
|
* @returns {string}
|
|
15417
|
+
* Serialized markdown.
|
|
15535
15418
|
*/
|
|
15536
15419
|
function hardBreak(_, _1, state, info) {
|
|
15537
15420
|
let index = -1;
|
|
15538
15421
|
|
|
15539
15422
|
while (++index < state.unsafe.length) {
|
|
15540
|
-
|
|
15541
|
-
|
|
15423
|
+
const pattern = state.unsafe[index];
|
|
15424
|
+
|
|
15425
|
+
// If we can’t put unconditional eols in this construct (setext headings,
|
|
15426
|
+
// tables), use a space instead.
|
|
15542
15427
|
if (
|
|
15543
|
-
|
|
15544
|
-
|
|
15428
|
+
pattern.character === '\n' &&
|
|
15429
|
+
!pattern.before &&
|
|
15430
|
+
!pattern.after &&
|
|
15431
|
+
patternInScope(state.stack, pattern)
|
|
15545
15432
|
) {
|
|
15546
|
-
return /[
|
|
15433
|
+
return /[\t ]/.test(info.before) ? '' : ' '
|
|
15547
15434
|
}
|
|
15548
15435
|
}
|
|
15549
15436
|
|
|
@@ -15593,20 +15480,25 @@ function longestStreak(value, substring) {
|
|
|
15593
15480
|
*/
|
|
15594
15481
|
|
|
15595
15482
|
/**
|
|
15483
|
+
* Checks if a code block can be formatted as an indented code block.
|
|
15484
|
+
*
|
|
15596
15485
|
* @param {Code} node
|
|
15486
|
+
* Node to check.
|
|
15597
15487
|
* @param {State} state
|
|
15488
|
+
* Info passed around.
|
|
15598
15489
|
* @returns {boolean}
|
|
15490
|
+
* Whether the code can be formatted as an indented code block.
|
|
15599
15491
|
*/
|
|
15600
15492
|
function formatCodeAsIndented(node, state) {
|
|
15601
15493
|
return Boolean(
|
|
15602
15494
|
state.options.fences === false &&
|
|
15603
|
-
|
|
15604
|
-
|
|
15605
|
-
|
|
15606
|
-
|
|
15607
|
-
|
|
15608
|
-
|
|
15609
|
-
|
|
15495
|
+
node.value &&
|
|
15496
|
+
// If there’s no info…
|
|
15497
|
+
!node.lang &&
|
|
15498
|
+
// And there’s a non-whitespace character…
|
|
15499
|
+
/[^\n\r ]/.test(node.value) &&
|
|
15500
|
+
// And the value doesn’t start or end in a blank…
|
|
15501
|
+
!/^[\t ]*(?:[\n\r]|$)|(?:^|[\n\r])[\t ]*$/.test(node.value)
|
|
15610
15502
|
)
|
|
15611
15503
|
}
|
|
15612
15504
|
|
|
@@ -15615,8 +15507,12 @@ function formatCodeAsIndented(node, state) {
|
|
|
15615
15507
|
*/
|
|
15616
15508
|
|
|
15617
15509
|
/**
|
|
15510
|
+
* Checks the preferred fence option.
|
|
15511
|
+
*
|
|
15618
15512
|
* @param {State} state
|
|
15513
|
+
* Info passed around.
|
|
15619
15514
|
* @returns {Exclude<Options['fence'], null | undefined>}
|
|
15515
|
+
* Preferred fence marker.
|
|
15620
15516
|
*/
|
|
15621
15517
|
function checkFence(state) {
|
|
15622
15518
|
const marker = state.options.fence || '`';
|
|
@@ -15639,16 +15535,22 @@ function checkFence(state) {
|
|
|
15639
15535
|
|
|
15640
15536
|
|
|
15641
15537
|
/**
|
|
15538
|
+
* Serialize a code node.
|
|
15539
|
+
*
|
|
15642
15540
|
* @param {Code} node
|
|
15541
|
+
* Node to serialize.
|
|
15643
15542
|
* @param {Parents | undefined} _
|
|
15543
|
+
* Parent node.
|
|
15644
15544
|
* @param {State} state
|
|
15545
|
+
* Info passed around.
|
|
15645
15546
|
* @param {Info} info
|
|
15547
|
+
* Info on surrounding context.
|
|
15646
15548
|
* @returns {string}
|
|
15549
|
+
* Serialized markdown.
|
|
15647
15550
|
*/
|
|
15648
15551
|
function code$1(node, _, state, info) {
|
|
15649
15552
|
const marker = checkFence(state);
|
|
15650
15553
|
const raw = node.value || '';
|
|
15651
|
-
const suffix = marker === '`' ? 'GraveAccent' : 'Tilde';
|
|
15652
15554
|
|
|
15653
15555
|
if (formatCodeAsIndented(node, state)) {
|
|
15654
15556
|
const exit = state.enter('codeIndented');
|
|
@@ -15660,6 +15562,7 @@ function code$1(node, _, state, info) {
|
|
|
15660
15562
|
const tracker = state.createTracker(info);
|
|
15661
15563
|
const sequence = marker.repeat(Math.max(longestStreak(raw, marker) + 1, 3));
|
|
15662
15564
|
const exit = state.enter('codeFenced');
|
|
15565
|
+
const suffix = marker === '`' ? 'GraveAccent' : 'Tilde';
|
|
15663
15566
|
let value = tracker.move(sequence);
|
|
15664
15567
|
|
|
15665
15568
|
if (node.lang) {
|
|
@@ -15700,7 +15603,11 @@ function code$1(node, _, state, info) {
|
|
|
15700
15603
|
return value
|
|
15701
15604
|
}
|
|
15702
15605
|
|
|
15703
|
-
/**
|
|
15606
|
+
/**
|
|
15607
|
+
* Indent lines w/ code indent.
|
|
15608
|
+
*
|
|
15609
|
+
* @type {Map}
|
|
15610
|
+
*/
|
|
15704
15611
|
function map(line, _, blank) {
|
|
15705
15612
|
return (blank ? '' : ' ') + line
|
|
15706
15613
|
}
|
|
@@ -15710,8 +15617,12 @@ function map(line, _, blank) {
|
|
|
15710
15617
|
*/
|
|
15711
15618
|
|
|
15712
15619
|
/**
|
|
15620
|
+
* Checks the preferred quote option.
|
|
15621
|
+
*
|
|
15713
15622
|
* @param {State} state
|
|
15623
|
+
* Info passed around.
|
|
15714
15624
|
* @returns {Exclude<Options['quote'], null | undefined>}
|
|
15625
|
+
* Preferred quote.
|
|
15715
15626
|
*/
|
|
15716
15627
|
function checkQuote(state) {
|
|
15717
15628
|
const marker = state.options.quote || '"';
|
|
@@ -15734,11 +15645,18 @@ function checkQuote(state) {
|
|
|
15734
15645
|
|
|
15735
15646
|
|
|
15736
15647
|
/**
|
|
15648
|
+
* Serialize a definition node.
|
|
15649
|
+
*
|
|
15737
15650
|
* @param {Definition} node
|
|
15651
|
+
* Node to serialize.
|
|
15738
15652
|
* @param {Parents | undefined} _
|
|
15653
|
+
* Parent node.
|
|
15739
15654
|
* @param {State} state
|
|
15655
|
+
* Info passed around.
|
|
15740
15656
|
* @param {Info} info
|
|
15657
|
+
* Info on surrounding context.
|
|
15741
15658
|
* @returns {string}
|
|
15659
|
+
* Serialized markdown.
|
|
15742
15660
|
*/
|
|
15743
15661
|
function definition(node, _, state, info) {
|
|
15744
15662
|
const quote = checkQuote(state);
|
|
@@ -15808,8 +15726,12 @@ function definition(node, _, state, info) {
|
|
|
15808
15726
|
*/
|
|
15809
15727
|
|
|
15810
15728
|
/**
|
|
15729
|
+
* Checks the preferred emphasis option.
|
|
15730
|
+
*
|
|
15811
15731
|
* @param {State} state
|
|
15732
|
+
* Info passed around.
|
|
15812
15733
|
* @returns {Exclude<Options['emphasis'], null | undefined>}
|
|
15734
|
+
* Preferred emphasis marker.
|
|
15813
15735
|
*/
|
|
15814
15736
|
function checkEmphasis(state) {
|
|
15815
15737
|
const marker = state.options.emphasis || '*';
|
|
@@ -15826,166 +15748,84 @@ function checkEmphasis(state) {
|
|
|
15826
15748
|
}
|
|
15827
15749
|
|
|
15828
15750
|
/**
|
|
15829
|
-
*
|
|
15830
|
-
*
|
|
15831
|
-
* @param {number} code
|
|
15832
|
-
* Code point to encode.
|
|
15833
|
-
* @returns {string}
|
|
15834
|
-
* Encoded character reference.
|
|
15751
|
+
* @import {AttentionInfo, Info, State} from 'mdast-util-to-markdown'
|
|
15752
|
+
* @import {Emphasis, Parents} from 'mdast'
|
|
15835
15753
|
*/
|
|
15836
|
-
function encodeCharacterReference(code) {
|
|
15837
|
-
return '&#x' + code.toString(16).toUpperCase() + ';'
|
|
15838
|
-
}
|
|
15839
15754
|
|
|
15840
|
-
/**
|
|
15841
|
-
* @import {EncodeSides} from '../types.js'
|
|
15842
|
-
*/
|
|
15843
15755
|
|
|
15756
|
+
emphasis.attention = attention$1;
|
|
15757
|
+
emphasis.peek = peek$1;
|
|
15844
15758
|
|
|
15845
15759
|
/**
|
|
15846
|
-
*
|
|
15847
|
-
* surrounding an attention run.
|
|
15760
|
+
* Serialize an emphasis node.
|
|
15848
15761
|
*
|
|
15849
|
-
*
|
|
15850
|
-
* not.
|
|
15851
|
-
*
|
|
15852
|
-
* See <https://github.com/orgs/syntax-tree/discussions/60> for more info.
|
|
15853
|
-
* See this markdown in a particular renderer to see what works:
|
|
15854
|
-
*
|
|
15855
|
-
* ```markdown
|
|
15856
|
-
* | | A (letter inside) | B (punctuation inside) | C (whitespace inside) | D (nothing inside) |
|
|
15857
|
-
* | ----------------------- | ----------------- | ---------------------- | --------------------- | ------------------ |
|
|
15858
|
-
* | 1 (letter outside) | x*y*z | x*.*z | x* *z | x**z |
|
|
15859
|
-
* | 2 (punctuation outside) | .*y*. | .*.*. | .* *. | .**. |
|
|
15860
|
-
* | 3 (whitespace outside) | x *y* z | x *.* z | x * * z | x ** z |
|
|
15861
|
-
* | 4 (nothing outside) | *x* | *.* | * * | ** |
|
|
15862
|
-
* ```
|
|
15762
|
+
* Attention is properly handled by `containerPhrasing`.
|
|
15863
15763
|
*
|
|
15864
|
-
* @param {number} outside
|
|
15865
|
-
* Code point on the outer side of the run.
|
|
15866
|
-
* @param {number} inside
|
|
15867
|
-
* Code point on the inner side of the run.
|
|
15868
|
-
* @param {'*' | '_'} marker
|
|
15869
|
-
* Marker of the run.
|
|
15870
|
-
* Underscores are handled more strictly (they form less often) than
|
|
15871
|
-
* asterisks.
|
|
15872
|
-
* @returns {EncodeSides}
|
|
15873
|
-
* Whether to encode characters.
|
|
15874
|
-
*/
|
|
15875
|
-
// Important: punctuation must never be encoded.
|
|
15876
|
-
// Punctuation is solely used by markdown constructs.
|
|
15877
|
-
// And by encoding itself.
|
|
15878
|
-
// Encoding them will break constructs or double encode things.
|
|
15879
|
-
function encodeInfo(outside, inside, marker) {
|
|
15880
|
-
const outsideKind = classifyCharacter(outside);
|
|
15881
|
-
const insideKind = classifyCharacter(inside);
|
|
15882
|
-
|
|
15883
|
-
// Letter outside:
|
|
15884
|
-
if (outsideKind === undefined) {
|
|
15885
|
-
return insideKind === undefined
|
|
15886
|
-
? // Letter inside:
|
|
15887
|
-
// we have to encode *both* letters for `_` as it is looser.
|
|
15888
|
-
// it already forms for `*` (and GFMs `~`).
|
|
15889
|
-
marker === '_'
|
|
15890
|
-
? {inside: true, outside: true}
|
|
15891
|
-
: {inside: false, outside: false}
|
|
15892
|
-
: insideKind === 1
|
|
15893
|
-
? // Whitespace inside: encode both (letter, whitespace).
|
|
15894
|
-
{inside: true, outside: true}
|
|
15895
|
-
: // Punctuation inside: encode outer (letter)
|
|
15896
|
-
{inside: false, outside: true}
|
|
15897
|
-
}
|
|
15898
|
-
|
|
15899
|
-
// Whitespace outside:
|
|
15900
|
-
if (outsideKind === 1) {
|
|
15901
|
-
return insideKind === undefined
|
|
15902
|
-
? // Letter inside: already forms.
|
|
15903
|
-
{inside: false, outside: false}
|
|
15904
|
-
: insideKind === 1
|
|
15905
|
-
? // Whitespace inside: encode both (whitespace).
|
|
15906
|
-
{inside: true, outside: true}
|
|
15907
|
-
: // Punctuation inside: already forms.
|
|
15908
|
-
{inside: false, outside: false}
|
|
15909
|
-
}
|
|
15910
|
-
|
|
15911
|
-
// Punctuation outside:
|
|
15912
|
-
return insideKind === undefined
|
|
15913
|
-
? // Letter inside: already forms.
|
|
15914
|
-
{inside: false, outside: false}
|
|
15915
|
-
: insideKind === 1
|
|
15916
|
-
? // Whitespace inside: encode inner (whitespace).
|
|
15917
|
-
{inside: true, outside: false}
|
|
15918
|
-
: // Punctuation inside: already forms.
|
|
15919
|
-
{inside: false, outside: false}
|
|
15920
|
-
}
|
|
15921
|
-
|
|
15922
|
-
/**
|
|
15923
|
-
* @import {Info, State} from 'mdast-util-to-markdown'
|
|
15924
|
-
* @import {Emphasis, Parents} from 'mdast'
|
|
15925
|
-
*/
|
|
15926
|
-
|
|
15927
|
-
|
|
15928
|
-
emphasis.peek = emphasisPeek;
|
|
15929
|
-
|
|
15930
|
-
/**
|
|
15931
15764
|
* @param {Emphasis} node
|
|
15765
|
+
* Node to serialize.
|
|
15932
15766
|
* @param {Parents | undefined} _
|
|
15767
|
+
* Parent node.
|
|
15933
15768
|
* @param {State} state
|
|
15769
|
+
* Info passed around.
|
|
15934
15770
|
* @param {Info} info
|
|
15771
|
+
* Info on surrounding context.
|
|
15935
15772
|
* @returns {string}
|
|
15773
|
+
* Serialized markdown.
|
|
15936
15774
|
*/
|
|
15937
15775
|
function emphasis(node, _, state, info) {
|
|
15938
|
-
const
|
|
15939
|
-
const
|
|
15940
|
-
const tracker = state.createTracker(info);
|
|
15941
|
-
const before = tracker.move(marker);
|
|
15942
|
-
|
|
15943
|
-
let between = tracker.move(
|
|
15944
|
-
state.containerPhrasing(node, {
|
|
15945
|
-
after: marker,
|
|
15946
|
-
before,
|
|
15947
|
-
...tracker.current()
|
|
15948
|
-
})
|
|
15949
|
-
);
|
|
15950
|
-
const betweenHead = between.charCodeAt(0);
|
|
15951
|
-
const open = encodeInfo(
|
|
15952
|
-
info.before.charCodeAt(info.before.length - 1),
|
|
15953
|
-
betweenHead,
|
|
15954
|
-
marker
|
|
15955
|
-
);
|
|
15956
|
-
|
|
15957
|
-
if (open.inside) {
|
|
15958
|
-
between = encodeCharacterReference(betweenHead) + between.slice(1);
|
|
15959
|
-
}
|
|
15960
|
-
|
|
15961
|
-
const betweenTail = between.charCodeAt(between.length - 1);
|
|
15962
|
-
const close = encodeInfo(info.after.charCodeAt(0), betweenTail, marker);
|
|
15963
|
-
|
|
15964
|
-
if (close.inside) {
|
|
15965
|
-
between = between.slice(0, -1) + encodeCharacterReference(betweenTail);
|
|
15966
|
-
}
|
|
15967
|
-
|
|
15968
|
-
const after = tracker.move(marker);
|
|
15969
|
-
|
|
15776
|
+
const exit = state.enter('phrasing');
|
|
15777
|
+
const value = state.containerPhrasing({type: 'root', children: [node]}, info);
|
|
15970
15778
|
exit();
|
|
15779
|
+
return value
|
|
15780
|
+
}
|
|
15971
15781
|
|
|
15972
|
-
|
|
15973
|
-
|
|
15974
|
-
|
|
15975
|
-
|
|
15976
|
-
|
|
15782
|
+
/**
|
|
15783
|
+
* Serialize an emphasis node as attention.
|
|
15784
|
+
*
|
|
15785
|
+
* @param {Emphasis} _
|
|
15786
|
+
* Node to serialize.
|
|
15787
|
+
* @param {State} state
|
|
15788
|
+
* Info passed around.
|
|
15789
|
+
* @returns {AttentionInfo}
|
|
15790
|
+
* Info on how to serialize the node.
|
|
15791
|
+
*/
|
|
15792
|
+
function attention$1(_, state) {
|
|
15793
|
+
const marker = checkEmphasis(state);
|
|
15794
|
+
return {
|
|
15795
|
+
construct: 'emphasis',
|
|
15796
|
+
markers: marker === '*' ? ['*', '_'] : ['_', '*'],
|
|
15797
|
+
sizes: [1]
|
|
15798
|
+
}
|
|
15977
15799
|
}
|
|
15978
15800
|
|
|
15979
15801
|
/**
|
|
15802
|
+
* Peek at this node.
|
|
15803
|
+
*
|
|
15980
15804
|
* @param {Emphasis} _
|
|
15805
|
+
* Node to serialize.
|
|
15981
15806
|
* @param {Parents | undefined} _1
|
|
15807
|
+
* Parent node.
|
|
15982
15808
|
* @param {State} state
|
|
15809
|
+
* Info passed around.
|
|
15983
15810
|
* @returns {string}
|
|
15811
|
+
* Start of the serialized markdown.
|
|
15984
15812
|
*/
|
|
15985
|
-
function
|
|
15813
|
+
function peek$1(_, _1, state) {
|
|
15986
15814
|
return state.options.emphasis || '*'
|
|
15987
15815
|
}
|
|
15988
15816
|
|
|
15817
|
+
/**
|
|
15818
|
+
* Encode a code point as a character reference.
|
|
15819
|
+
*
|
|
15820
|
+
* @param {number} code
|
|
15821
|
+
* Code point to encode.
|
|
15822
|
+
* @returns {string}
|
|
15823
|
+
* Encoded character reference.
|
|
15824
|
+
*/
|
|
15825
|
+
function encodeCharacterReference(code) {
|
|
15826
|
+
return '&#x' + code.toString(16).toUpperCase() + ';'
|
|
15827
|
+
}
|
|
15828
|
+
|
|
15989
15829
|
/**
|
|
15990
15830
|
* @import {State} from 'mdast-util-to-markdown'
|
|
15991
15831
|
* @import {Heading} from 'mdast'
|
|
@@ -15993,29 +15833,34 @@ function emphasisPeek(_, _1, state) {
|
|
|
15993
15833
|
|
|
15994
15834
|
|
|
15995
15835
|
/**
|
|
15836
|
+
* Checks if a heading can be formatted as a setext heading.
|
|
15837
|
+
*
|
|
15996
15838
|
* @param {Heading} node
|
|
15839
|
+
* Node to check.
|
|
15997
15840
|
* @param {State} state
|
|
15841
|
+
* Info passed around.
|
|
15998
15842
|
* @returns {boolean}
|
|
15843
|
+
* Whether the heading can be formatted as a setext heading.
|
|
15999
15844
|
*/
|
|
16000
15845
|
function formatHeadingAsSetext(node, state) {
|
|
16001
15846
|
let literalWithBreak = false;
|
|
16002
15847
|
|
|
16003
15848
|
// Look for literals with a line break.
|
|
16004
15849
|
// Note that this also
|
|
16005
|
-
index$
|
|
15850
|
+
index$1.visit(node, function (node) {
|
|
16006
15851
|
if (
|
|
16007
15852
|
('value' in node && /\r?\n|\r/.test(node.value)) ||
|
|
16008
15853
|
node.type === 'break'
|
|
16009
15854
|
) {
|
|
16010
15855
|
literalWithBreak = true;
|
|
16011
|
-
return index$
|
|
15856
|
+
return index$1.EXIT
|
|
16012
15857
|
}
|
|
16013
15858
|
});
|
|
16014
15859
|
|
|
16015
15860
|
return Boolean(
|
|
16016
15861
|
(!node.depth || node.depth < 3) &&
|
|
16017
|
-
|
|
16018
|
-
|
|
15862
|
+
toString(node) &&
|
|
15863
|
+
(state.options.setext || literalWithBreak)
|
|
16019
15864
|
)
|
|
16020
15865
|
}
|
|
16021
15866
|
|
|
@@ -16026,11 +15871,18 @@ function formatHeadingAsSetext(node, state) {
|
|
|
16026
15871
|
|
|
16027
15872
|
|
|
16028
15873
|
/**
|
|
15874
|
+
* Serialize a heading node.
|
|
15875
|
+
*
|
|
16029
15876
|
* @param {Heading} node
|
|
15877
|
+
* Node to serialize.
|
|
16030
15878
|
* @param {Parents | undefined} _
|
|
15879
|
+
* Parent node.
|
|
16031
15880
|
* @param {State} state
|
|
15881
|
+
* Info passed around.
|
|
16032
15882
|
* @param {Info} info
|
|
15883
|
+
* Info on surrounding context.
|
|
16033
15884
|
* @returns {string}
|
|
15885
|
+
* Serialized markdown.
|
|
16034
15886
|
*/
|
|
16035
15887
|
function heading(node, _, state, info) {
|
|
16036
15888
|
const rank = Math.max(Math.min(6, node.depth || 1), 1);
|
|
@@ -16076,9 +15928,11 @@ function heading(node, _, state, info) {
|
|
|
16076
15928
|
...tracker.current()
|
|
16077
15929
|
});
|
|
16078
15930
|
|
|
16079
|
-
|
|
15931
|
+
const head = value.charCodeAt(0);
|
|
15932
|
+
|
|
15933
|
+
if (head === 9 /* `\t` */ || head === 32 /* ` ` */) {
|
|
16080
15934
|
// To do: what effect has the character reference on tracking?
|
|
16081
|
-
value = encodeCharacterReference(
|
|
15935
|
+
value = encodeCharacterReference(head) + value.slice(1);
|
|
16082
15936
|
}
|
|
16083
15937
|
|
|
16084
15938
|
value = value ? sequence + ' ' + value : sequence;
|
|
@@ -16100,15 +15954,22 @@ function heading(node, _, state, info) {
|
|
|
16100
15954
|
html$4.peek = htmlPeek;
|
|
16101
15955
|
|
|
16102
15956
|
/**
|
|
15957
|
+
* Serialize an HTML node.
|
|
15958
|
+
*
|
|
16103
15959
|
* @param {Html} node
|
|
15960
|
+
* Node to serialize.
|
|
16104
15961
|
* @returns {string}
|
|
15962
|
+
* Serialized markdown.
|
|
16105
15963
|
*/
|
|
16106
15964
|
function html$4(node) {
|
|
16107
15965
|
return node.value || ''
|
|
16108
15966
|
}
|
|
16109
15967
|
|
|
16110
15968
|
/**
|
|
15969
|
+
* Peek at this node.
|
|
15970
|
+
*
|
|
16111
15971
|
* @returns {string}
|
|
15972
|
+
* Start of the serialized markdown.
|
|
16112
15973
|
*/
|
|
16113
15974
|
function htmlPeek() {
|
|
16114
15975
|
return '<'
|
|
@@ -16123,11 +15984,18 @@ function htmlPeek() {
|
|
|
16123
15984
|
image.peek = imagePeek;
|
|
16124
15985
|
|
|
16125
15986
|
/**
|
|
15987
|
+
* Serialize an image node.
|
|
15988
|
+
*
|
|
16126
15989
|
* @param {Image} node
|
|
15990
|
+
* Node to serialize.
|
|
16127
15991
|
* @param {Parents | undefined} _
|
|
15992
|
+
* Parent node.
|
|
16128
15993
|
* @param {State} state
|
|
15994
|
+
* Info passed around.
|
|
16129
15995
|
* @param {Info} info
|
|
15996
|
+
* Info on surrounding context.
|
|
16130
15997
|
* @returns {string}
|
|
15998
|
+
* Serialized markdown.
|
|
16131
15999
|
*/
|
|
16132
16000
|
function image(node, _, state, info) {
|
|
16133
16001
|
const quote = checkQuote(state);
|
|
@@ -16190,7 +16058,10 @@ function image(node, _, state, info) {
|
|
|
16190
16058
|
}
|
|
16191
16059
|
|
|
16192
16060
|
/**
|
|
16061
|
+
* Peek at this node.
|
|
16062
|
+
*
|
|
16193
16063
|
* @returns {string}
|
|
16064
|
+
* Start of the serialized markdown.
|
|
16194
16065
|
*/
|
|
16195
16066
|
function imagePeek() {
|
|
16196
16067
|
return '!'
|
|
@@ -16204,11 +16075,18 @@ function imagePeek() {
|
|
|
16204
16075
|
imageReference.peek = imageReferencePeek;
|
|
16205
16076
|
|
|
16206
16077
|
/**
|
|
16078
|
+
* Serialize an image reference node.
|
|
16079
|
+
*
|
|
16207
16080
|
* @param {ImageReference} node
|
|
16081
|
+
* Node to serialize.
|
|
16208
16082
|
* @param {Parents | undefined} _
|
|
16083
|
+
* Parent node.
|
|
16209
16084
|
* @param {State} state
|
|
16085
|
+
* Info passed around.
|
|
16210
16086
|
* @param {Info} info
|
|
16087
|
+
* Info on surrounding context.
|
|
16211
16088
|
* @returns {string}
|
|
16089
|
+
* Serialized markdown.
|
|
16212
16090
|
*/
|
|
16213
16091
|
function imageReference(node, _, state, info) {
|
|
16214
16092
|
const type = node.referenceType;
|
|
@@ -16224,9 +16102,14 @@ function imageReference(node, _, state, info) {
|
|
|
16224
16102
|
value += tracker.move(alt + '][');
|
|
16225
16103
|
|
|
16226
16104
|
subexit();
|
|
16227
|
-
// Hide
|
|
16105
|
+
// Hide that we’re in phrasing as things like attention or code cannot form
|
|
16106
|
+
// in references.
|
|
16107
|
+
// Character escapes and references *do* work.
|
|
16108
|
+
// It is important to know about other constructs, such as table cells.
|
|
16228
16109
|
const stack = state.stack;
|
|
16229
|
-
state.stack =
|
|
16110
|
+
state.stack = stack.filter(function (d) {
|
|
16111
|
+
return d !== 'phrasing'
|
|
16112
|
+
});
|
|
16230
16113
|
subexit = state.enter('reference');
|
|
16231
16114
|
// Note: for proper tracking, we should reset the output positions when we end
|
|
16232
16115
|
// up making a `shortcut` reference, because then there is no brace output.
|
|
@@ -16254,7 +16137,10 @@ function imageReference(node, _, state, info) {
|
|
|
16254
16137
|
}
|
|
16255
16138
|
|
|
16256
16139
|
/**
|
|
16140
|
+
* Peek at this node.
|
|
16141
|
+
*
|
|
16257
16142
|
* @returns {string}
|
|
16143
|
+
* Start of the serialized markdown.
|
|
16258
16144
|
*/
|
|
16259
16145
|
function imageReferencePeek() {
|
|
16260
16146
|
return '!'
|
|
@@ -16268,10 +16154,16 @@ function imageReferencePeek() {
|
|
|
16268
16154
|
inlineCode.peek = inlineCodePeek;
|
|
16269
16155
|
|
|
16270
16156
|
/**
|
|
16157
|
+
* Serialize an inline code node.
|
|
16158
|
+
*
|
|
16271
16159
|
* @param {InlineCode} node
|
|
16160
|
+
* Node to serialize.
|
|
16272
16161
|
* @param {Parents | undefined} _
|
|
16162
|
+
* Parent node.
|
|
16273
16163
|
* @param {State} state
|
|
16164
|
+
* Info passed around.
|
|
16274
16165
|
* @returns {string}
|
|
16166
|
+
* Serialized markdown.
|
|
16275
16167
|
*/
|
|
16276
16168
|
function inlineCode(node, _, state) {
|
|
16277
16169
|
let value = node.value || '';
|
|
@@ -16288,8 +16180,8 @@ function inlineCode(node, _, state) {
|
|
|
16288
16180
|
// If this is not just spaces or eols (tabs don’t count), and either the
|
|
16289
16181
|
// first or last character are a space, eol, or tick, then pad with spaces.
|
|
16290
16182
|
if (
|
|
16291
|
-
/[
|
|
16292
|
-
((/^[
|
|
16183
|
+
/[^\n\r ]/.test(value) &&
|
|
16184
|
+
((/^[\n\r ]/.test(value) && /[\n\r ]$/.test(value)) || /^`|`$/.test(value))
|
|
16293
16185
|
) {
|
|
16294
16186
|
value = ' ' + value + ' ';
|
|
16295
16187
|
}
|
|
@@ -16304,14 +16196,15 @@ function inlineCode(node, _, state) {
|
|
|
16304
16196
|
while (++index < state.unsafe.length) {
|
|
16305
16197
|
const pattern = state.unsafe[index];
|
|
16306
16198
|
const expression = state.compilePattern(pattern);
|
|
16307
|
-
/** @type {RegExpExecArray | null} */
|
|
16308
|
-
let match;
|
|
16309
16199
|
|
|
16310
16200
|
// Only look for `atBreak`s.
|
|
16311
16201
|
// Btw: note that `atBreak` patterns will always start the regex at LF or
|
|
16312
16202
|
// CR.
|
|
16313
16203
|
if (!pattern.atBreak) continue
|
|
16314
16204
|
|
|
16205
|
+
/** @type {RegExpExecArray | null} */
|
|
16206
|
+
let match;
|
|
16207
|
+
|
|
16315
16208
|
while ((match = expression.exec(value))) {
|
|
16316
16209
|
let position = match.index;
|
|
16317
16210
|
|
|
@@ -16331,7 +16224,10 @@ function inlineCode(node, _, state) {
|
|
|
16331
16224
|
}
|
|
16332
16225
|
|
|
16333
16226
|
/**
|
|
16227
|
+
* Peek at this node.
|
|
16228
|
+
*
|
|
16334
16229
|
* @returns {string}
|
|
16230
|
+
* Start of the serialized markdown.
|
|
16335
16231
|
*/
|
|
16336
16232
|
function inlineCodePeek() {
|
|
16337
16233
|
return '`'
|
|
@@ -16344,30 +16240,35 @@ function inlineCodePeek() {
|
|
|
16344
16240
|
|
|
16345
16241
|
|
|
16346
16242
|
/**
|
|
16243
|
+
* Checks if a link can be formatted as an autolink.
|
|
16244
|
+
*
|
|
16347
16245
|
* @param {Link} node
|
|
16246
|
+
* Node to check.
|
|
16348
16247
|
* @param {State} state
|
|
16248
|
+
* Info passed around.
|
|
16349
16249
|
* @returns {boolean}
|
|
16250
|
+
* Whether the link can be formatted as an autolink.
|
|
16350
16251
|
*/
|
|
16351
16252
|
function formatLinkAsAutolink(node, state) {
|
|
16352
16253
|
const raw = toString(node);
|
|
16353
16254
|
|
|
16354
16255
|
return Boolean(
|
|
16355
16256
|
!state.options.resourceLink &&
|
|
16356
|
-
|
|
16357
|
-
|
|
16358
|
-
|
|
16359
|
-
|
|
16360
|
-
|
|
16361
|
-
|
|
16362
|
-
|
|
16363
|
-
|
|
16364
|
-
|
|
16365
|
-
|
|
16366
|
-
|
|
16367
|
-
|
|
16368
|
-
|
|
16369
|
-
|
|
16370
|
-
|
|
16257
|
+
// If there’s a url…
|
|
16258
|
+
node.url &&
|
|
16259
|
+
// And there’s no title…
|
|
16260
|
+
!node.title &&
|
|
16261
|
+
// And the content of `node` is a single text node…
|
|
16262
|
+
node.children &&
|
|
16263
|
+
node.children.length === 1 &&
|
|
16264
|
+
node.children[0].type === 'text' &&
|
|
16265
|
+
// And if the url is the same as the content…
|
|
16266
|
+
(raw === node.url || 'mailto:' + raw === node.url) &&
|
|
16267
|
+
// And that starts w/ a protocol…
|
|
16268
|
+
/^[a-z][+\-.a-z]+:/i.test(node.url) &&
|
|
16269
|
+
// And that doesn’t contain ASCII control codes (character escapes and
|
|
16270
|
+
// references don’t work), space, or angle brackets…
|
|
16271
|
+
!/[\0- <>\u007F]/.test(node.url)
|
|
16371
16272
|
)
|
|
16372
16273
|
}
|
|
16373
16274
|
|
|
@@ -16381,26 +16282,35 @@ function formatLinkAsAutolink(node, state) {
|
|
|
16381
16282
|
link.peek = linkPeek;
|
|
16382
16283
|
|
|
16383
16284
|
/**
|
|
16285
|
+
* Serialize a link node.
|
|
16286
|
+
*
|
|
16384
16287
|
* @param {Link} node
|
|
16288
|
+
* Node to serialize.
|
|
16385
16289
|
* @param {Parents | undefined} _
|
|
16290
|
+
* Parent node.
|
|
16386
16291
|
* @param {State} state
|
|
16292
|
+
* Info passed around.
|
|
16387
16293
|
* @param {Info} info
|
|
16294
|
+
* Info on surrounding context.
|
|
16388
16295
|
* @returns {string}
|
|
16296
|
+
* Serialized markdown.
|
|
16389
16297
|
*/
|
|
16390
16298
|
function link(node, _, state, info) {
|
|
16391
16299
|
const quote = checkQuote(state);
|
|
16392
16300
|
const suffix = quote === '"' ? 'Quote' : 'Apostrophe';
|
|
16393
16301
|
const tracker = state.createTracker(info);
|
|
16394
|
-
/** @type {Exit} */
|
|
16395
|
-
let exit;
|
|
16396
|
-
/** @type {Exit} */
|
|
16397
|
-
let subexit;
|
|
16398
16302
|
|
|
16399
16303
|
if (formatLinkAsAutolink(node, state)) {
|
|
16400
|
-
// Hide
|
|
16304
|
+
// Hide that we’re in phrasing as things like attention or code cannot form
|
|
16305
|
+
// in autolinks.
|
|
16306
|
+
// Character escapes also don’t work (nor character references),
|
|
16307
|
+
// but that is a different matter, which `safe.js` handles for `autolink`.
|
|
16308
|
+
// It is important to know about other constructs, such as table cells.
|
|
16401
16309
|
const stack = state.stack;
|
|
16402
|
-
state.stack =
|
|
16403
|
-
|
|
16310
|
+
state.stack = stack.filter(function (d) {
|
|
16311
|
+
return d !== 'phrasing'
|
|
16312
|
+
});
|
|
16313
|
+
const exit = state.enter('autolink');
|
|
16404
16314
|
let value = tracker.move('<');
|
|
16405
16315
|
value += tracker.move(
|
|
16406
16316
|
state.containerPhrasing(node, {
|
|
@@ -16415,8 +16325,8 @@ function link(node, _, state, info) {
|
|
|
16415
16325
|
return value
|
|
16416
16326
|
}
|
|
16417
16327
|
|
|
16418
|
-
exit = state.enter('link');
|
|
16419
|
-
subexit = state.enter('label');
|
|
16328
|
+
const exit = state.enter('link');
|
|
16329
|
+
let subexit = state.enter('label');
|
|
16420
16330
|
let value = tracker.move('[');
|
|
16421
16331
|
value += tracker.move(
|
|
16422
16332
|
state.containerPhrasing(node, {
|
|
@@ -16475,10 +16385,16 @@ function link(node, _, state, info) {
|
|
|
16475
16385
|
}
|
|
16476
16386
|
|
|
16477
16387
|
/**
|
|
16388
|
+
* Peek at this node.
|
|
16389
|
+
*
|
|
16478
16390
|
* @param {Link} node
|
|
16391
|
+
* Node to peek at.
|
|
16479
16392
|
* @param {Parents | undefined} _
|
|
16393
|
+
* Parent node.
|
|
16480
16394
|
* @param {State} state
|
|
16395
|
+
* Info passed around.
|
|
16481
16396
|
* @returns {string}
|
|
16397
|
+
* Start of the serialized markdown.
|
|
16482
16398
|
*/
|
|
16483
16399
|
function linkPeek(node, _, state) {
|
|
16484
16400
|
return formatLinkAsAutolink(node, state) ? '<' : '['
|
|
@@ -16492,11 +16408,18 @@ function linkPeek(node, _, state) {
|
|
|
16492
16408
|
linkReference.peek = linkReferencePeek;
|
|
16493
16409
|
|
|
16494
16410
|
/**
|
|
16411
|
+
* Serialize a link reference node.
|
|
16412
|
+
*
|
|
16495
16413
|
* @param {LinkReference} node
|
|
16414
|
+
* Node to serialize.
|
|
16496
16415
|
* @param {Parents | undefined} _
|
|
16416
|
+
* Parent node.
|
|
16497
16417
|
* @param {State} state
|
|
16418
|
+
* Info passed around.
|
|
16498
16419
|
* @param {Info} info
|
|
16420
|
+
* Info on surrounding context.
|
|
16499
16421
|
* @returns {string}
|
|
16422
|
+
* Serialized markdown.
|
|
16500
16423
|
*/
|
|
16501
16424
|
function linkReference(node, _, state, info) {
|
|
16502
16425
|
const type = node.referenceType;
|
|
@@ -16512,9 +16435,14 @@ function linkReference(node, _, state, info) {
|
|
|
16512
16435
|
value += tracker.move(text + '][');
|
|
16513
16436
|
|
|
16514
16437
|
subexit();
|
|
16515
|
-
// Hide
|
|
16438
|
+
// Hide that we’re in phrasing as things like attention or code cannot form
|
|
16439
|
+
// in references.
|
|
16440
|
+
// Character escapes and references *do* work.
|
|
16441
|
+
// It is important to know about other constructs, such as table cells.
|
|
16516
16442
|
const stack = state.stack;
|
|
16517
|
-
state.stack =
|
|
16443
|
+
state.stack = stack.filter(function (d) {
|
|
16444
|
+
return d !== 'phrasing'
|
|
16445
|
+
});
|
|
16518
16446
|
subexit = state.enter('reference');
|
|
16519
16447
|
// Note: for proper tracking, we should reset the output positions when we end
|
|
16520
16448
|
// up making a `shortcut` reference, because then there is no brace output.
|
|
@@ -16542,7 +16470,10 @@ function linkReference(node, _, state, info) {
|
|
|
16542
16470
|
}
|
|
16543
16471
|
|
|
16544
16472
|
/**
|
|
16473
|
+
* Peek at this node.
|
|
16474
|
+
*
|
|
16545
16475
|
* @returns {string}
|
|
16476
|
+
* Start of the serialized markdown.
|
|
16546
16477
|
*/
|
|
16547
16478
|
function linkReferencePeek() {
|
|
16548
16479
|
return '['
|
|
@@ -16553,8 +16484,12 @@ function linkReferencePeek() {
|
|
|
16553
16484
|
*/
|
|
16554
16485
|
|
|
16555
16486
|
/**
|
|
16487
|
+
* Checks the preferred list bullet option.
|
|
16488
|
+
*
|
|
16556
16489
|
* @param {State} state
|
|
16490
|
+
* Info passed around.
|
|
16557
16491
|
* @returns {Exclude<Options['bullet'], null | undefined>}
|
|
16492
|
+
* Preferred list bullet.
|
|
16558
16493
|
*/
|
|
16559
16494
|
function checkBullet(state) {
|
|
16560
16495
|
const marker = state.options.bullet || '*';
|
|
@@ -16576,8 +16511,12 @@ function checkBullet(state) {
|
|
|
16576
16511
|
|
|
16577
16512
|
|
|
16578
16513
|
/**
|
|
16514
|
+
* Checks the preferred alternate list bullet option.
|
|
16515
|
+
*
|
|
16579
16516
|
* @param {State} state
|
|
16517
|
+
* Info passed around.
|
|
16580
16518
|
* @returns {Exclude<Options['bullet'], null | undefined>}
|
|
16519
|
+
* Preferred alternate list bullet.
|
|
16581
16520
|
*/
|
|
16582
16521
|
function checkBulletOther(state) {
|
|
16583
16522
|
const bullet = checkBullet(state);
|
|
@@ -16613,8 +16552,12 @@ function checkBulletOther(state) {
|
|
|
16613
16552
|
*/
|
|
16614
16553
|
|
|
16615
16554
|
/**
|
|
16555
|
+
* Checks the preferred ordered list bullet option.
|
|
16556
|
+
*
|
|
16616
16557
|
* @param {State} state
|
|
16558
|
+
* Info passed around.
|
|
16617
16559
|
* @returns {Exclude<Options['bulletOrdered'], null | undefined>}
|
|
16560
|
+
* Preferred ordered list bullet.
|
|
16618
16561
|
*/
|
|
16619
16562
|
function checkBulletOrdered(state) {
|
|
16620
16563
|
const marker = state.options.bulletOrdered || '.';
|
|
@@ -16635,8 +16578,12 @@ function checkBulletOrdered(state) {
|
|
|
16635
16578
|
*/
|
|
16636
16579
|
|
|
16637
16580
|
/**
|
|
16581
|
+
* Checks the preferred rule option.
|
|
16582
|
+
*
|
|
16638
16583
|
* @param {State} state
|
|
16584
|
+
* Info passed around.
|
|
16639
16585
|
* @returns {Exclude<Options['rule'], null | undefined>}
|
|
16586
|
+
* Preferred rule marker.
|
|
16640
16587
|
*/
|
|
16641
16588
|
function checkRule(state) {
|
|
16642
16589
|
const marker = state.options.rule || '*';
|
|
@@ -16659,11 +16606,18 @@ function checkRule(state) {
|
|
|
16659
16606
|
|
|
16660
16607
|
|
|
16661
16608
|
/**
|
|
16609
|
+
* Serialize a list node.
|
|
16610
|
+
*
|
|
16662
16611
|
* @param {List} node
|
|
16612
|
+
* Node to serialize.
|
|
16663
16613
|
* @param {Parents | undefined} parent
|
|
16614
|
+
* Parent node.
|
|
16664
16615
|
* @param {State} state
|
|
16616
|
+
* Info passed around.
|
|
16665
16617
|
* @param {Info} info
|
|
16618
|
+
* Info on surrounding context.
|
|
16666
16619
|
* @returns {string}
|
|
16620
|
+
* Serialized markdown.
|
|
16667
16621
|
*/
|
|
16668
16622
|
function list(node, parent, state, info) {
|
|
16669
16623
|
const exit = state.enter('list');
|
|
@@ -16754,8 +16708,12 @@ function list(node, parent, state, info) {
|
|
|
16754
16708
|
*/
|
|
16755
16709
|
|
|
16756
16710
|
/**
|
|
16711
|
+
* Checks the preferred list item indent option.
|
|
16712
|
+
*
|
|
16757
16713
|
* @param {State} state
|
|
16714
|
+
* Info passed around.
|
|
16758
16715
|
* @returns {Exclude<Options['listItemIndent'], null | undefined>}
|
|
16716
|
+
* Preferred list item indent.
|
|
16759
16717
|
*/
|
|
16760
16718
|
function checkListItemIndent(state) {
|
|
16761
16719
|
const style = state.options.listItemIndent || 'one';
|
|
@@ -16778,11 +16736,18 @@ function checkListItemIndent(state) {
|
|
|
16778
16736
|
|
|
16779
16737
|
|
|
16780
16738
|
/**
|
|
16739
|
+
* Serialize a list item node.
|
|
16740
|
+
*
|
|
16781
16741
|
* @param {ListItem} node
|
|
16742
|
+
* Node to serialize.
|
|
16782
16743
|
* @param {Parents | undefined} parent
|
|
16744
|
+
* Parent node.
|
|
16783
16745
|
* @param {State} state
|
|
16746
|
+
* Info passed around.
|
|
16784
16747
|
* @param {Info} info
|
|
16748
|
+
* Info on surrounding context.
|
|
16785
16749
|
* @returns {string}
|
|
16750
|
+
* Serialized markdown.
|
|
16786
16751
|
*/
|
|
16787
16752
|
function listItem(node, parent, state, info) {
|
|
16788
16753
|
const listItemIndent = checkListItemIndent(state);
|
|
@@ -16822,7 +16787,11 @@ function listItem(node, parent, state, info) {
|
|
|
16822
16787
|
|
|
16823
16788
|
return value
|
|
16824
16789
|
|
|
16825
|
-
/**
|
|
16790
|
+
/**
|
|
16791
|
+
* Indent lines of the list item.
|
|
16792
|
+
*
|
|
16793
|
+
* @type {Map}
|
|
16794
|
+
*/
|
|
16826
16795
|
function map(line, index, blank) {
|
|
16827
16796
|
if (index) {
|
|
16828
16797
|
return (blank ? '' : ' '.repeat(size)) + line
|
|
@@ -16838,11 +16807,18 @@ function listItem(node, parent, state, info) {
|
|
|
16838
16807
|
*/
|
|
16839
16808
|
|
|
16840
16809
|
/**
|
|
16810
|
+
* Serialize a paragraph node.
|
|
16811
|
+
*
|
|
16841
16812
|
* @param {Paragraph} node
|
|
16813
|
+
* Node to serialize.
|
|
16842
16814
|
* @param {Parents | undefined} _
|
|
16815
|
+
* Parent node.
|
|
16843
16816
|
* @param {State} state
|
|
16817
|
+
* Info passed around.
|
|
16844
16818
|
* @param {Info} info
|
|
16819
|
+
* Info on surrounding context.
|
|
16845
16820
|
* @returns {string}
|
|
16821
|
+
* Serialized markdown.
|
|
16846
16822
|
*/
|
|
16847
16823
|
function paragraph(node, _, state, info) {
|
|
16848
16824
|
const exit = state.enter('paragraph');
|
|
@@ -16853,41 +16829,6 @@ function paragraph(node, _, state, info) {
|
|
|
16853
16829
|
return value
|
|
16854
16830
|
}
|
|
16855
16831
|
|
|
16856
|
-
/**
|
|
16857
|
-
* @typedef {import('mdast').PhrasingContent} PhrasingContent
|
|
16858
|
-
*/
|
|
16859
|
-
|
|
16860
|
-
|
|
16861
|
-
/**
|
|
16862
|
-
* Check if the given value is *phrasing content*.
|
|
16863
|
-
*
|
|
16864
|
-
* > 👉 **Note**: Excludes `html`, which can be both phrasing or flow.
|
|
16865
|
-
*
|
|
16866
|
-
* @param node
|
|
16867
|
-
* Thing to check, typically `Node`.
|
|
16868
|
-
* @returns
|
|
16869
|
-
* Whether `value` is phrasing content.
|
|
16870
|
-
*/
|
|
16871
|
-
|
|
16872
|
-
const phrasing =
|
|
16873
|
-
/** @type {(node?: unknown) => node is PhrasingContent} */
|
|
16874
|
-
(
|
|
16875
|
-
index$2.convert([
|
|
16876
|
-
'break',
|
|
16877
|
-
'delete',
|
|
16878
|
-
'emphasis',
|
|
16879
|
-
'footnote',
|
|
16880
|
-
'footnoteReference',
|
|
16881
|
-
'image',
|
|
16882
|
-
'imageReference',
|
|
16883
|
-
'inlineCode',
|
|
16884
|
-
'link',
|
|
16885
|
-
'linkReference',
|
|
16886
|
-
'strong',
|
|
16887
|
-
'text'
|
|
16888
|
-
])
|
|
16889
|
-
);
|
|
16890
|
-
|
|
16891
16832
|
/**
|
|
16892
16833
|
* @import {Info, State} from 'mdast-util-to-markdown'
|
|
16893
16834
|
* @import {Parents, Root} from 'mdast'
|
|
@@ -16895,11 +16836,18 @@ const phrasing =
|
|
|
16895
16836
|
|
|
16896
16837
|
|
|
16897
16838
|
/**
|
|
16839
|
+
* Serialize a root node.
|
|
16840
|
+
*
|
|
16898
16841
|
* @param {Root} node
|
|
16842
|
+
* Node to serialize.
|
|
16899
16843
|
* @param {Parents | undefined} _
|
|
16844
|
+
* Parent node.
|
|
16900
16845
|
* @param {State} state
|
|
16846
|
+
* Info passed around.
|
|
16901
16847
|
* @param {Info} info
|
|
16848
|
+
* Info on surrounding context.
|
|
16902
16849
|
* @returns {string}
|
|
16850
|
+
* Serialized markdown.
|
|
16903
16851
|
*/
|
|
16904
16852
|
function root$2(node, _, state, info) {
|
|
16905
16853
|
// Note: `html` nodes are ambiguous.
|
|
@@ -16907,8 +16855,12 @@ function root$2(node, _, state, info) {
|
|
|
16907
16855
|
return phrasing(d)
|
|
16908
16856
|
});
|
|
16909
16857
|
|
|
16910
|
-
|
|
16911
|
-
|
|
16858
|
+
if (!hasPhrasing) return state.containerFlow(node, info)
|
|
16859
|
+
|
|
16860
|
+
const exit = state.enter('phrasing');
|
|
16861
|
+
const value = state.containerPhrasing(node, info);
|
|
16862
|
+
exit();
|
|
16863
|
+
return value
|
|
16912
16864
|
}
|
|
16913
16865
|
|
|
16914
16866
|
/**
|
|
@@ -16916,8 +16868,12 @@ function root$2(node, _, state, info) {
|
|
|
16916
16868
|
*/
|
|
16917
16869
|
|
|
16918
16870
|
/**
|
|
16871
|
+
* Checks the preferred strong option.
|
|
16872
|
+
*
|
|
16919
16873
|
* @param {State} state
|
|
16874
|
+
* Info passed around.
|
|
16920
16875
|
* @returns {Exclude<Options['strong'], null | undefined>}
|
|
16876
|
+
* Preferred strong marker.
|
|
16921
16877
|
*/
|
|
16922
16878
|
function checkStrong(state) {
|
|
16923
16879
|
const marker = state.options.strong || '*';
|
|
@@ -16934,69 +16890,69 @@ function checkStrong(state) {
|
|
|
16934
16890
|
}
|
|
16935
16891
|
|
|
16936
16892
|
/**
|
|
16937
|
-
* @import {Info, State} from 'mdast-util-to-markdown'
|
|
16893
|
+
* @import {AttentionInfo, Info, State} from 'mdast-util-to-markdown'
|
|
16938
16894
|
* @import {Parents, Strong} from 'mdast'
|
|
16939
16895
|
*/
|
|
16940
16896
|
|
|
16941
16897
|
|
|
16942
|
-
strong.
|
|
16898
|
+
strong.attention = attention;
|
|
16899
|
+
strong.peek = peek;
|
|
16943
16900
|
|
|
16944
16901
|
/**
|
|
16902
|
+
* Serialize a strong node.
|
|
16903
|
+
*
|
|
16904
|
+
* Attention is properly handled by `containerPhrasing`.
|
|
16905
|
+
*
|
|
16945
16906
|
* @param {Strong} node
|
|
16907
|
+
* Node to serialize.
|
|
16946
16908
|
* @param {Parents | undefined} _
|
|
16909
|
+
* Parent node.
|
|
16947
16910
|
* @param {State} state
|
|
16911
|
+
* Info passed around.
|
|
16948
16912
|
* @param {Info} info
|
|
16913
|
+
* Info on surrounding context.
|
|
16949
16914
|
* @returns {string}
|
|
16915
|
+
* Serialized markdown.
|
|
16950
16916
|
*/
|
|
16951
16917
|
function strong(node, _, state, info) {
|
|
16952
|
-
const
|
|
16953
|
-
const
|
|
16954
|
-
const tracker = state.createTracker(info);
|
|
16955
|
-
const before = tracker.move(marker + marker);
|
|
16956
|
-
|
|
16957
|
-
let between = tracker.move(
|
|
16958
|
-
state.containerPhrasing(node, {
|
|
16959
|
-
after: marker,
|
|
16960
|
-
before,
|
|
16961
|
-
...tracker.current()
|
|
16962
|
-
})
|
|
16963
|
-
);
|
|
16964
|
-
const betweenHead = between.charCodeAt(0);
|
|
16965
|
-
const open = encodeInfo(
|
|
16966
|
-
info.before.charCodeAt(info.before.length - 1),
|
|
16967
|
-
betweenHead,
|
|
16968
|
-
marker
|
|
16969
|
-
);
|
|
16970
|
-
|
|
16971
|
-
if (open.inside) {
|
|
16972
|
-
between = encodeCharacterReference(betweenHead) + between.slice(1);
|
|
16973
|
-
}
|
|
16974
|
-
|
|
16975
|
-
const betweenTail = between.charCodeAt(between.length - 1);
|
|
16976
|
-
const close = encodeInfo(info.after.charCodeAt(0), betweenTail, marker);
|
|
16977
|
-
|
|
16978
|
-
if (close.inside) {
|
|
16979
|
-
between = between.slice(0, -1) + encodeCharacterReference(betweenTail);
|
|
16980
|
-
}
|
|
16981
|
-
|
|
16982
|
-
const after = tracker.move(marker + marker);
|
|
16983
|
-
|
|
16918
|
+
const exit = state.enter('phrasing');
|
|
16919
|
+
const value = state.containerPhrasing({type: 'root', children: [node]}, info);
|
|
16984
16920
|
exit();
|
|
16921
|
+
return value
|
|
16922
|
+
}
|
|
16985
16923
|
|
|
16986
|
-
|
|
16987
|
-
|
|
16988
|
-
|
|
16989
|
-
|
|
16990
|
-
|
|
16924
|
+
/**
|
|
16925
|
+
* Serialize a strong node as attention.
|
|
16926
|
+
*
|
|
16927
|
+
* @param {Strong} _
|
|
16928
|
+
* Node to serialize.
|
|
16929
|
+
* @param {State} state
|
|
16930
|
+
* Info passed around.
|
|
16931
|
+
* @returns {AttentionInfo}
|
|
16932
|
+
* Info on how to serialize the node.
|
|
16933
|
+
*/
|
|
16934
|
+
function attention(_, state) {
|
|
16935
|
+
const marker = checkStrong(state);
|
|
16936
|
+
return {
|
|
16937
|
+
construct: 'strong',
|
|
16938
|
+
markers: marker === '*' ? ['*', '_'] : ['_', '*'],
|
|
16939
|
+
sizes: [2]
|
|
16940
|
+
}
|
|
16991
16941
|
}
|
|
16992
16942
|
|
|
16993
16943
|
/**
|
|
16944
|
+
* Peek at this node.
|
|
16945
|
+
*
|
|
16994
16946
|
* @param {Strong} _
|
|
16947
|
+
* Node to serialize.
|
|
16995
16948
|
* @param {Parents | undefined} _1
|
|
16949
|
+
* Parent node.
|
|
16996
16950
|
* @param {State} state
|
|
16951
|
+
* Info passed around.
|
|
16997
16952
|
* @returns {string}
|
|
16953
|
+
* Start of the serialized markdown.
|
|
16998
16954
|
*/
|
|
16999
|
-
function
|
|
16955
|
+
function peek(_, _1, state) {
|
|
17000
16956
|
return state.options.strong || '*'
|
|
17001
16957
|
}
|
|
17002
16958
|
|
|
@@ -17006,11 +16962,18 @@ function strongPeek(_, _1, state) {
|
|
|
17006
16962
|
*/
|
|
17007
16963
|
|
|
17008
16964
|
/**
|
|
16965
|
+
* Serialize a text node.
|
|
16966
|
+
*
|
|
17009
16967
|
* @param {Text} node
|
|
16968
|
+
* Node to serialize.
|
|
17010
16969
|
* @param {Parents | undefined} _
|
|
16970
|
+
* Parent node.
|
|
17011
16971
|
* @param {State} state
|
|
16972
|
+
* Info passed around.
|
|
17012
16973
|
* @param {Info} info
|
|
16974
|
+
* Info on surrounding context.
|
|
17013
16975
|
* @returns {string}
|
|
16976
|
+
* Serialized markdown.
|
|
17014
16977
|
*/
|
|
17015
16978
|
function text$3(node, _, state, info) {
|
|
17016
16979
|
return state.safe(node.value, info)
|
|
@@ -17021,8 +16984,12 @@ function text$3(node, _, state, info) {
|
|
|
17021
16984
|
*/
|
|
17022
16985
|
|
|
17023
16986
|
/**
|
|
16987
|
+
* Checks the preferred rule repetition option.
|
|
16988
|
+
*
|
|
17024
16989
|
* @param {State} state
|
|
16990
|
+
* Info passed around.
|
|
17025
16991
|
* @returns {Exclude<Options['ruleRepetition'], null | undefined>}
|
|
16992
|
+
* Preferred rule repetition.
|
|
17026
16993
|
*/
|
|
17027
16994
|
function checkRuleRepetition(state) {
|
|
17028
16995
|
const repetition = state.options.ruleRepetition || 3;
|
|
@@ -17045,10 +17012,16 @@ function checkRuleRepetition(state) {
|
|
|
17045
17012
|
|
|
17046
17013
|
|
|
17047
17014
|
/**
|
|
17015
|
+
* Serialize a thematic break node.
|
|
17016
|
+
*
|
|
17048
17017
|
* @param {ThematicBreak} _
|
|
17018
|
+
* Node to serialize.
|
|
17049
17019
|
* @param {Parents | undefined} _1
|
|
17020
|
+
* Parent node.
|
|
17050
17021
|
* @param {State} state
|
|
17022
|
+
* Info passed around.
|
|
17051
17023
|
* @returns {string}
|
|
17024
|
+
* Serialized markdown.
|
|
17052
17025
|
*/
|
|
17053
17026
|
function thematicBreak(_, _1, state) {
|
|
17054
17027
|
const value = (
|
|
@@ -17190,7 +17163,7 @@ function exitCodeText(token) {
|
|
|
17190
17163
|
let value = this.resume();
|
|
17191
17164
|
|
|
17192
17165
|
if (this.data.inTable) {
|
|
17193
|
-
value = value.replace(/\\([\\|])/g, replace);
|
|
17166
|
+
value = value.replace(/\\([\\|])/g, replace$1);
|
|
17194
17167
|
}
|
|
17195
17168
|
|
|
17196
17169
|
const node = this.stack[this.stack.length - 1];
|
|
@@ -17203,7 +17176,7 @@ function exitCodeText(token) {
|
|
|
17203
17176
|
* @param {string} $1
|
|
17204
17177
|
* @returns {string}
|
|
17205
17178
|
*/
|
|
17206
|
-
function replace($0, $1) {
|
|
17179
|
+
function replace$1($0, $1) {
|
|
17207
17180
|
// Pipes work, backslashes don’t (but can’t escape pipes).
|
|
17208
17181
|
return $1 === '|' ? $1 : $0
|
|
17209
17182
|
}
|
|
@@ -20565,6 +20538,59 @@ function remarkGfm(options) {
|
|
|
20565
20538
|
toMarkdownExtensions.push(gfmToMarkdown(settings));
|
|
20566
20539
|
}
|
|
20567
20540
|
|
|
20541
|
+
/**
|
|
20542
|
+
* @typedef {import('mdast').Nodes} Nodes
|
|
20543
|
+
* @typedef {import('mdast-util-find-and-replace').ReplaceFunction} ReplaceFunction
|
|
20544
|
+
*/
|
|
20545
|
+
|
|
20546
|
+
|
|
20547
|
+
/**
|
|
20548
|
+
* Turn normal line endings into hard breaks.
|
|
20549
|
+
*
|
|
20550
|
+
* @param {Nodes} tree
|
|
20551
|
+
* Tree to change.
|
|
20552
|
+
* @returns {undefined}
|
|
20553
|
+
* Nothing.
|
|
20554
|
+
*/
|
|
20555
|
+
function newlineToBreak(tree) {
|
|
20556
|
+
findAndReplace(tree, [/\r?\n|\r/g, replace]);
|
|
20557
|
+
}
|
|
20558
|
+
|
|
20559
|
+
/**
|
|
20560
|
+
* Replace line endings.
|
|
20561
|
+
*
|
|
20562
|
+
* @type {ReplaceFunction}
|
|
20563
|
+
*/
|
|
20564
|
+
function replace() {
|
|
20565
|
+
return {type: 'break'}
|
|
20566
|
+
}
|
|
20567
|
+
|
|
20568
|
+
/**
|
|
20569
|
+
* @typedef {import('mdast').Root} Root
|
|
20570
|
+
*/
|
|
20571
|
+
|
|
20572
|
+
|
|
20573
|
+
/**
|
|
20574
|
+
* Support hard breaks without needing spaces or escapes (turns enters into
|
|
20575
|
+
* `<br>`s).
|
|
20576
|
+
*
|
|
20577
|
+
* @returns
|
|
20578
|
+
* Transform.
|
|
20579
|
+
*/
|
|
20580
|
+
function remarkBreaks() {
|
|
20581
|
+
/**
|
|
20582
|
+
* Transform.
|
|
20583
|
+
*
|
|
20584
|
+
* @param {Root} tree
|
|
20585
|
+
* Tree.
|
|
20586
|
+
* @returns {undefined}
|
|
20587
|
+
* Nothing.
|
|
20588
|
+
*/
|
|
20589
|
+
return function (tree) {
|
|
20590
|
+
newlineToBreak(tree);
|
|
20591
|
+
}
|
|
20592
|
+
}
|
|
20593
|
+
|
|
20568
20594
|
/**
|
|
20569
20595
|
* @typedef {import('./info.js').Info} Info
|
|
20570
20596
|
* @typedef {Record<string, Info>} Properties
|
|
@@ -21822,157 +21848,6 @@ function camelcase$1($0) {
|
|
|
21822
21848
|
const html$2 = merge$1([xml$1, xlink$1, xmlns$1, aria$1, html$3], 'html');
|
|
21823
21849
|
const svg$2 = merge$1([xml$1, xlink$1, xmlns$1, aria$1, svg$3], 'svg');
|
|
21824
21850
|
|
|
21825
|
-
/**
|
|
21826
|
-
* @typedef Options
|
|
21827
|
-
* Configuration for `stringify`.
|
|
21828
|
-
* @property {boolean} [padLeft=true]
|
|
21829
|
-
* Whether to pad a space before a token.
|
|
21830
|
-
* @property {boolean} [padRight=false]
|
|
21831
|
-
* Whether to pad a space after a token.
|
|
21832
|
-
*/
|
|
21833
|
-
|
|
21834
|
-
/**
|
|
21835
|
-
* @typedef {Options} StringifyOptions
|
|
21836
|
-
* Please use `StringifyOptions` instead.
|
|
21837
|
-
*/
|
|
21838
|
-
|
|
21839
|
-
/**
|
|
21840
|
-
* Parse comma-separated tokens to an array.
|
|
21841
|
-
*
|
|
21842
|
-
* @param {string} value
|
|
21843
|
-
* Comma-separated tokens.
|
|
21844
|
-
* @returns {Array<string>}
|
|
21845
|
-
* List of tokens.
|
|
21846
|
-
*/
|
|
21847
|
-
function parse$1(value) {
|
|
21848
|
-
/** @type {Array<string>} */
|
|
21849
|
-
const tokens = [];
|
|
21850
|
-
const input = String(value || '');
|
|
21851
|
-
let index = input.indexOf(',');
|
|
21852
|
-
let start = 0;
|
|
21853
|
-
/** @type {boolean} */
|
|
21854
|
-
let end = false;
|
|
21855
|
-
|
|
21856
|
-
while (!end) {
|
|
21857
|
-
if (index === -1) {
|
|
21858
|
-
index = input.length;
|
|
21859
|
-
end = true;
|
|
21860
|
-
}
|
|
21861
|
-
|
|
21862
|
-
const token = input.slice(start, index).trim();
|
|
21863
|
-
|
|
21864
|
-
if (token || !end) {
|
|
21865
|
-
tokens.push(token);
|
|
21866
|
-
}
|
|
21867
|
-
|
|
21868
|
-
start = index + 1;
|
|
21869
|
-
index = input.indexOf(',', start);
|
|
21870
|
-
}
|
|
21871
|
-
|
|
21872
|
-
return tokens
|
|
21873
|
-
}
|
|
21874
|
-
|
|
21875
|
-
/**
|
|
21876
|
-
* @typedef {import('hast').Element} Element
|
|
21877
|
-
* @typedef {import('hast').Properties} Properties
|
|
21878
|
-
*/
|
|
21879
|
-
|
|
21880
|
-
/**
|
|
21881
|
-
* @template {string} SimpleSelector
|
|
21882
|
-
* Selector type.
|
|
21883
|
-
* @template {string} DefaultTagName
|
|
21884
|
-
* Default tag name.
|
|
21885
|
-
* @typedef {(
|
|
21886
|
-
* SimpleSelector extends ''
|
|
21887
|
-
* ? DefaultTagName
|
|
21888
|
-
* : SimpleSelector extends `${infer TagName}.${infer Rest}`
|
|
21889
|
-
* ? ExtractTagName<TagName, DefaultTagName>
|
|
21890
|
-
* : SimpleSelector extends `${infer TagName}#${infer Rest}`
|
|
21891
|
-
* ? ExtractTagName<TagName, DefaultTagName>
|
|
21892
|
-
* : SimpleSelector extends string
|
|
21893
|
-
* ? SimpleSelector
|
|
21894
|
-
* : DefaultTagName
|
|
21895
|
-
* )} ExtractTagName
|
|
21896
|
-
* Extract tag name from a simple selector.
|
|
21897
|
-
*/
|
|
21898
|
-
|
|
21899
|
-
const search$1 = /[#.]/g;
|
|
21900
|
-
|
|
21901
|
-
/**
|
|
21902
|
-
* Create a hast element from a simple CSS selector.
|
|
21903
|
-
*
|
|
21904
|
-
* @template {string} Selector
|
|
21905
|
-
* Type of selector.
|
|
21906
|
-
* @template {string} [DefaultTagName='div']
|
|
21907
|
-
* Type of default tag name (default: `'div'`).
|
|
21908
|
-
* @param {Selector | null | undefined} [selector]
|
|
21909
|
-
* Simple CSS selector (optional).
|
|
21910
|
-
*
|
|
21911
|
-
* Can contain a tag name (`foo`), classes (`.bar`), and an ID (`#baz`).
|
|
21912
|
-
* Multiple classes are allowed.
|
|
21913
|
-
* Uses the last ID if multiple IDs are found.
|
|
21914
|
-
* @param {DefaultTagName | null | undefined} [defaultTagName='div']
|
|
21915
|
-
* Tag name to use if `selector` does not specify one (default: `'div'`).
|
|
21916
|
-
* @returns {Element & {tagName: ExtractTagName<Selector, DefaultTagName>}}
|
|
21917
|
-
* Built element.
|
|
21918
|
-
*/
|
|
21919
|
-
function parseSelector(selector, defaultTagName) {
|
|
21920
|
-
const value = selector || '';
|
|
21921
|
-
/** @type {Properties} */
|
|
21922
|
-
const props = {};
|
|
21923
|
-
let start = 0;
|
|
21924
|
-
/** @type {string | undefined} */
|
|
21925
|
-
let previous;
|
|
21926
|
-
/** @type {string | undefined} */
|
|
21927
|
-
let tagName;
|
|
21928
|
-
|
|
21929
|
-
while (start < value.length) {
|
|
21930
|
-
search$1.lastIndex = start;
|
|
21931
|
-
const match = search$1.exec(value);
|
|
21932
|
-
const subvalue = value.slice(start, match ? match.index : value.length);
|
|
21933
|
-
|
|
21934
|
-
if (subvalue) {
|
|
21935
|
-
if (!previous) {
|
|
21936
|
-
tagName = subvalue;
|
|
21937
|
-
} else if (previous === '#') {
|
|
21938
|
-
props.id = subvalue;
|
|
21939
|
-
} else if (Array.isArray(props.className)) {
|
|
21940
|
-
props.className.push(subvalue);
|
|
21941
|
-
} else {
|
|
21942
|
-
props.className = [subvalue];
|
|
21943
|
-
}
|
|
21944
|
-
|
|
21945
|
-
start += subvalue.length;
|
|
21946
|
-
}
|
|
21947
|
-
|
|
21948
|
-
if (match) {
|
|
21949
|
-
previous = match[0];
|
|
21950
|
-
start++;
|
|
21951
|
-
}
|
|
21952
|
-
}
|
|
21953
|
-
|
|
21954
|
-
return {
|
|
21955
|
-
type: 'element',
|
|
21956
|
-
// @ts-expect-error: tag name is parsed.
|
|
21957
|
-
tagName: tagName || defaultTagName || 'div',
|
|
21958
|
-
properties: props,
|
|
21959
|
-
children: []
|
|
21960
|
-
}
|
|
21961
|
-
}
|
|
21962
|
-
|
|
21963
|
-
/**
|
|
21964
|
-
* Parse space-separated tokens to an array of strings.
|
|
21965
|
-
*
|
|
21966
|
-
* @param {string} value
|
|
21967
|
-
* Space-separated tokens.
|
|
21968
|
-
* @returns {Array<string>}
|
|
21969
|
-
* List of tokens.
|
|
21970
|
-
*/
|
|
21971
|
-
function parse(value) {
|
|
21972
|
-
const input = String(value || '').trim();
|
|
21973
|
-
return input ? input.split(/[ \t\n\r\f]+/g) : []
|
|
21974
|
-
}
|
|
21975
|
-
|
|
21976
21851
|
/**
|
|
21977
21852
|
* @typedef {import('hast').Element} Element
|
|
21978
21853
|
* @typedef {import('hast').Nodes} Nodes
|
|
@@ -22040,7 +21915,7 @@ function createH(schema, defaultTagName, caseSensitive) {
|
|
|
22040
21915
|
const child = /** @type {Child} */ (properties);
|
|
22041
21916
|
children.unshift(child);
|
|
22042
21917
|
} else {
|
|
22043
|
-
node = parseSelector(selector, defaultTagName);
|
|
21918
|
+
node = index$1.parseSelector(selector, defaultTagName);
|
|
22044
21919
|
// Normalize the name.
|
|
22045
21920
|
node.tagName = node.tagName.toLowerCase();
|
|
22046
21921
|
if (adjust && own$3.call(adjust, node.tagName)) {
|
|
@@ -22147,11 +22022,11 @@ function addProperty(schema, properties, key, value) {
|
|
|
22147
22022
|
// Handle list values.
|
|
22148
22023
|
else if (typeof value === 'string') {
|
|
22149
22024
|
if (info.spaceSeparated) {
|
|
22150
|
-
result = parse(value);
|
|
22025
|
+
result = index$1.parse(value);
|
|
22151
22026
|
} else if (info.commaSeparated) {
|
|
22152
|
-
result = parse$1(value);
|
|
22027
|
+
result = index$1.parse$1(value);
|
|
22153
22028
|
} else if (info.commaOrSpaceSeparated) {
|
|
22154
|
-
result = parse(parse$1(value).join(' '));
|
|
22029
|
+
result = index$1.parse(index$1.parse$1(value).join(' '));
|
|
22155
22030
|
} else {
|
|
22156
22031
|
result = parsePrimitive(info, info.property, value);
|
|
22157
22032
|
}
|
|
@@ -22468,15 +22343,6 @@ function location(file) {
|
|
|
22468
22343
|
}
|
|
22469
22344
|
}
|
|
22470
22345
|
|
|
22471
|
-
/**
|
|
22472
|
-
* Map of web namespaces.
|
|
22473
|
-
*
|
|
22474
|
-
* @type {Record<string, string>}
|
|
22475
|
-
*/
|
|
22476
|
-
const webNamespaces$1 = {
|
|
22477
|
-
html: 'http://www.w3.org/1999/xhtml',
|
|
22478
|
-
svg: 'http://www.w3.org/2000/svg'};
|
|
22479
|
-
|
|
22480
22346
|
/**
|
|
22481
22347
|
* @typedef {import('hast').Element} Element
|
|
22482
22348
|
* @typedef {import('hast').ElementData} ElementData
|
|
@@ -22633,7 +22499,7 @@ function all$2(state, nodes) {
|
|
|
22633
22499
|
function element$2(state, node) {
|
|
22634
22500
|
const schema = state.schema;
|
|
22635
22501
|
|
|
22636
|
-
state.schema = node.namespaceURI ===
|
|
22502
|
+
state.schema = node.namespaceURI === index$1.webNamespaces.svg ? svg$2 : html$2;
|
|
22637
22503
|
|
|
22638
22504
|
// Props.
|
|
22639
22505
|
let index = -1;
|
|
@@ -22767,12 +22633,12 @@ function createLocation(state, node, location) {
|
|
|
22767
22633
|
* Position or nothing.
|
|
22768
22634
|
*/
|
|
22769
22635
|
function position(loc) {
|
|
22770
|
-
const start = point
|
|
22636
|
+
const start = point({
|
|
22771
22637
|
line: loc.startLine,
|
|
22772
22638
|
column: loc.startCol,
|
|
22773
22639
|
offset: loc.startOffset
|
|
22774
22640
|
});
|
|
22775
|
-
const end = point
|
|
22641
|
+
const end = point({
|
|
22776
22642
|
line: loc.endLine,
|
|
22777
22643
|
column: loc.endCol,
|
|
22778
22644
|
offset: loc.endOffset
|
|
@@ -22791,45 +22657,10 @@ function position(loc) {
|
|
|
22791
22657
|
* @returns {Point | undefined}
|
|
22792
22658
|
* Point or nothing.
|
|
22793
22659
|
*/
|
|
22794
|
-
function point
|
|
22660
|
+
function point(point) {
|
|
22795
22661
|
return point.line && point.column ? point : undefined
|
|
22796
22662
|
}
|
|
22797
22663
|
|
|
22798
|
-
/**
|
|
22799
|
-
* @typedef Options
|
|
22800
|
-
* Configuration for `stringify`.
|
|
22801
|
-
* @property {boolean} [padLeft=true]
|
|
22802
|
-
* Whether to pad a space before a token.
|
|
22803
|
-
* @property {boolean} [padRight=false]
|
|
22804
|
-
* Whether to pad a space after a token.
|
|
22805
|
-
*/
|
|
22806
|
-
|
|
22807
|
-
|
|
22808
|
-
/**
|
|
22809
|
-
* Serialize an array of strings or numbers to comma-separated tokens.
|
|
22810
|
-
*
|
|
22811
|
-
* @param {Array<string|number>} values
|
|
22812
|
-
* List of tokens.
|
|
22813
|
-
* @param {Options} [options]
|
|
22814
|
-
* Configuration for `stringify` (optional).
|
|
22815
|
-
* @returns {string}
|
|
22816
|
-
* Comma-separated tokens.
|
|
22817
|
-
*/
|
|
22818
|
-
function stringify$1(values, options) {
|
|
22819
|
-
const settings = {};
|
|
22820
|
-
|
|
22821
|
-
// Ensure the last empty entry is seen.
|
|
22822
|
-
const input = values[values.length - 1] === '' ? [...values, ''] : values;
|
|
22823
|
-
|
|
22824
|
-
return input
|
|
22825
|
-
.join(
|
|
22826
|
-
(settings.padRight ? ' ' : '') +
|
|
22827
|
-
',' +
|
|
22828
|
-
(settings.padLeft === false ? '' : ' ')
|
|
22829
|
-
)
|
|
22830
|
-
.trim()
|
|
22831
|
-
}
|
|
22832
|
-
|
|
22833
22664
|
/**
|
|
22834
22665
|
* @typedef {import('./info.js').Info} Info
|
|
22835
22666
|
* @typedef {Record<string, Info>} Properties
|
|
@@ -24087,41 +23918,6 @@ function camelcase($0) {
|
|
|
24087
23918
|
const html = merge([xml, xlink, xmlns, aria, html$1], 'html');
|
|
24088
23919
|
const svg = merge([xml, xlink, xmlns, aria, svg$1], 'svg');
|
|
24089
23920
|
|
|
24090
|
-
/**
|
|
24091
|
-
* Parse space-separated tokens to an array of strings.
|
|
24092
|
-
*
|
|
24093
|
-
* @param {string} value
|
|
24094
|
-
* Space-separated tokens.
|
|
24095
|
-
* @returns {Array<string>}
|
|
24096
|
-
* List of tokens.
|
|
24097
|
-
*/
|
|
24098
|
-
|
|
24099
|
-
/**
|
|
24100
|
-
* Serialize an array of strings as space separated-tokens.
|
|
24101
|
-
*
|
|
24102
|
-
* @param {Array<string|number>} values
|
|
24103
|
-
* List of tokens.
|
|
24104
|
-
* @returns {string}
|
|
24105
|
-
* Space-separated tokens.
|
|
24106
|
-
*/
|
|
24107
|
-
function stringify(values) {
|
|
24108
|
-
return values.join(' ').trim()
|
|
24109
|
-
}
|
|
24110
|
-
|
|
24111
|
-
/**
|
|
24112
|
-
* Map of web namespaces.
|
|
24113
|
-
*
|
|
24114
|
-
* @type {Record<string, string>}
|
|
24115
|
-
*/
|
|
24116
|
-
const webNamespaces = {
|
|
24117
|
-
html: 'http://www.w3.org/1999/xhtml',
|
|
24118
|
-
mathml: 'http://www.w3.org/1998/Math/MathML',
|
|
24119
|
-
svg: 'http://www.w3.org/2000/svg',
|
|
24120
|
-
xlink: 'http://www.w3.org/1999/xlink',
|
|
24121
|
-
xml: 'http://www.w3.org/XML/1998/namespace',
|
|
24122
|
-
xmlns: 'http://www.w3.org/2000/xmlns/'
|
|
24123
|
-
};
|
|
24124
|
-
|
|
24125
23921
|
/**
|
|
24126
23922
|
* @typedef {import('hast').Comment} Comment
|
|
24127
23923
|
* @typedef {import('hast').Doctype} Doctype
|
|
@@ -24150,7 +23946,7 @@ const emptyOptions = {};
|
|
|
24150
23946
|
|
|
24151
23947
|
const own = {}.hasOwnProperty;
|
|
24152
23948
|
|
|
24153
|
-
const one = index$
|
|
23949
|
+
const one = index$1.zwitch('type', {handlers: {root: root$1, element: element$1, text: text$1, comment: comment$1, doctype: doctype$1}});
|
|
24154
23950
|
|
|
24155
23951
|
/**
|
|
24156
23952
|
* Transform a hast tree to a `parse5` AST.
|
|
@@ -24310,7 +24106,7 @@ function element$1(node, schema) {
|
|
|
24310
24106
|
tagName: node.tagName,
|
|
24311
24107
|
attrs,
|
|
24312
24108
|
// @ts-expect-error: `parse5` types are wrong.
|
|
24313
|
-
namespaceURI: webNamespaces[space],
|
|
24109
|
+
namespaceURI: index$1.webNamespaces[space],
|
|
24314
24110
|
childNodes: [],
|
|
24315
24111
|
parentNode: null
|
|
24316
24112
|
};
|
|
@@ -24354,7 +24150,7 @@ function createProperty(schema, prop, value) {
|
|
|
24354
24150
|
if (Array.isArray(value)) {
|
|
24355
24151
|
// Accept `array`.
|
|
24356
24152
|
// Most props are space-separated.
|
|
24357
|
-
value = info.commaSeparated ?
|
|
24153
|
+
value = info.commaSeparated ? index$1.stringify(value) : index$1.stringify$1(value);
|
|
24358
24154
|
}
|
|
24359
24155
|
|
|
24360
24156
|
/** @type {Parse5Attribute} */
|
|
@@ -24373,7 +24169,7 @@ function createProperty(schema, prop, value) {
|
|
|
24373
24169
|
attribute.prefix = info.attribute.slice(0, index);
|
|
24374
24170
|
}
|
|
24375
24171
|
|
|
24376
|
-
attribute.namespace = webNamespaces[info.space];
|
|
24172
|
+
attribute.namespace = index$1.webNamespaces[info.space];
|
|
24377
24173
|
}
|
|
24378
24174
|
|
|
24379
24175
|
return attribute
|
|
@@ -25804,13 +25600,13 @@ class Tokenizer {
|
|
|
25804
25600
|
let result = null;
|
|
25805
25601
|
let excess = 0;
|
|
25806
25602
|
let withoutSemicolon = false;
|
|
25807
|
-
for (let i = 0, current = index$
|
|
25808
|
-
i = index$
|
|
25603
|
+
for (let i = 0, current = index$1.htmlDecodeTree[0]; i >= 0; cp = this._consume()) {
|
|
25604
|
+
i = index$1.determineBranch(index$1.htmlDecodeTree, current, i + 1, cp);
|
|
25809
25605
|
if (i < 0)
|
|
25810
25606
|
break;
|
|
25811
25607
|
excess += 1;
|
|
25812
|
-
current = index$
|
|
25813
|
-
const masked = current & index$
|
|
25608
|
+
current = index$1.htmlDecodeTree[i];
|
|
25609
|
+
const masked = current & index$1.BinTrieFlags.VALUE_LENGTH;
|
|
25814
25610
|
// If the branch is a value, store it and continue
|
|
25815
25611
|
if (masked) {
|
|
25816
25612
|
// The mask is the number of bytes of the value, including the current byte.
|
|
@@ -25830,10 +25626,10 @@ class Tokenizer {
|
|
|
25830
25626
|
// If this is a surrogate pair, consume the next two bytes.
|
|
25831
25627
|
result =
|
|
25832
25628
|
valueLength === 0
|
|
25833
|
-
? [index$
|
|
25629
|
+
? [index$1.htmlDecodeTree[i] & ~index$1.BinTrieFlags.VALUE_LENGTH]
|
|
25834
25630
|
: valueLength === 1
|
|
25835
|
-
? [index$
|
|
25836
|
-
: [index$
|
|
25631
|
+
? [index$1.htmlDecodeTree[++i]]
|
|
25632
|
+
: [index$1.htmlDecodeTree[++i], index$1.htmlDecodeTree[++i]];
|
|
25837
25633
|
excess = 0;
|
|
25838
25634
|
withoutSemicolon = cp !== CODE_POINTS.SEMICOLON;
|
|
25839
25635
|
}
|
|
@@ -32295,85 +32091,6 @@ function endTagInForeignContent(p, token) {
|
|
|
32295
32091
|
}
|
|
32296
32092
|
}
|
|
32297
32093
|
|
|
32298
|
-
/**
|
|
32299
|
-
* @typedef {import('unist').Node} Node
|
|
32300
|
-
* @typedef {import('unist').Point} Point
|
|
32301
|
-
* @typedef {import('unist').Position} Position
|
|
32302
|
-
*/
|
|
32303
|
-
|
|
32304
|
-
/**
|
|
32305
|
-
* @typedef NodeLike
|
|
32306
|
-
* @property {string} type
|
|
32307
|
-
* @property {PositionLike | null | undefined} [position]
|
|
32308
|
-
*
|
|
32309
|
-
* @typedef PositionLike
|
|
32310
|
-
* @property {PointLike | null | undefined} [start]
|
|
32311
|
-
* @property {PointLike | null | undefined} [end]
|
|
32312
|
-
*
|
|
32313
|
-
* @typedef PointLike
|
|
32314
|
-
* @property {number | null | undefined} [line]
|
|
32315
|
-
* @property {number | null | undefined} [column]
|
|
32316
|
-
* @property {number | null | undefined} [offset]
|
|
32317
|
-
*/
|
|
32318
|
-
|
|
32319
|
-
/**
|
|
32320
|
-
* Get the ending point of `node`.
|
|
32321
|
-
*
|
|
32322
|
-
* @param node
|
|
32323
|
-
* Node.
|
|
32324
|
-
* @returns
|
|
32325
|
-
* Point.
|
|
32326
|
-
*/
|
|
32327
|
-
const pointEnd = point('end');
|
|
32328
|
-
|
|
32329
|
-
/**
|
|
32330
|
-
* Get the starting point of `node`.
|
|
32331
|
-
*
|
|
32332
|
-
* @param node
|
|
32333
|
-
* Node.
|
|
32334
|
-
* @returns
|
|
32335
|
-
* Point.
|
|
32336
|
-
*/
|
|
32337
|
-
const pointStart = point('start');
|
|
32338
|
-
|
|
32339
|
-
/**
|
|
32340
|
-
* Get the positional info of `node`.
|
|
32341
|
-
*
|
|
32342
|
-
* @param {'end' | 'start'} type
|
|
32343
|
-
* Side.
|
|
32344
|
-
* @returns
|
|
32345
|
-
* Getter.
|
|
32346
|
-
*/
|
|
32347
|
-
function point(type) {
|
|
32348
|
-
return point
|
|
32349
|
-
|
|
32350
|
-
/**
|
|
32351
|
-
* Get the point info of `node` at a bound side.
|
|
32352
|
-
*
|
|
32353
|
-
* @param {Node | NodeLike | null | undefined} [node]
|
|
32354
|
-
* @returns {Point | undefined}
|
|
32355
|
-
*/
|
|
32356
|
-
function point(node) {
|
|
32357
|
-
const point = (node && node.position && node.position[type]) || {};
|
|
32358
|
-
|
|
32359
|
-
if (
|
|
32360
|
-
typeof point.line === 'number' &&
|
|
32361
|
-
point.line > 0 &&
|
|
32362
|
-
typeof point.column === 'number' &&
|
|
32363
|
-
point.column > 0
|
|
32364
|
-
) {
|
|
32365
|
-
return {
|
|
32366
|
-
line: point.line,
|
|
32367
|
-
column: point.column,
|
|
32368
|
-
offset:
|
|
32369
|
-
typeof point.offset === 'number' && point.offset > -1
|
|
32370
|
-
? point.offset
|
|
32371
|
-
: undefined
|
|
32372
|
-
}
|
|
32373
|
-
}
|
|
32374
|
-
}
|
|
32375
|
-
}
|
|
32376
|
-
|
|
32377
32094
|
/**
|
|
32378
32095
|
* @typedef {import('hast').Comment} Comment
|
|
32379
32096
|
* @typedef {import('hast').Doctype} Doctype
|
|
@@ -32426,7 +32143,7 @@ const parseOptions = {sourceCodeLocationInfo: true, scriptingEnabled: false};
|
|
|
32426
32143
|
function raw(tree, options) {
|
|
32427
32144
|
const document = documentMode(tree);
|
|
32428
32145
|
/** @type {(node: Nodes, state: State) => undefined} */
|
|
32429
|
-
const one = index$
|
|
32146
|
+
const one = index$1.zwitch('type', {
|
|
32430
32147
|
handlers: {root, element, text, comment, doctype, raw: handleRaw},
|
|
32431
32148
|
unknown
|
|
32432
32149
|
});
|
|
@@ -32444,7 +32161,7 @@ function raw(tree, options) {
|
|
|
32444
32161
|
};
|
|
32445
32162
|
|
|
32446
32163
|
one(tree, state);
|
|
32447
|
-
resetTokenizer(state, pointStart());
|
|
32164
|
+
resetTokenizer(state, index$1.pointStart());
|
|
32448
32165
|
|
|
32449
32166
|
const p5 = document ? state.parser.document : state.parser.getFragment();
|
|
32450
32167
|
const result = fromParse5(p5, {
|
|
@@ -32453,7 +32170,7 @@ function raw(tree, options) {
|
|
|
32453
32170
|
});
|
|
32454
32171
|
|
|
32455
32172
|
if (state.stitches) {
|
|
32456
|
-
index$
|
|
32173
|
+
index$1.visit(result, 'comment', function (node, index, parent) {
|
|
32457
32174
|
const stitch = /** @type {Stitch} */ (/** @type {unknown} */ (node));
|
|
32458
32175
|
if (stitch.value.stitch && parent && index !== undefined) {
|
|
32459
32176
|
/** @type {Array<RootContent>} */
|
|
@@ -32557,7 +32274,7 @@ function text(node, state) {
|
|
|
32557
32274
|
location: createParse5Location(node)
|
|
32558
32275
|
};
|
|
32559
32276
|
|
|
32560
|
-
resetTokenizer(state, pointStart(node));
|
|
32277
|
+
resetTokenizer(state, index$1.pointStart(node));
|
|
32561
32278
|
// @ts-expect-error: private.
|
|
32562
32279
|
// type-coverage:ignore-next-line
|
|
32563
32280
|
state.parser.currentToken = token;
|
|
@@ -32587,7 +32304,7 @@ function doctype(node, state) {
|
|
|
32587
32304
|
location: createParse5Location(node)
|
|
32588
32305
|
};
|
|
32589
32306
|
|
|
32590
|
-
resetTokenizer(state, pointStart(node));
|
|
32307
|
+
resetTokenizer(state, index$1.pointStart(node));
|
|
32591
32308
|
// @ts-expect-error: private.
|
|
32592
32309
|
// type-coverage:ignore-next-line
|
|
32593
32310
|
state.parser.currentToken = token;
|
|
@@ -32650,7 +32367,7 @@ function comment(node, state) {
|
|
|
32650
32367
|
data,
|
|
32651
32368
|
location: createParse5Location(node)
|
|
32652
32369
|
};
|
|
32653
|
-
resetTokenizer(state, pointStart(node));
|
|
32370
|
+
resetTokenizer(state, index$1.pointStart(node));
|
|
32654
32371
|
// @ts-expect-error: private.
|
|
32655
32372
|
// type-coverage:ignore-next-line
|
|
32656
32373
|
state.parser.currentToken = token;
|
|
@@ -32694,7 +32411,7 @@ function handleRaw(node, state) {
|
|
|
32694
32411
|
state.parser.tokenizer.preprocessor.isEol = false;
|
|
32695
32412
|
|
|
32696
32413
|
// Now pass `node.value`.
|
|
32697
|
-
setPoint(state, pointStart(node));
|
|
32414
|
+
setPoint(state, index$1.pointStart(node));
|
|
32698
32415
|
state.parser.tokenizer.write(node.value, false);
|
|
32699
32416
|
// @ts-expect-error: private.
|
|
32700
32417
|
// type-coverage:ignore-next-line
|
|
@@ -32877,19 +32594,19 @@ function startTag(node, state) {
|
|
|
32877
32594
|
// Ignore tags if we’re in plain text.
|
|
32878
32595
|
if (state.parser.tokenizer.state === TokenizerMode.PLAINTEXT) return
|
|
32879
32596
|
|
|
32880
|
-
resetTokenizer(state, pointStart(node));
|
|
32597
|
+
resetTokenizer(state, index$1.pointStart(node));
|
|
32881
32598
|
|
|
32882
32599
|
const current = state.parser.openElements.current;
|
|
32883
|
-
let ns = 'namespaceURI' in current ? current.namespaceURI :
|
|
32600
|
+
let ns = 'namespaceURI' in current ? current.namespaceURI : index$1.webNamespaces.html;
|
|
32884
32601
|
|
|
32885
|
-
if (ns ===
|
|
32886
|
-
ns =
|
|
32602
|
+
if (ns === index$1.webNamespaces.html && tagName === 'svg') {
|
|
32603
|
+
ns = index$1.webNamespaces.svg;
|
|
32887
32604
|
}
|
|
32888
32605
|
|
|
32889
32606
|
const result = toParse5(
|
|
32890
32607
|
// Shallow clone to not delve into `children`: we only need the attributes.
|
|
32891
32608
|
{...node, children: []},
|
|
32892
|
-
{space: ns ===
|
|
32609
|
+
{space: ns === index$1.webNamespaces.svg ? 'svg' : 'html'}
|
|
32893
32610
|
);
|
|
32894
32611
|
|
|
32895
32612
|
/** @type {TagToken} */
|
|
@@ -32950,7 +32667,7 @@ function endTag(node, state) {
|
|
|
32950
32667
|
// Ignore tags if we’re in plain text.
|
|
32951
32668
|
if (state.parser.tokenizer.state === TokenizerMode.PLAINTEXT) return
|
|
32952
32669
|
|
|
32953
|
-
resetTokenizer(state, pointEnd(node));
|
|
32670
|
+
resetTokenizer(state, index$1.pointEnd(node));
|
|
32954
32671
|
|
|
32955
32672
|
/** @type {TagToken} */
|
|
32956
32673
|
const tag = {
|
|
@@ -33020,12 +32737,12 @@ function documentMode(node) {
|
|
|
33020
32737
|
* `parse5` location.
|
|
33021
32738
|
*/
|
|
33022
32739
|
function createParse5Location(node) {
|
|
33023
|
-
const start = pointStart(node) || {
|
|
32740
|
+
const start = index$1.pointStart(node) || {
|
|
33024
32741
|
line: undefined,
|
|
33025
32742
|
column: undefined,
|
|
33026
32743
|
offset: undefined
|
|
33027
32744
|
};
|
|
33028
|
-
const end = pointEnd(node) || {
|
|
32745
|
+
const end = index$1.pointEnd(node) || {
|
|
33029
32746
|
line: undefined,
|
|
33030
32747
|
column: undefined,
|
|
33031
32748
|
offset: undefined
|
|
@@ -33056,8 +32773,8 @@ function createParse5Location(node) {
|
|
|
33056
32773
|
*/
|
|
33057
32774
|
function cloneWithoutChildren(node) {
|
|
33058
32775
|
return 'children' in node
|
|
33059
|
-
? index$
|
|
33060
|
-
: index$
|
|
32776
|
+
? index$1.structuredClone({...node, children: []})
|
|
32777
|
+
: index$1.structuredClone(node)
|
|
33061
32778
|
}
|
|
33062
32779
|
|
|
33063
32780
|
/**
|
|
@@ -33856,7 +33573,7 @@ function createLazyLoadImagesPlugin(lazyLoadImages = false) {
|
|
|
33856
33573
|
return (tree) => tree;
|
|
33857
33574
|
}
|
|
33858
33575
|
return (tree) => {
|
|
33859
|
-
index$
|
|
33576
|
+
index$1.visit(tree, 'element', (node) => {
|
|
33860
33577
|
if (node.tagName === 'img') {
|
|
33861
33578
|
node.properties = node.properties || {};
|
|
33862
33579
|
node.properties.loading = 'lazy';
|
|
@@ -33880,7 +33597,7 @@ function createLazyLoadImagesPlugin(lazyLoadImages = false) {
|
|
|
33880
33597
|
function createLinksPlugin() {
|
|
33881
33598
|
return () => {
|
|
33882
33599
|
return (tree) => {
|
|
33883
|
-
index$
|
|
33600
|
+
index$1.visit(tree, 'element', (node) => {
|
|
33884
33601
|
var _a, _b;
|
|
33885
33602
|
if (node.tagName === 'a') {
|
|
33886
33603
|
const href = (_a = node.properties) === null || _a === void 0 ? void 0 : _a.href;
|
|
@@ -34030,26 +33747,24 @@ const isWhitespace = (value) => {
|
|
|
34030
33747
|
*/
|
|
34031
33748
|
async function markdownToHTML(text, options) {
|
|
34032
33749
|
var _a;
|
|
34033
|
-
|
|
34034
|
-
text = text.replaceAll(/(?<!\\)([\n\r])/g, ' $1');
|
|
34035
|
-
}
|
|
34036
|
-
const file = await index$2.unified()
|
|
33750
|
+
const file = await index$1.unified()
|
|
34037
33751
|
.use(remarkParse)
|
|
34038
33752
|
.use(remarkGfm)
|
|
33753
|
+
.use((options === null || options === void 0 ? void 0 : options.forceHardLineBreaks) ? [remarkBreaks] : [])
|
|
34039
33754
|
.use(remarkRehype, { allowDangerousHtml: true })
|
|
34040
33755
|
.use(rehypeRaw)
|
|
34041
33756
|
.use(createLinksPlugin())
|
|
34042
|
-
.use(index$
|
|
33757
|
+
.use(index$1.rehypeSanitize, getWhiteList((_a = options === null || options === void 0 ? void 0 : options.whitelist) !== null && _a !== void 0 ? _a : []))
|
|
34043
33758
|
.use(() => {
|
|
34044
33759
|
return (tree) => {
|
|
34045
33760
|
// Run the sanitizeStyle function on all elements, to sanitize
|
|
34046
33761
|
// the value of the `style` attribute, if there is one.
|
|
34047
|
-
index$
|
|
33762
|
+
index$1.visit(tree, 'element', sanitizeStyle);
|
|
34048
33763
|
};
|
|
34049
33764
|
})
|
|
34050
33765
|
.use(createRemoveEmptyParagraphsPlugin(options === null || options === void 0 ? void 0 : options.removeEmptyParagraphs))
|
|
34051
33766
|
.use(createLazyLoadImagesPlugin(options === null || options === void 0 ? void 0 : options.lazyLoadImages))
|
|
34052
|
-
.use(index$
|
|
33767
|
+
.use(index$1.rehypeStringify)
|
|
34053
33768
|
.process(text);
|
|
34054
33769
|
return file.toString();
|
|
34055
33770
|
}
|
|
@@ -34061,28 +33776,28 @@ async function markdownToHTML(text, options) {
|
|
|
34061
33776
|
* @returns The sanitized HTML string.
|
|
34062
33777
|
*/
|
|
34063
33778
|
async function sanitizeHTML(html, whitelist) {
|
|
34064
|
-
const file = await index$
|
|
34065
|
-
.use(index$
|
|
34066
|
-
.use(index$
|
|
33779
|
+
const file = await index$1.unified()
|
|
33780
|
+
.use(index$1.rehypeParse)
|
|
33781
|
+
.use(index$1.rehypeSanitize, getWhiteList(whitelist !== null && whitelist !== void 0 ? whitelist : []))
|
|
34067
33782
|
.use(() => {
|
|
34068
33783
|
return (tree) => {
|
|
34069
33784
|
// Run the sanitizeStyle function on all elements, to sanitize
|
|
34070
33785
|
// the value of the `style` attribute, if there is one.
|
|
34071
|
-
index$
|
|
33786
|
+
index$1.visit(tree, 'element', sanitizeStyle);
|
|
34072
33787
|
};
|
|
34073
33788
|
})
|
|
34074
|
-
.use(index$
|
|
33789
|
+
.use(index$1.rehypeStringify)
|
|
34075
33790
|
.process(html);
|
|
34076
33791
|
return file.toString();
|
|
34077
33792
|
}
|
|
34078
33793
|
function getWhiteList(allowedComponents) {
|
|
34079
33794
|
var _a, _b, _c, _d;
|
|
34080
|
-
const defaultSchemaClone = [...((_a = index$
|
|
33795
|
+
const defaultSchemaClone = [...((_a = index$1.defaultSchema.attributes['*']) !== null && _a !== void 0 ? _a : [])];
|
|
34081
33796
|
const asteriskAttributeWhitelist = defaultSchemaClone.filter((attr) => {
|
|
34082
33797
|
return attr !== 'height';
|
|
34083
33798
|
});
|
|
34084
33799
|
asteriskAttributeWhitelist.push('style');
|
|
34085
|
-
const whitelist = Object.assign(Object.assign({}, index$
|
|
33800
|
+
const whitelist = Object.assign(Object.assign({}, index$1.defaultSchema), {
|
|
34086
33801
|
// Disable rehype-sanitize's default `user-content-` prefix, which it
|
|
34087
33802
|
// otherwise prepends to the DOM-clobber attributes (`id`, `name`,
|
|
34088
33803
|
// `aria-describedby`, `aria-labelledby`).
|
|
@@ -34108,18 +33823,18 @@ function getWhiteList(allowedComponents) {
|
|
|
34108
33823
|
// output into the light DOM — or these functions become public exports
|
|
34109
33824
|
// — reinstate the prefix or scope its removal to whitelisted custom
|
|
34110
33825
|
// elements only.
|
|
34111
|
-
clobberPrefix: '', strip: [...((_b = index$
|
|
34112
|
-
...(index$
|
|
33826
|
+
clobberPrefix: '', strip: [...((_b = index$1.defaultSchema.strip) !== null && _b !== void 0 ? _b : []), 'style'], tagNames: [
|
|
33827
|
+
...(index$1.defaultSchema.tagNames || []),
|
|
34113
33828
|
// Table column definitions carry the column widths for tables
|
|
34114
33829
|
// from sources like Google Sheets, where the table element
|
|
34115
33830
|
// itself has no usable width.
|
|
34116
33831
|
'colgroup',
|
|
34117
33832
|
'col',
|
|
34118
33833
|
...allowedComponents.map((component) => component.tagName),
|
|
34119
|
-
], attributes: Object.assign(Object.assign({}, index$
|
|
34120
|
-
...((_c = index$
|
|
33834
|
+
], attributes: Object.assign(Object.assign({}, index$1.defaultSchema.attributes), { p: [
|
|
33835
|
+
...((_c = index$1.defaultSchema.attributes.p) !== null && _c !== void 0 ? _c : []),
|
|
34121
33836
|
['className', 'MsoNormal'],
|
|
34122
|
-
], a: [...((_d = index$
|
|
33837
|
+
], a: [...((_d = index$1.defaultSchema.attributes.a) !== null && _d !== void 0 ? _d : []), 'referrerpolicy'], '*': asteriskAttributeWhitelist })
|
|
34123
33838
|
});
|
|
34124
33839
|
for (const component of allowedComponents) {
|
|
34125
33840
|
whitelist.attributes[component.tagName] = component.attributes;
|
|
@@ -34127,6 +33842,22 @@ function getWhiteList(allowedComponents) {
|
|
|
34127
33842
|
return whitelist;
|
|
34128
33843
|
}
|
|
34129
33844
|
|
|
33845
|
+
exports.asciiAlpha = asciiAlpha;
|
|
33846
|
+
exports.asciiAlphanumeric = asciiAlphanumeric;
|
|
33847
|
+
exports.asciiPunctuation = asciiPunctuation;
|
|
33848
|
+
exports.classifyCharacter = classifyCharacter;
|
|
33849
|
+
exports.decodeString = decodeString;
|
|
33850
|
+
exports.encodeCharacterReference = encodeCharacterReference;
|
|
33851
|
+
exports.formatCodeAsIndented = formatCodeAsIndented;
|
|
33852
|
+
exports.formatHeadingAsSetext = formatHeadingAsSetext;
|
|
34130
33853
|
exports.getLinkAttributes = getLinkAttributes;
|
|
33854
|
+
exports.handle = handle;
|
|
33855
|
+
exports.htmlBlockNames = htmlBlockNames;
|
|
33856
|
+
exports.htmlRawNames = htmlRawNames;
|
|
34131
33857
|
exports.markdownToHTML = markdownToHTML;
|
|
33858
|
+
exports.patternInScope = patternInScope;
|
|
33859
|
+
exports.phrasing = phrasing;
|
|
33860
|
+
exports.remarkGfm = remarkGfm;
|
|
33861
|
+
exports.remarkParse = remarkParse;
|
|
34132
33862
|
exports.sanitizeHTML = sanitizeHTML;
|
|
33863
|
+
exports.toString = toString;
|