@readme/markdown 14.11.2 → 14.11.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/Tabs/index.tsx +9 -2
- package/dist/lib/mdast-util/html-block-component/index.d.ts +2 -0
- package/dist/lib/micromark/html-block-component/index.d.ts +1 -0
- package/dist/lib/micromark/html-block-component/syntax.d.ts +8 -0
- package/dist/main.js +850 -153
- package/dist/main.node.js +850 -153
- package/dist/main.node.js.map +1 -1
- package/dist/processor/transform/mdxish/react-element-to-hast.d.ts +8 -0
- package/dist/processor/transform/mdxish/tables/escape-crossing-emphasis.d.ts +15 -0
- package/dist/processor/transform/mdxish/tables/escape-stray-less-than.d.ts +9 -0
- package/dist/processor/transform/mdxish/tables/remap-positions.d.ts +3 -5
- package/dist/processor/transform/mdxish/tables/split-nested-tables.d.ts +11 -0
- package/dist/processor/utils.d.ts +7 -0
- package/dist/render-fixture.node.js +1031 -334
- package/dist/render-fixture.node.js.map +1 -1
- package/package.json +1 -1
|
@@ -68490,6 +68490,21 @@ function evaluate(source, scope = {}) {
|
|
|
68490
68490
|
// eslint-disable-next-line no-new-func
|
|
68491
68491
|
return new Function(...names, `return (${source})`)(...values);
|
|
68492
68492
|
}
|
|
68493
|
+
/**
|
|
68494
|
+
* Advance a `Point` by the `consumed` substring that follows it, returning the
|
|
68495
|
+
* point at the consumed string's end. Lets split-out sub-nodes carry accurate
|
|
68496
|
+
* document positions so downstream offset shifting stays correct.
|
|
68497
|
+
*/
|
|
68498
|
+
const pointAfter = (start, consumed) => {
|
|
68499
|
+
const newlineIndex = consumed.lastIndexOf('\n');
|
|
68500
|
+
const newlineCount = newlineIndex === -1 ? 0 : consumed.split('\n').length - 1;
|
|
68501
|
+
return {
|
|
68502
|
+
line: start.line + newlineCount,
|
|
68503
|
+
// Same line → advance the base column; a later line → column is the run since its newline.
|
|
68504
|
+
column: newlineCount === 0 ? start.column + consumed.length : consumed.length - newlineIndex,
|
|
68505
|
+
offset: (start.offset ?? 0) + consumed.length,
|
|
68506
|
+
};
|
|
68507
|
+
};
|
|
68493
68508
|
/**
|
|
68494
68509
|
* Formats the hProperties of a node as a string, so they can be compiled back into JSX/MDX.
|
|
68495
68510
|
* This currently sets all the values to a string since we process/compile the MDX on the fly
|
|
@@ -92168,10 +92183,10 @@ const Tabs = ({ children }) => {
|
|
|
92168
92183
|
const tabs = external_react_default().Children.toArray(children);
|
|
92169
92184
|
return (external_react_default().createElement("div", { className: "TabGroup" },
|
|
92170
92185
|
external_react_default().createElement("header", null,
|
|
92171
|
-
external_react_default().createElement("nav", { className: "TabGroup-nav" }, tabs.map((tab, index) => (external_react_default().createElement("button", { key: tab.
|
|
92186
|
+
external_react_default().createElement("nav", { className: "TabGroup-nav" }, tabs.map((tab, index) => (external_react_default().createElement("button", { key: tab.key, className: `TabGroup-tab${activeTab === index ? '_active' : ''}`, onClick: () => setActiveTab(index) },
|
|
92172
92187
|
tab.props.icon && (external_react_default().createElement(components_Icon, { className: "TabGroup-icon", icon: tab.props.icon, iconColor: tab.props.iconColor })),
|
|
92173
92188
|
tab.props.title))))),
|
|
92174
|
-
external_react_default().createElement("section", null, tabs
|
|
92189
|
+
external_react_default().createElement("section", null, tabs.map((tab, index) => (external_react_default().createElement("div", { key: tab.key, hidden: index !== activeTab }, tab))))));
|
|
92175
92190
|
};
|
|
92176
92191
|
/* harmony default export */ const components_Tabs = (Tabs);
|
|
92177
92192
|
|
|
@@ -92840,7 +92855,7 @@ function legacyVariableFromMarkdown() {
|
|
|
92840
92855
|
*
|
|
92841
92856
|
* Unicode basic latin block.
|
|
92842
92857
|
*/
|
|
92843
|
-
const
|
|
92858
|
+
const codes_codes = /** @type {const} */ ({
|
|
92844
92859
|
carriageReturn: -5,
|
|
92845
92860
|
lineFeed: -4,
|
|
92846
92861
|
carriageReturnLineFeed: -3,
|
|
@@ -92988,11 +93003,11 @@ const codes = /** @type {const} */ ({
|
|
|
92988
93003
|
function isNameChar(code) {
|
|
92989
93004
|
if (code === null)
|
|
92990
93005
|
return false;
|
|
92991
|
-
return ((code >=
|
|
92992
|
-
(code >=
|
|
92993
|
-
(code >=
|
|
92994
|
-
code ===
|
|
92995
|
-
code ===
|
|
93006
|
+
return ((code >= codes_codes.lowercaseA && code <= codes_codes.lowercaseZ) ||
|
|
93007
|
+
(code >= codes_codes.uppercaseA && code <= codes_codes.uppercaseZ) ||
|
|
93008
|
+
(code >= codes_codes.digit0 && code <= codes_codes.digit9) ||
|
|
93009
|
+
code === codes_codes.dash ||
|
|
93010
|
+
code === codes_codes.underscore);
|
|
92996
93011
|
}
|
|
92997
93012
|
const gemojiConstruct = {
|
|
92998
93013
|
name: 'gemoji',
|
|
@@ -93002,7 +93017,7 @@ function tokenize(effects, ok, nok) {
|
|
|
93002
93017
|
let hasName = false;
|
|
93003
93018
|
// Entry point — expect opening `:`
|
|
93004
93019
|
const start = (code) => {
|
|
93005
|
-
if (code !==
|
|
93020
|
+
if (code !== codes_codes.colon)
|
|
93006
93021
|
return nok(code);
|
|
93007
93022
|
effects.enter('gemoji');
|
|
93008
93023
|
effects.enter('gemojiMarker');
|
|
@@ -93013,7 +93028,7 @@ function tokenize(effects, ok, nok) {
|
|
|
93013
93028
|
};
|
|
93014
93029
|
// First char after `:`, branch on `+` for :+1:, otherwise start normal name
|
|
93015
93030
|
const nameStart = (code) => {
|
|
93016
|
-
if (code ===
|
|
93031
|
+
if (code === codes_codes.plusSign) {
|
|
93017
93032
|
effects.consume(code); // +
|
|
93018
93033
|
return plusOne;
|
|
93019
93034
|
}
|
|
@@ -93028,7 +93043,7 @@ function tokenize(effects, ok, nok) {
|
|
|
93028
93043
|
// After `+`, only `1` is valid (for :+1:), anything else rejects
|
|
93029
93044
|
// this is a special case for :+1: 👍 since + isnt a normal name character
|
|
93030
93045
|
const plusOne = (code) => {
|
|
93031
|
-
if (code ===
|
|
93046
|
+
if (code === codes_codes.digit1) {
|
|
93032
93047
|
hasName = true;
|
|
93033
93048
|
effects.consume(code); // 1
|
|
93034
93049
|
return nameEnd;
|
|
@@ -93037,7 +93052,7 @@ function tokenize(effects, ok, nok) {
|
|
|
93037
93052
|
};
|
|
93038
93053
|
// Consume name characters until we hit closing `:` or an invalid char
|
|
93039
93054
|
const name = (code) => {
|
|
93040
|
-
if (code ===
|
|
93055
|
+
if (code === codes_codes.colon) {
|
|
93041
93056
|
if (!hasName)
|
|
93042
93057
|
return nok(code);
|
|
93043
93058
|
return nameEnd(code);
|
|
@@ -93051,7 +93066,7 @@ function tokenize(effects, ok, nok) {
|
|
|
93051
93066
|
};
|
|
93052
93067
|
// Expect closing `:`
|
|
93053
93068
|
const nameEnd = (code) => {
|
|
93054
|
-
if (code !==
|
|
93069
|
+
if (code !== codes_codes.colon)
|
|
93055
93070
|
return nok(code);
|
|
93056
93071
|
effects.exit('gemojiName');
|
|
93057
93072
|
effects.enter('gemojiMarker');
|
|
@@ -93064,7 +93079,7 @@ function tokenize(effects, ok, nok) {
|
|
|
93064
93079
|
}
|
|
93065
93080
|
function syntax_gemoji() {
|
|
93066
93081
|
return {
|
|
93067
|
-
text: { [
|
|
93082
|
+
text: { [codes_codes.colon]: gemojiConstruct },
|
|
93068
93083
|
};
|
|
93069
93084
|
}
|
|
93070
93085
|
|
|
@@ -93079,8 +93094,8 @@ function syntax_gemoji() {
|
|
|
93079
93094
|
|
|
93080
93095
|
function isAllowedValueChar(code) {
|
|
93081
93096
|
return (code !== null &&
|
|
93082
|
-
code !==
|
|
93083
|
-
code !==
|
|
93097
|
+
code !== codes_codes.lessThan &&
|
|
93098
|
+
code !== codes_codes.greaterThan &&
|
|
93084
93099
|
!markdownLineEnding(code));
|
|
93085
93100
|
}
|
|
93086
93101
|
const legacyVariableConstruct = {
|
|
@@ -93090,7 +93105,7 @@ const legacyVariableConstruct = {
|
|
|
93090
93105
|
function syntax_tokenize(effects, ok, nok) {
|
|
93091
93106
|
let hasValue = false;
|
|
93092
93107
|
const start = (code) => {
|
|
93093
|
-
if (code !==
|
|
93108
|
+
if (code !== codes_codes.lessThan)
|
|
93094
93109
|
return nok(code);
|
|
93095
93110
|
effects.enter('legacyVariable');
|
|
93096
93111
|
effects.enter('legacyVariableMarkerStart');
|
|
@@ -93098,7 +93113,7 @@ function syntax_tokenize(effects, ok, nok) {
|
|
|
93098
93113
|
return open2;
|
|
93099
93114
|
};
|
|
93100
93115
|
const open2 = (code) => {
|
|
93101
|
-
if (code !==
|
|
93116
|
+
if (code !== codes_codes.lessThan)
|
|
93102
93117
|
return nok(code);
|
|
93103
93118
|
effects.consume(code); // <<
|
|
93104
93119
|
effects.exit('legacyVariableMarkerStart');
|
|
@@ -93106,7 +93121,7 @@ function syntax_tokenize(effects, ok, nok) {
|
|
|
93106
93121
|
return value;
|
|
93107
93122
|
};
|
|
93108
93123
|
const value = (code) => {
|
|
93109
|
-
if (code ===
|
|
93124
|
+
if (code === codes_codes.greaterThan) {
|
|
93110
93125
|
if (!hasValue)
|
|
93111
93126
|
return nok(code);
|
|
93112
93127
|
effects.exit('legacyVariableValue');
|
|
@@ -93121,7 +93136,7 @@ function syntax_tokenize(effects, ok, nok) {
|
|
|
93121
93136
|
return value;
|
|
93122
93137
|
};
|
|
93123
93138
|
const close2 = (code) => {
|
|
93124
|
-
if (code !==
|
|
93139
|
+
if (code !== codes_codes.greaterThan)
|
|
93125
93140
|
return nok(code);
|
|
93126
93141
|
effects.consume(code); // >>
|
|
93127
93142
|
effects.exit('legacyVariableMarkerEnd');
|
|
@@ -93132,7 +93147,7 @@ function syntax_tokenize(effects, ok, nok) {
|
|
|
93132
93147
|
}
|
|
93133
93148
|
function legacyVariable() {
|
|
93134
93149
|
return {
|
|
93135
|
-
text: { [
|
|
93150
|
+
text: { [codes_codes.lessThan]: legacyVariableConstruct },
|
|
93136
93151
|
};
|
|
93137
93152
|
}
|
|
93138
93153
|
|
|
@@ -95970,6 +95985,134 @@ const applyInserts = (html, inserts) => {
|
|
|
95970
95985
|
return { value: out + html.slice(cursor), inserts: sorted };
|
|
95971
95986
|
};
|
|
95972
95987
|
|
|
95988
|
+
;// ./processor/transform/mdxish/tables/escape-crossing-emphasis.ts
|
|
95989
|
+
|
|
95990
|
+
|
|
95991
|
+
|
|
95992
|
+
// Maximal run of a single emphasis delimiter (`_`, `*`, `**`, `***`, …).
|
|
95993
|
+
const EMPHASIS_RUN_RE = /([*_])\1*/g;
|
|
95994
|
+
// String bounds (undefined) count as whitespace, not punctuation, per the
|
|
95995
|
+
// CommonMark flanking definition.
|
|
95996
|
+
const escape_crossing_emphasis_isWhitespace = (ch) => ch === undefined || unicodeWhitespace(ch.charCodeAt(0));
|
|
95997
|
+
const isPunctuation = (ch) => ch !== undefined && unicodePunctuation(ch.charCodeAt(0));
|
|
95998
|
+
/**
|
|
95999
|
+
* Whether a delimiter run can open and/or close emphasis, per CommonMark's
|
|
96000
|
+
* left/right-flanking rules. The extra `_` conditions forbid intraword
|
|
96001
|
+
* emphasis, which keeps `snake_case` from being treated as a delimiter.
|
|
96002
|
+
*/
|
|
96003
|
+
const analyzeFlanking = (source, char, start, end) => {
|
|
96004
|
+
const before = source[start - 1];
|
|
96005
|
+
const after = source[end];
|
|
96006
|
+
const leftFlanking = !escape_crossing_emphasis_isWhitespace(after) && (!isPunctuation(after) || escape_crossing_emphasis_isWhitespace(before) || isPunctuation(before));
|
|
96007
|
+
const rightFlanking = !escape_crossing_emphasis_isWhitespace(before) && (!isPunctuation(before) || escape_crossing_emphasis_isWhitespace(after) || isPunctuation(after));
|
|
96008
|
+
if (char === '_') {
|
|
96009
|
+
return {
|
|
96010
|
+
canOpen: leftFlanking && (!rightFlanking || isPunctuation(before)),
|
|
96011
|
+
canClose: rightFlanking && (!leftFlanking || isPunctuation(after)),
|
|
96012
|
+
};
|
|
96013
|
+
}
|
|
96014
|
+
return { canOpen: leftFlanking, canClose: rightFlanking };
|
|
96015
|
+
};
|
|
96016
|
+
/**
|
|
96017
|
+
* Collect HTML tag boundaries (via htmlparser2) and emphasis delimiter runs
|
|
96018
|
+
* (via regex over the masked source, so code spans and escaped `<` are skipped)
|
|
96019
|
+
* into one list ordered by position. At a shared offset a tag opener sorts
|
|
96020
|
+
* before a closer, so a self-closing tag brackets rather than swallows a run.
|
|
96021
|
+
*/
|
|
96022
|
+
const collectEvents = (html) => {
|
|
96023
|
+
const masked = maskNonTagRegions(html);
|
|
96024
|
+
const events = [];
|
|
96025
|
+
walkTags(html, {
|
|
96026
|
+
onOpen: ({ start }) => events.push({ kind: 'tagOpen', offset: start }),
|
|
96027
|
+
onClose: ({ start }) => events.push({ kind: 'tagClose', offset: start }),
|
|
96028
|
+
});
|
|
96029
|
+
EMPHASIS_RUN_RE.lastIndex = 0;
|
|
96030
|
+
let match;
|
|
96031
|
+
while ((match = EMPHASIS_RUN_RE.exec(masked)) !== null) {
|
|
96032
|
+
const [run, char] = match;
|
|
96033
|
+
const start = match.index;
|
|
96034
|
+
// eslint-disable-next-line no-continue
|
|
96035
|
+
if (html[start - 1] === '\\')
|
|
96036
|
+
continue; // already escaped
|
|
96037
|
+
events.push({ kind: 'emphasis', offset: start, char, length: run.length, flanking: analyzeFlanking(html, char, start, start + run.length) });
|
|
96038
|
+
}
|
|
96039
|
+
return events.sort((a, b) => a.offset - b.offset || (a.kind === 'tagClose' ? 1 : 0) - (b.kind === 'tagClose' ? 1 : 0));
|
|
96040
|
+
};
|
|
96041
|
+
/**
|
|
96042
|
+
* mdxjs rejects a table when a markdown emphasis run opens at one HTML
|
|
96043
|
+
* tag-nesting depth and closes at another — e.g. `_<ul><li>text_</li></ul>`,
|
|
96044
|
+
* where the `_` opens outside the list but closes inside a `<li>`. It throws
|
|
96045
|
+
* "Expected a closing tag for `<li>` before the end of `emphasis`" and the
|
|
96046
|
+
* whole `<Table>` fails to parse.
|
|
96047
|
+
*
|
|
96048
|
+
* We walk tags and emphasis together, tracking tag depth and a stack of open
|
|
96049
|
+
* emphasis. A delimiter only closes an opener at the same depth; any emphasis
|
|
96050
|
+
* still open when its enclosing tag closes (or at end of input), and any closer
|
|
96051
|
+
* with no same-depth opener, is escaped so mdxjs treats it as literal text.
|
|
96052
|
+
* Scoped to the malformed-retry path.
|
|
96053
|
+
*/
|
|
96054
|
+
const escapeCrossingEmphasis = (html) => {
|
|
96055
|
+
const open = [];
|
|
96056
|
+
const orphans = [];
|
|
96057
|
+
let depth = 0;
|
|
96058
|
+
collectEvents(html).forEach(event => {
|
|
96059
|
+
if (event.kind === 'tagOpen') {
|
|
96060
|
+
depth += 1;
|
|
96061
|
+
return;
|
|
96062
|
+
}
|
|
96063
|
+
if (event.kind === 'tagClose') {
|
|
96064
|
+
depth -= 1;
|
|
96065
|
+
// Emphasis opened deeper than the surviving depth was inside the tag that
|
|
96066
|
+
// just closed, so it crosses the boundary.
|
|
96067
|
+
while (open.length > 0 && open[open.length - 1].depth > depth) {
|
|
96068
|
+
const crossed = open.pop();
|
|
96069
|
+
if (crossed)
|
|
96070
|
+
orphans.push(crossed);
|
|
96071
|
+
}
|
|
96072
|
+
return;
|
|
96073
|
+
}
|
|
96074
|
+
const top = open[open.length - 1];
|
|
96075
|
+
if (event.flanking.canClose && top?.char === event.char && top.depth === depth) {
|
|
96076
|
+
open.pop();
|
|
96077
|
+
}
|
|
96078
|
+
else if (event.flanking.canOpen) {
|
|
96079
|
+
open.push({ char: event.char, depth, offset: event.offset, length: event.length });
|
|
96080
|
+
}
|
|
96081
|
+
else if (event.flanking.canClose) {
|
|
96082
|
+
orphans.push({ offset: event.offset, length: event.length });
|
|
96083
|
+
}
|
|
96084
|
+
});
|
|
96085
|
+
orphans.push(...open); // anything still open never closed
|
|
96086
|
+
const inserts = orphans.flatMap(({ offset, length }) => Array.from({ length }, (_unused, i) => ({ offset: offset + i, text: '\\' })));
|
|
96087
|
+
return applyInserts(html, inserts);
|
|
96088
|
+
};
|
|
96089
|
+
|
|
96090
|
+
;// ./processor/transform/mdxish/tables/escape-stray-less-than.ts
|
|
96091
|
+
|
|
96092
|
+
|
|
96093
|
+
// A `<` only starts a JSX/HTML construct when followed by a tag-name start
|
|
96094
|
+
// (letter, `_`, `$`), a closer `/`, a fragment `>`, or a comment/declaration
|
|
96095
|
+
// `!`. Anything else (whitespace, EOL, a digit, …) is a literal `<` that acorn
|
|
96096
|
+
// rejects with "before name, expected a character that can start a name".
|
|
96097
|
+
const STRAY_LESS_THAN_RE = /<(?![a-zA-Z_$/>!])/g;
|
|
96098
|
+
/**
|
|
96099
|
+
* Escapes stray `<` characters that don't begin a valid tag so the strict mdxjs
|
|
96100
|
+
* parse treats them as literal text instead of throwing (`word <`, `a <1>`).
|
|
96101
|
+
*
|
|
96102
|
+
* Runs against the masked source so `<` inside code spans, legacy `<<var>>`
|
|
96103
|
+
* syntax, or already-escaped `\<` are left untouched.
|
|
96104
|
+
*/
|
|
96105
|
+
const escapeStrayLessThan = (html) => {
|
|
96106
|
+
const masked = maskNonTagRegions(html);
|
|
96107
|
+
const inserts = [];
|
|
96108
|
+
STRAY_LESS_THAN_RE.lastIndex = 0;
|
|
96109
|
+
let match;
|
|
96110
|
+
while ((match = STRAY_LESS_THAN_RE.exec(masked)) !== null) {
|
|
96111
|
+
inserts.push({ offset: match.index, text: '\\' });
|
|
96112
|
+
}
|
|
96113
|
+
return applyInserts(html, inserts);
|
|
96114
|
+
};
|
|
96115
|
+
|
|
95973
96116
|
;// ./processor/transform/mdxish/tables/normalize-tag-spacing.ts
|
|
95974
96117
|
|
|
95975
96118
|
|
|
@@ -96096,6 +96239,21 @@ const buildOffsetMapper = (inserts) => {
|
|
|
96096
96239
|
return repaired - shift;
|
|
96097
96240
|
};
|
|
96098
96241
|
};
|
|
96242
|
+
/**
|
|
96243
|
+
* Compose the per-repair offset mappers into one that maps an offset in the
|
|
96244
|
+
* fully-repaired string back to the original. `layers` are in application
|
|
96245
|
+
* order; each maps its own output space to its input space, so we apply them
|
|
96246
|
+
* last-repair-first to peel every edit back to the original coordinates.
|
|
96247
|
+
*/
|
|
96248
|
+
const composeOffsetMapper = (layers) => {
|
|
96249
|
+
const mappers = layers.map(buildOffsetMapper);
|
|
96250
|
+
return (repaired) => {
|
|
96251
|
+
let offset = repaired;
|
|
96252
|
+
for (let i = mappers.length - 1; i >= 0; i -= 1)
|
|
96253
|
+
offset = mappers[i](offset);
|
|
96254
|
+
return offset;
|
|
96255
|
+
};
|
|
96256
|
+
};
|
|
96099
96257
|
/**
|
|
96100
96258
|
* Map an offset in `source` to its 1-based `{ line, column }`. `lineStarts`
|
|
96101
96259
|
* is the precomputed array of offsets where each line begins.
|
|
@@ -96123,14 +96281,11 @@ const computeLineStarts = (source) => {
|
|
|
96123
96281
|
};
|
|
96124
96282
|
/**
|
|
96125
96283
|
* Walk `tree`, translating every node's position from the repaired source's
|
|
96126
|
-
* coordinate space back to the original source
|
|
96127
|
-
*
|
|
96128
|
-
*
|
|
96284
|
+
* coordinate space back to the original source via `mapOffset`. Line/column
|
|
96285
|
+
* are recomputed from the original source so they remain accurate even if
|
|
96286
|
+
* repairs introduced newlines.
|
|
96129
96287
|
*/
|
|
96130
|
-
const
|
|
96131
|
-
if (inserts.length === 0)
|
|
96132
|
-
return;
|
|
96133
|
-
const mapOffset = buildOffsetMapper(inserts);
|
|
96288
|
+
const remapWithMapper = (tree, originalSource, mapOffset) => {
|
|
96134
96289
|
const lineStarts = computeLineStarts(originalSource);
|
|
96135
96290
|
lib_visit(tree, child => {
|
|
96136
96291
|
if (child.position?.start) {
|
|
@@ -96149,6 +96304,15 @@ const remapPositionsToOriginal = (tree, originalSource, inserts) => {
|
|
|
96149
96304
|
}
|
|
96150
96305
|
});
|
|
96151
96306
|
};
|
|
96307
|
+
/**
|
|
96308
|
+
* Remap positions produced after a chain of repairs (each applied to the prior
|
|
96309
|
+
* one's output) back to the original source coordinates.
|
|
96310
|
+
*/
|
|
96311
|
+
const remapPositionsThroughLayers = (tree, originalSource, layers) => {
|
|
96312
|
+
if (layers.length === 0)
|
|
96313
|
+
return;
|
|
96314
|
+
remapWithMapper(tree, originalSource, composeOffsetMapper(layers));
|
|
96315
|
+
};
|
|
96152
96316
|
|
|
96153
96317
|
;// ./processor/transform/mdxish/tables/repair-expression-escapes.ts
|
|
96154
96318
|
|
|
@@ -96448,6 +96612,83 @@ const repairUnclosedTags = (html) => {
|
|
|
96448
96612
|
return applyInserts(html, inserts);
|
|
96449
96613
|
};
|
|
96450
96614
|
|
|
96615
|
+
;// ./processor/transform/mdxish/tables/split-nested-tables.ts
|
|
96616
|
+
|
|
96617
|
+
|
|
96618
|
+
const TOP_LEVEL_TABLE_TAG_RE = /^<(?:table|Table)(?=[\s/>])/;
|
|
96619
|
+
/**
|
|
96620
|
+
* Find every balanced, depth-matched `<table>…</table>` range in an html string.
|
|
96621
|
+
* Uses `walkTags` so `<table>`s inside code spans / fenced blocks (masked away)
|
|
96622
|
+
* are never matched.
|
|
96623
|
+
*
|
|
96624
|
+
* Note: An implicitly-closed table (no `</table>`, so htmlparser2 synthesizes the
|
|
96625
|
+
* close at a later tag) is skipped: splitting there would swallow whatever
|
|
96626
|
+
* followed the table into the fragment and drop it, so we leave such a node
|
|
96627
|
+
* whole for downstream raw-HTML handling instead.
|
|
96628
|
+
*/
|
|
96629
|
+
const findTableRanges = (html) => {
|
|
96630
|
+
const ranges = [];
|
|
96631
|
+
let depth = 0;
|
|
96632
|
+
let start = 0;
|
|
96633
|
+
walkTags(html, {
|
|
96634
|
+
onOpen: ({ name, start: openStart, isStrayCloser }) => {
|
|
96635
|
+
if (name.toLowerCase() !== 'table' || isStrayCloser)
|
|
96636
|
+
return;
|
|
96637
|
+
if (depth === 0)
|
|
96638
|
+
start = openStart;
|
|
96639
|
+
depth += 1;
|
|
96640
|
+
},
|
|
96641
|
+
onClose: ({ name, end, implicit }) => {
|
|
96642
|
+
if (implicit || name.toLowerCase() !== 'table' || depth === 0)
|
|
96643
|
+
return;
|
|
96644
|
+
depth -= 1;
|
|
96645
|
+
if (depth === 0)
|
|
96646
|
+
ranges.push({ start, end });
|
|
96647
|
+
},
|
|
96648
|
+
});
|
|
96649
|
+
return ranges;
|
|
96650
|
+
};
|
|
96651
|
+
/**
|
|
96652
|
+
* Given an HTML node that might contain table sequences inside it, split
|
|
96653
|
+
* the node based on the table boundaries so they become a top level node.
|
|
96654
|
+
*
|
|
96655
|
+
* The surrounding raw HTML (the wrapper's open/close tags) would be re-nested
|
|
96656
|
+
* around the parsed tables by rehype-raw.
|
|
96657
|
+
*
|
|
96658
|
+
* Returns null when there is no wrapped table to extract.
|
|
96659
|
+
*/
|
|
96660
|
+
const splitHtmlWithNestedTables = (node) => {
|
|
96661
|
+
const { value } = node;
|
|
96662
|
+
// This is a top-level table, so we don't need to split it
|
|
96663
|
+
if (TOP_LEVEL_TABLE_TAG_RE.test(value))
|
|
96664
|
+
return null;
|
|
96665
|
+
// No table text anywhere in the value → skip the htmlparser2 walk entirely.
|
|
96666
|
+
if (!/<\/?table/i.test(value))
|
|
96667
|
+
return null;
|
|
96668
|
+
const ranges = findTableRanges(value);
|
|
96669
|
+
if (ranges.length === 0)
|
|
96670
|
+
return null;
|
|
96671
|
+
const base = node.position?.start;
|
|
96672
|
+
const sliceToHtml = (from, to) => ({
|
|
96673
|
+
type: 'html',
|
|
96674
|
+
value: value.slice(from, to),
|
|
96675
|
+
...(base && {
|
|
96676
|
+
position: { start: pointAfter(base, value.slice(0, from)), end: pointAfter(base, value.slice(0, to)) },
|
|
96677
|
+
}),
|
|
96678
|
+
});
|
|
96679
|
+
const parts = [];
|
|
96680
|
+
let cursor = 0;
|
|
96681
|
+
ranges.forEach(({ start, end }) => {
|
|
96682
|
+
if (start > cursor)
|
|
96683
|
+
parts.push(sliceToHtml(cursor, start));
|
|
96684
|
+
parts.push(sliceToHtml(start, end)); // starts with `<table` → picked up by the main pass
|
|
96685
|
+
cursor = end;
|
|
96686
|
+
});
|
|
96687
|
+
if (cursor < value.length)
|
|
96688
|
+
parts.push(sliceToHtml(cursor, value.length));
|
|
96689
|
+
return parts;
|
|
96690
|
+
};
|
|
96691
|
+
|
|
96451
96692
|
;// ./processor/transform/mdxish/tables/mdxish-tables.ts
|
|
96452
96693
|
|
|
96453
96694
|
|
|
@@ -96467,6 +96708,9 @@ const repairUnclosedTags = (html) => {
|
|
|
96467
96708
|
|
|
96468
96709
|
|
|
96469
96710
|
|
|
96711
|
+
|
|
96712
|
+
|
|
96713
|
+
|
|
96470
96714
|
|
|
96471
96715
|
|
|
96472
96716
|
|
|
@@ -96497,6 +96741,21 @@ const buildTableNodeProcessor = (withMdx) => lib_unified()
|
|
|
96497
96741
|
.use(lib_remarkGfm);
|
|
96498
96742
|
const tableNodeProcessor = buildTableNodeProcessor(true);
|
|
96499
96743
|
const fallbackTableNodeProcessor = buildTableNodeProcessor(false);
|
|
96744
|
+
// Targeted repairs for tables mdxjs rejects, tried cumulatively (each runs on
|
|
96745
|
+
// the prior's output) since one table can carry independent per-cell defects.
|
|
96746
|
+
// Each was added after seeing real customer content fail to parse:
|
|
96747
|
+
// - repairUnclosedTags: unclosed/orphan HTML tags
|
|
96748
|
+
// - normalizeTagSpacing: a line mixing text and an opening tag
|
|
96749
|
+
// - repairExpressionEscapes: backslash escapes inside a `{…}` expression
|
|
96750
|
+
// - escapeStrayLessThan: a `<` that doesn't begin a valid tag (`word <`)
|
|
96751
|
+
// - escapeCrossingEmphasis: emphasis opening/closing at different tag depths
|
|
96752
|
+
const tableRepairs = [
|
|
96753
|
+
repairUnclosedTags,
|
|
96754
|
+
normalizeTagSpacing,
|
|
96755
|
+
repairExpressionEscapes,
|
|
96756
|
+
escapeStrayLessThan,
|
|
96757
|
+
escapeCrossingEmphasis,
|
|
96758
|
+
];
|
|
96500
96759
|
/**
|
|
96501
96760
|
* Parse the HTML node that contains the full table substring
|
|
96502
96761
|
* into the table parts (headers, rows, cells).
|
|
@@ -96512,10 +96771,10 @@ const parseTableNode = (processor, node, repair) => {
|
|
|
96512
96771
|
return undefined;
|
|
96513
96772
|
}
|
|
96514
96773
|
// If `node.value` was repaired before parsing, first remap positions back to
|
|
96515
|
-
// the original (unrepaired) coordinates via the insert
|
|
96774
|
+
// the original (unrepaired) coordinates via the insert layers — otherwise the
|
|
96516
96775
|
// shift would land on synthetic characters and be inaccurate
|
|
96517
96776
|
if (repair) {
|
|
96518
|
-
|
|
96777
|
+
remapPositionsThroughLayers(parsed, repair.originalSource, repair.layers);
|
|
96519
96778
|
}
|
|
96520
96779
|
// The subparser produces positions relative to `node.value`; shift them by
|
|
96521
96780
|
// the outer node's offset/line so consumers can slice the full source.
|
|
@@ -96612,9 +96871,7 @@ const processTableNode = (node, index, parent, documentPosition) => {
|
|
|
96612
96871
|
lib_visit(node, utils_isMDXElement, (child) => {
|
|
96613
96872
|
if (child.name === 'thead')
|
|
96614
96873
|
hasThead = true;
|
|
96615
|
-
if (tableTags.has(child.name) &&
|
|
96616
|
-
Array.isArray(child.attributes) &&
|
|
96617
|
-
child.attributes.length > 0) {
|
|
96874
|
+
if (tableTags.has(child.name) && Array.isArray(child.attributes) && child.attributes.length > 0) {
|
|
96618
96875
|
hasStructuralAttributes = true;
|
|
96619
96876
|
}
|
|
96620
96877
|
});
|
|
@@ -96725,6 +96982,26 @@ const processTableNode = (node, index, parent, documentPosition) => {
|
|
|
96725
96982
|
};
|
|
96726
96983
|
parent.children[index] = mdNode;
|
|
96727
96984
|
};
|
|
96985
|
+
/**
|
|
96986
|
+
* Apply `tableRepairs` cumulatively, re-parsing after every change and stopping
|
|
96987
|
+
* once the accumulated result parses. Each layer's inserts are relative to the
|
|
96988
|
+
* string that repair received, so they stay ordered for position remapping.
|
|
96989
|
+
*/
|
|
96990
|
+
const repairAndReparse = (node) => {
|
|
96991
|
+
let repairedValue = node.value;
|
|
96992
|
+
const layers = [];
|
|
96993
|
+
let parsed;
|
|
96994
|
+
tableRepairs.some(repair => {
|
|
96995
|
+
const { value, inserts } = repair(repairedValue);
|
|
96996
|
+
if (value === repairedValue)
|
|
96997
|
+
return false;
|
|
96998
|
+
repairedValue = value;
|
|
96999
|
+
layers.push(inserts);
|
|
97000
|
+
parsed = parseTableNode(tableNodeProcessor, { ...node, value: repairedValue }, { layers, originalSource: node.value });
|
|
97001
|
+
return Boolean(parsed);
|
|
97002
|
+
});
|
|
97003
|
+
return parsed;
|
|
97004
|
+
};
|
|
96728
97005
|
/**
|
|
96729
97006
|
* Converts JSX Table elements to markdown table nodes and re-parses markdown in cells.
|
|
96730
97007
|
*
|
|
@@ -96737,39 +97014,30 @@ const processTableNode = (node, index, parent, documentPosition) => {
|
|
|
96737
97014
|
* is kept as a JSX <Table> element so that remarkRehype can properly handle the flow content.
|
|
96738
97015
|
*/
|
|
96739
97016
|
const mdxish_tables_mdxishTables = () => tree => {
|
|
97017
|
+
// Pre-pass: lift `<table>`s wrapped in a raw HTML block out into their own
|
|
97018
|
+
// html nodes so the main pass below treats them like top-level tables.
|
|
97019
|
+
lib_visit(tree, 'html', (_node, index, parent) => {
|
|
97020
|
+
const node = _node;
|
|
97021
|
+
if (typeof index !== 'number' || !parent || !('children' in parent))
|
|
97022
|
+
return;
|
|
97023
|
+
const parts = splitHtmlWithNestedTables(node);
|
|
97024
|
+
if (!parts)
|
|
97025
|
+
return;
|
|
97026
|
+
// The inserted parts can't re-trigger a split (table parts start with
|
|
97027
|
+
// `<table`; the wrapper slices hold no table), so plain in-place splicing
|
|
97028
|
+
// visits each once without looping.
|
|
97029
|
+
parent.children.splice(index, 1, ...parts);
|
|
97030
|
+
});
|
|
96740
97031
|
lib_visit(tree, 'html', (_node, index, parent) => {
|
|
96741
97032
|
const node = _node;
|
|
96742
97033
|
if (typeof index !== 'number' || !parent || !('children' in parent))
|
|
96743
97034
|
return;
|
|
96744
97035
|
if (!node.value.startsWith('<Table') && !node.value.startsWith('<table'))
|
|
96745
97036
|
return;
|
|
96746
|
-
// Main logic to transform table node to its parts
|
|
96747
97037
|
// Because the processor uses remarkMdx, it is stricter in what it accepts
|
|
96748
|
-
// and only accepts valid MDX syntax
|
|
96749
|
-
//
|
|
96750
|
-
|
|
96751
|
-
if (!parsed) {
|
|
96752
|
-
// Try a sequence of targeted repairs and re-parse
|
|
96753
|
-
// after each, stopping at the first that yields a parseable tree:
|
|
96754
|
-
// - repairUnclosedTags: unclosed/orphan HTML tags
|
|
96755
|
-
// - normalizeTagSpacing: a line mixing text and an opening tag
|
|
96756
|
-
// (e.g. `text <div> \n <div> text`)
|
|
96757
|
-
// - repairExpressionEscapes: backslash escapes inside a `{…}` expression
|
|
96758
|
-
// These repairs are created after seeing real customer content that has failed to parse
|
|
96759
|
-
const repairs = [
|
|
96760
|
-
repairUnclosedTags,
|
|
96761
|
-
normalizeTagSpacing,
|
|
96762
|
-
repairExpressionEscapes,
|
|
96763
|
-
];
|
|
96764
|
-
// Stops at the first repair that yields a parseable tree
|
|
96765
|
-
repairs.some(repair => {
|
|
96766
|
-
const { value, inserts } = repair(node.value);
|
|
96767
|
-
if (value !== node.value) {
|
|
96768
|
-
parsed = parseTableNode(tableNodeProcessor, { ...node, value }, { inserts, originalSource: node.value });
|
|
96769
|
-
}
|
|
96770
|
-
return Boolean(parsed);
|
|
96771
|
-
});
|
|
96772
|
-
}
|
|
97038
|
+
// and only accepts valid MDX syntax in the table node. To get around that,
|
|
97039
|
+
// fall back to the cumulative repairs when the first parse fails.
|
|
97040
|
+
const parsed = parseTableNode(tableNodeProcessor, node) ?? repairAndReparse(node);
|
|
96773
97041
|
if (parsed) {
|
|
96774
97042
|
// If the table is parsed successfully, we can now process it further
|
|
96775
97043
|
// to build on the markdown / JSX table
|
|
@@ -117498,6 +117766,21 @@ function isActualHtmlTag(tagName, originalExcerpt) {
|
|
|
117498
117766
|
return true;
|
|
117499
117767
|
return false;
|
|
117500
117768
|
}
|
|
117769
|
+
/**
|
|
117770
|
+
* Re-parsing a component's text child treats it as a standalone document, so
|
|
117771
|
+
* content that happens to start with the literal word `export`/`import`
|
|
117772
|
+
* (e.g. link text like "export Lorem Ipsum") sits at true column 1 and
|
|
117773
|
+
* gets mistaken for an MDX ESM statement, which then fails to parse as JS.
|
|
117774
|
+
* Fall back to `undefined` rather than letting one such child crash the page.
|
|
117775
|
+
*/
|
|
117776
|
+
function tryProcessMarkdown(processMarkdown, content) {
|
|
117777
|
+
try {
|
|
117778
|
+
return processMarkdown(content);
|
|
117779
|
+
}
|
|
117780
|
+
catch {
|
|
117781
|
+
return undefined;
|
|
117782
|
+
}
|
|
117783
|
+
}
|
|
117501
117784
|
/** Parse and replace text children with processed markdown */
|
|
117502
117785
|
function parseTextChildren(node, processMarkdown, components) {
|
|
117503
117786
|
if (!node.children?.length)
|
|
@@ -117512,7 +117795,9 @@ function parseTextChildren(node, processMarkdown, components) {
|
|
|
117512
117795
|
node.properties = { ...node.properties, children: child.value };
|
|
117513
117796
|
return [];
|
|
117514
117797
|
}
|
|
117515
|
-
const hast = processMarkdown
|
|
117798
|
+
const hast = tryProcessMarkdown(processMarkdown, child.value.trim());
|
|
117799
|
+
if (!hast)
|
|
117800
|
+
return [child];
|
|
117516
117801
|
const children = (hast.children ?? []).filter(isElementContentNode);
|
|
117517
117802
|
// For inline components, preserve plain text instead of wrapping in <p>
|
|
117518
117803
|
if (INLINE_COMPONENT_TAGS_LOWER.has(node.tagName.toLowerCase()) && isSingleParagraphTextNode(children)) {
|
|
@@ -117586,8 +117871,9 @@ const rehypeMdxishComponents = ({ components, processMarkdown }) => {
|
|
|
117586
117871
|
// rehypeRaw strips children from <img> (void element), so we must
|
|
117587
117872
|
// re-process the caption here, after rehypeRaw.
|
|
117588
117873
|
if (node.tagName === 'img' && typeof node.properties?.caption === 'string' && !node.children?.length) {
|
|
117589
|
-
const
|
|
117590
|
-
|
|
117874
|
+
const caption = node.properties.caption;
|
|
117875
|
+
const captionHast = tryProcessMarkdown(processMarkdown, caption);
|
|
117876
|
+
node.children = captionHast ? (captionHast.children ?? []).filter(isElementContentNode) : [{ type: 'text', value: caption }];
|
|
117591
117877
|
}
|
|
117592
117878
|
// Skip runtime components and standard HTML tags
|
|
117593
117879
|
if (RUNTIME_COMPONENT_TAGS.has(node.tagName))
|
|
@@ -117620,11 +117906,10 @@ const rehypeMdxishComponents = ({ components, processMarkdown }) => {
|
|
|
117620
117906
|
;// ./processor/plugin/mdxish-handlers.ts
|
|
117621
117907
|
|
|
117622
117908
|
|
|
117623
|
-
//
|
|
117624
|
-
|
|
117625
|
-
|
|
117626
|
-
|
|
117627
|
-
});
|
|
117909
|
+
// If hChildren is populated, it means the node holds a renderable value (e.g. React)
|
|
117910
|
+
// See evaluate-expressions.ts for more details
|
|
117911
|
+
// Otherwise, it's a simple value and we fall back to text
|
|
117912
|
+
const mdxExpressionHandler = (_state, node) => node.data?.hChildren ?? { type: 'text', value: node.value || '' };
|
|
117628
117913
|
// Convert MDX JSX elements to a custom mdx-jsx hast node that bypasses rehypeRaw's
|
|
117629
117914
|
// HTML serialization round-trip; downstream normalization rewrites it to `element`.
|
|
117630
117915
|
const mdxJsxElementHandler = (state, node) => {
|
|
@@ -118316,7 +118601,7 @@ const KNOWN_BLOCK_TYPES = new Set([
|
|
|
118316
118601
|
* Types can contain alphanumeric characters and hyphens (e.g., "api-header", "tutorial-tile")
|
|
118317
118602
|
*/
|
|
118318
118603
|
function isTypeChar(code) {
|
|
118319
|
-
return asciiAlphanumeric(code) || code ===
|
|
118604
|
+
return asciiAlphanumeric(code) || code === codes_codes.dash;
|
|
118320
118605
|
}
|
|
118321
118606
|
/**
|
|
118322
118607
|
* Creates the opening marker state machine: [block:
|
|
@@ -118324,37 +118609,37 @@ function isTypeChar(code) {
|
|
|
118324
118609
|
*/
|
|
118325
118610
|
function createOpeningMarkerParser(effects, nok, onComplete) {
|
|
118326
118611
|
const expectB = (code) => {
|
|
118327
|
-
if (code !==
|
|
118612
|
+
if (code !== codes_codes.lowercaseB)
|
|
118328
118613
|
return nok(code);
|
|
118329
118614
|
effects.consume(code);
|
|
118330
118615
|
return expectL;
|
|
118331
118616
|
};
|
|
118332
118617
|
const expectL = (code) => {
|
|
118333
|
-
if (code !==
|
|
118618
|
+
if (code !== codes_codes.lowercaseL)
|
|
118334
118619
|
return nok(code);
|
|
118335
118620
|
effects.consume(code);
|
|
118336
118621
|
return expectO;
|
|
118337
118622
|
};
|
|
118338
118623
|
const expectO = (code) => {
|
|
118339
|
-
if (code !==
|
|
118624
|
+
if (code !== codes_codes.lowercaseO)
|
|
118340
118625
|
return nok(code);
|
|
118341
118626
|
effects.consume(code);
|
|
118342
118627
|
return expectC;
|
|
118343
118628
|
};
|
|
118344
118629
|
const expectC = (code) => {
|
|
118345
|
-
if (code !==
|
|
118630
|
+
if (code !== codes_codes.lowercaseC)
|
|
118346
118631
|
return nok(code);
|
|
118347
118632
|
effects.consume(code);
|
|
118348
118633
|
return expectK;
|
|
118349
118634
|
};
|
|
118350
118635
|
const expectK = (code) => {
|
|
118351
|
-
if (code !==
|
|
118636
|
+
if (code !== codes_codes.lowercaseK)
|
|
118352
118637
|
return nok(code);
|
|
118353
118638
|
effects.consume(code);
|
|
118354
118639
|
return expectColon;
|
|
118355
118640
|
};
|
|
118356
118641
|
const expectColon = (code) => {
|
|
118357
|
-
if (code !==
|
|
118642
|
+
if (code !== codes_codes.colon)
|
|
118358
118643
|
return nok(code);
|
|
118359
118644
|
effects.consume(code);
|
|
118360
118645
|
effects.exit('magicBlockMarkerStart');
|
|
@@ -118370,7 +118655,7 @@ function createOpeningMarkerParser(effects, nok, onComplete) {
|
|
|
118370
118655
|
function createTypeCaptureParser(effects, nok, onComplete, blockTypeRef) {
|
|
118371
118656
|
const captureTypeFirst = (code) => {
|
|
118372
118657
|
// Reject empty type name [block:]
|
|
118373
|
-
if (code ===
|
|
118658
|
+
if (code === codes_codes.rightSquareBracket) {
|
|
118374
118659
|
return nok(code);
|
|
118375
118660
|
}
|
|
118376
118661
|
if (isTypeChar(code)) {
|
|
@@ -118381,7 +118666,7 @@ function createTypeCaptureParser(effects, nok, onComplete, blockTypeRef) {
|
|
|
118381
118666
|
return nok(code);
|
|
118382
118667
|
};
|
|
118383
118668
|
const captureType = (code) => {
|
|
118384
|
-
if (code ===
|
|
118669
|
+
if (code === codes_codes.rightSquareBracket) {
|
|
118385
118670
|
if (!KNOWN_BLOCK_TYPES.has(blockTypeRef.value)) {
|
|
118386
118671
|
return nok(code);
|
|
118387
118672
|
}
|
|
@@ -118406,7 +118691,7 @@ function createTypeCaptureParser(effects, nok, onComplete, blockTypeRef) {
|
|
|
118406
118691
|
*/
|
|
118407
118692
|
function createClosingMarkerParser(effects, onSuccess, onMismatch, onEof, jsonState) {
|
|
118408
118693
|
const handleMismatch = (code) => {
|
|
118409
|
-
if (jsonState && code ===
|
|
118694
|
+
if (jsonState && code === codes_codes.quotationMark) {
|
|
118410
118695
|
jsonState.inString = true;
|
|
118411
118696
|
}
|
|
118412
118697
|
return onMismatch(code);
|
|
@@ -118414,7 +118699,7 @@ function createClosingMarkerParser(effects, onSuccess, onMismatch, onEof, jsonSt
|
|
|
118414
118699
|
const expectSlash = (code) => {
|
|
118415
118700
|
if (code === null)
|
|
118416
118701
|
return onEof(code);
|
|
118417
|
-
if (code !==
|
|
118702
|
+
if (code !== codes_codes.slash)
|
|
118418
118703
|
return handleMismatch(code);
|
|
118419
118704
|
effects.consume(code);
|
|
118420
118705
|
return expectB;
|
|
@@ -118422,7 +118707,7 @@ function createClosingMarkerParser(effects, onSuccess, onMismatch, onEof, jsonSt
|
|
|
118422
118707
|
const expectB = (code) => {
|
|
118423
118708
|
if (code === null)
|
|
118424
118709
|
return onEof(code);
|
|
118425
|
-
if (code !==
|
|
118710
|
+
if (code !== codes_codes.lowercaseB)
|
|
118426
118711
|
return handleMismatch(code);
|
|
118427
118712
|
effects.consume(code);
|
|
118428
118713
|
return expectL;
|
|
@@ -118430,7 +118715,7 @@ function createClosingMarkerParser(effects, onSuccess, onMismatch, onEof, jsonSt
|
|
|
118430
118715
|
const expectL = (code) => {
|
|
118431
118716
|
if (code === null)
|
|
118432
118717
|
return onEof(code);
|
|
118433
|
-
if (code !==
|
|
118718
|
+
if (code !== codes_codes.lowercaseL)
|
|
118434
118719
|
return handleMismatch(code);
|
|
118435
118720
|
effects.consume(code);
|
|
118436
118721
|
return expectO;
|
|
@@ -118438,7 +118723,7 @@ function createClosingMarkerParser(effects, onSuccess, onMismatch, onEof, jsonSt
|
|
|
118438
118723
|
const expectO = (code) => {
|
|
118439
118724
|
if (code === null)
|
|
118440
118725
|
return onEof(code);
|
|
118441
|
-
if (code !==
|
|
118726
|
+
if (code !== codes_codes.lowercaseO)
|
|
118442
118727
|
return handleMismatch(code);
|
|
118443
118728
|
effects.consume(code);
|
|
118444
118729
|
return expectC;
|
|
@@ -118446,7 +118731,7 @@ function createClosingMarkerParser(effects, onSuccess, onMismatch, onEof, jsonSt
|
|
|
118446
118731
|
const expectC = (code) => {
|
|
118447
118732
|
if (code === null)
|
|
118448
118733
|
return onEof(code);
|
|
118449
|
-
if (code !==
|
|
118734
|
+
if (code !== codes_codes.lowercaseC)
|
|
118450
118735
|
return handleMismatch(code);
|
|
118451
118736
|
effects.consume(code);
|
|
118452
118737
|
return expectK;
|
|
@@ -118454,7 +118739,7 @@ function createClosingMarkerParser(effects, onSuccess, onMismatch, onEof, jsonSt
|
|
|
118454
118739
|
const expectK = (code) => {
|
|
118455
118740
|
if (code === null)
|
|
118456
118741
|
return onEof(code);
|
|
118457
|
-
if (code !==
|
|
118742
|
+
if (code !== codes_codes.lowercaseK)
|
|
118458
118743
|
return handleMismatch(code);
|
|
118459
118744
|
effects.consume(code);
|
|
118460
118745
|
return expectBracket;
|
|
@@ -118462,7 +118747,7 @@ function createClosingMarkerParser(effects, onSuccess, onMismatch, onEof, jsonSt
|
|
|
118462
118747
|
const expectBracket = (code) => {
|
|
118463
118748
|
if (code === null)
|
|
118464
118749
|
return onEof(code);
|
|
118465
|
-
if (code !==
|
|
118750
|
+
if (code !== codes_codes.rightSquareBracket)
|
|
118466
118751
|
return handleMismatch(code);
|
|
118467
118752
|
effects.consume(code);
|
|
118468
118753
|
return onSuccess;
|
|
@@ -118518,7 +118803,7 @@ function syntax_magicBlock() {
|
|
|
118518
118803
|
// Flow construct - handles block-level magic blocks at document root
|
|
118519
118804
|
// Marked as concrete to prevent interruption by containers
|
|
118520
118805
|
flow: {
|
|
118521
|
-
[
|
|
118806
|
+
[codes_codes.leftSquareBracket]: {
|
|
118522
118807
|
name: 'magicBlock',
|
|
118523
118808
|
concrete: true,
|
|
118524
118809
|
tokenize: tokenizeMagicBlockFlow,
|
|
@@ -118526,7 +118811,7 @@ function syntax_magicBlock() {
|
|
|
118526
118811
|
},
|
|
118527
118812
|
// Text construct - handles magic blocks in inline contexts (lists, paragraphs)
|
|
118528
118813
|
text: {
|
|
118529
|
-
[
|
|
118814
|
+
[codes_codes.leftSquareBracket]: {
|
|
118530
118815
|
name: 'magicBlock',
|
|
118531
118816
|
tokenize: tokenizeMagicBlockText,
|
|
118532
118817
|
},
|
|
@@ -118547,7 +118832,7 @@ function tokenizeMagicBlockFlow(effects, ok, nok) {
|
|
|
118547
118832
|
const openingMarkerParser = createOpeningMarkerParser(effects, nok, typeParser.first);
|
|
118548
118833
|
return start;
|
|
118549
118834
|
function start(code) {
|
|
118550
|
-
if (code !==
|
|
118835
|
+
if (code !== codes_codes.leftSquareBracket)
|
|
118551
118836
|
return nok(code);
|
|
118552
118837
|
effects.enter('magicBlock');
|
|
118553
118838
|
effects.enter('magicBlockMarkerStart');
|
|
@@ -118570,7 +118855,7 @@ function tokenizeMagicBlockFlow(effects, ok, nok) {
|
|
|
118570
118855
|
// Check for closing marker directly (without entering data)
|
|
118571
118856
|
// This handles cases like [block:type]\n{}\n\n[/block] where there are
|
|
118572
118857
|
// newlines after the data object
|
|
118573
|
-
if (code ===
|
|
118858
|
+
if (code === codes_codes.leftSquareBracket) {
|
|
118574
118859
|
effects.enter('magicBlockMarkerEnd');
|
|
118575
118860
|
effects.consume(code);
|
|
118576
118861
|
return expectSlashFromContinuation;
|
|
@@ -118582,11 +118867,11 @@ function tokenizeMagicBlockFlow(effects, ok, nok) {
|
|
|
118582
118867
|
}
|
|
118583
118868
|
// Skip whitespace (spaces/tabs) before the data - stay in beforeData
|
|
118584
118869
|
// Don't enter magicBlockData token yet until we confirm there's a '{'
|
|
118585
|
-
if (code ===
|
|
118870
|
+
if (code === codes_codes.space || code === codes_codes.horizontalTab) {
|
|
118586
118871
|
return beforeDataWhitespace(code);
|
|
118587
118872
|
}
|
|
118588
118873
|
// Data must start with '{' for valid JSON
|
|
118589
|
-
if (code !==
|
|
118874
|
+
if (code !== codes_codes.leftCurlyBrace) {
|
|
118590
118875
|
effects.exit('magicBlock');
|
|
118591
118876
|
return nok(code);
|
|
118592
118877
|
}
|
|
@@ -118607,14 +118892,14 @@ function tokenizeMagicBlockFlow(effects, ok, nok) {
|
|
|
118607
118892
|
if (markdownLineEnding(code)) {
|
|
118608
118893
|
return effects.check(syntax_nonLazyContinuation, continuationOkBeforeData, after)(code);
|
|
118609
118894
|
}
|
|
118610
|
-
if (code ===
|
|
118895
|
+
if (code === codes_codes.space || code === codes_codes.horizontalTab) {
|
|
118611
118896
|
// We need to consume this but can't without a token - use magicBlockData
|
|
118612
118897
|
// and track that we haven't seen '{' yet
|
|
118613
118898
|
effects.enter('magicBlockData');
|
|
118614
118899
|
effects.consume(code);
|
|
118615
118900
|
return beforeDataWhitespaceContinue;
|
|
118616
118901
|
}
|
|
118617
|
-
if (code ===
|
|
118902
|
+
if (code === codes_codes.leftCurlyBrace) {
|
|
118618
118903
|
seenOpenBrace = true;
|
|
118619
118904
|
effects.enter('magicBlockData');
|
|
118620
118905
|
return captureData(code);
|
|
@@ -118635,11 +118920,11 @@ function tokenizeMagicBlockFlow(effects, ok, nok) {
|
|
|
118635
118920
|
effects.exit('magicBlockData');
|
|
118636
118921
|
return effects.check(syntax_nonLazyContinuation, continuationOk, after)(code);
|
|
118637
118922
|
}
|
|
118638
|
-
if (code ===
|
|
118923
|
+
if (code === codes_codes.space || code === codes_codes.horizontalTab) {
|
|
118639
118924
|
effects.consume(code);
|
|
118640
118925
|
return beforeDataWhitespaceContinue;
|
|
118641
118926
|
}
|
|
118642
|
-
if (code ===
|
|
118927
|
+
if (code === codes_codes.leftCurlyBrace) {
|
|
118643
118928
|
seenOpenBrace = true;
|
|
118644
118929
|
return captureData(code);
|
|
118645
118930
|
}
|
|
@@ -118674,23 +118959,23 @@ function tokenizeMagicBlockFlow(effects, ok, nok) {
|
|
|
118674
118959
|
return captureData;
|
|
118675
118960
|
}
|
|
118676
118961
|
if (jsonState.inString) {
|
|
118677
|
-
if (code ===
|
|
118962
|
+
if (code === codes_codes.backslash) {
|
|
118678
118963
|
jsonState.escapeNext = true;
|
|
118679
118964
|
effects.consume(code);
|
|
118680
118965
|
return captureData;
|
|
118681
118966
|
}
|
|
118682
|
-
if (code ===
|
|
118967
|
+
if (code === codes_codes.quotationMark) {
|
|
118683
118968
|
jsonState.inString = false;
|
|
118684
118969
|
}
|
|
118685
118970
|
effects.consume(code);
|
|
118686
118971
|
return captureData;
|
|
118687
118972
|
}
|
|
118688
|
-
if (code ===
|
|
118973
|
+
if (code === codes_codes.quotationMark) {
|
|
118689
118974
|
jsonState.inString = true;
|
|
118690
118975
|
effects.consume(code);
|
|
118691
118976
|
return captureData;
|
|
118692
118977
|
}
|
|
118693
|
-
if (code ===
|
|
118978
|
+
if (code === codes_codes.leftSquareBracket) {
|
|
118694
118979
|
effects.exit('magicBlockData');
|
|
118695
118980
|
effects.enter('magicBlockMarkerEnd');
|
|
118696
118981
|
effects.consume(code);
|
|
@@ -118723,7 +119008,7 @@ function tokenizeMagicBlockFlow(effects, ok, nok) {
|
|
|
118723
119008
|
}
|
|
118724
119009
|
// Check if this is the start of the closing marker [/block]
|
|
118725
119010
|
// If so, handle it directly without entering magicBlockData
|
|
118726
|
-
if (code ===
|
|
119011
|
+
if (code === codes_codes.leftSquareBracket) {
|
|
118727
119012
|
effects.enter('magicBlockMarkerEnd');
|
|
118728
119013
|
effects.consume(code);
|
|
118729
119014
|
return expectSlashFromContinuation;
|
|
@@ -118745,7 +119030,7 @@ function tokenizeMagicBlockFlow(effects, ok, nok) {
|
|
|
118745
119030
|
effects.exit('magicBlockMarkerEnd');
|
|
118746
119031
|
return effects.check(syntax_nonLazyContinuation, continuationOkBeforeData, after)(code);
|
|
118747
119032
|
}
|
|
118748
|
-
if (code ===
|
|
119033
|
+
if (code === codes_codes.slash) {
|
|
118749
119034
|
effects.consume(code);
|
|
118750
119035
|
return expectClosingB;
|
|
118751
119036
|
}
|
|
@@ -118756,7 +119041,7 @@ function tokenizeMagicBlockFlow(effects, ok, nok) {
|
|
|
118756
119041
|
// The [ was consumed by the marker, so we need to conceptually "have it" in our data
|
|
118757
119042
|
// But since we already consumed it into the marker, we need a different approach
|
|
118758
119043
|
// Re-classify: consume this character as data and continue
|
|
118759
|
-
if (code ===
|
|
119044
|
+
if (code === codes_codes.quotationMark)
|
|
118760
119045
|
jsonState.inString = true;
|
|
118761
119046
|
effects.consume(code);
|
|
118762
119047
|
return captureData;
|
|
@@ -118772,10 +119057,10 @@ function tokenizeMagicBlockFlow(effects, ok, nok) {
|
|
|
118772
119057
|
effects.exit('magicBlockMarkerEnd');
|
|
118773
119058
|
return effects.check(syntax_nonLazyContinuation, continuationOk, after)(code);
|
|
118774
119059
|
}
|
|
118775
|
-
if (code !==
|
|
119060
|
+
if (code !== codes_codes.slash) {
|
|
118776
119061
|
effects.exit('magicBlockMarkerEnd');
|
|
118777
119062
|
effects.enter('magicBlockData');
|
|
118778
|
-
if (code ===
|
|
119063
|
+
if (code === codes_codes.quotationMark)
|
|
118779
119064
|
jsonState.inString = true;
|
|
118780
119065
|
effects.consume(code);
|
|
118781
119066
|
return captureData;
|
|
@@ -118789,10 +119074,10 @@ function tokenizeMagicBlockFlow(effects, ok, nok) {
|
|
|
118789
119074
|
effects.exit('magicBlock');
|
|
118790
119075
|
return nok(code);
|
|
118791
119076
|
}
|
|
118792
|
-
if (code !==
|
|
119077
|
+
if (code !== codes_codes.lowercaseB) {
|
|
118793
119078
|
effects.exit('magicBlockMarkerEnd');
|
|
118794
119079
|
effects.enter('magicBlockData');
|
|
118795
|
-
if (code ===
|
|
119080
|
+
if (code === codes_codes.quotationMark)
|
|
118796
119081
|
jsonState.inString = true;
|
|
118797
119082
|
effects.consume(code);
|
|
118798
119083
|
return captureData;
|
|
@@ -118806,10 +119091,10 @@ function tokenizeMagicBlockFlow(effects, ok, nok) {
|
|
|
118806
119091
|
effects.exit('magicBlock');
|
|
118807
119092
|
return nok(code);
|
|
118808
119093
|
}
|
|
118809
|
-
if (code !==
|
|
119094
|
+
if (code !== codes_codes.lowercaseL) {
|
|
118810
119095
|
effects.exit('magicBlockMarkerEnd');
|
|
118811
119096
|
effects.enter('magicBlockData');
|
|
118812
|
-
if (code ===
|
|
119097
|
+
if (code === codes_codes.quotationMark)
|
|
118813
119098
|
jsonState.inString = true;
|
|
118814
119099
|
effects.consume(code);
|
|
118815
119100
|
return captureData;
|
|
@@ -118823,10 +119108,10 @@ function tokenizeMagicBlockFlow(effects, ok, nok) {
|
|
|
118823
119108
|
effects.exit('magicBlock');
|
|
118824
119109
|
return nok(code);
|
|
118825
119110
|
}
|
|
118826
|
-
if (code !==
|
|
119111
|
+
if (code !== codes_codes.lowercaseO) {
|
|
118827
119112
|
effects.exit('magicBlockMarkerEnd');
|
|
118828
119113
|
effects.enter('magicBlockData');
|
|
118829
|
-
if (code ===
|
|
119114
|
+
if (code === codes_codes.quotationMark)
|
|
118830
119115
|
jsonState.inString = true;
|
|
118831
119116
|
effects.consume(code);
|
|
118832
119117
|
return captureData;
|
|
@@ -118840,10 +119125,10 @@ function tokenizeMagicBlockFlow(effects, ok, nok) {
|
|
|
118840
119125
|
effects.exit('magicBlock');
|
|
118841
119126
|
return nok(code);
|
|
118842
119127
|
}
|
|
118843
|
-
if (code !==
|
|
119128
|
+
if (code !== codes_codes.lowercaseC) {
|
|
118844
119129
|
effects.exit('magicBlockMarkerEnd');
|
|
118845
119130
|
effects.enter('magicBlockData');
|
|
118846
|
-
if (code ===
|
|
119131
|
+
if (code === codes_codes.quotationMark)
|
|
118847
119132
|
jsonState.inString = true;
|
|
118848
119133
|
effects.consume(code);
|
|
118849
119134
|
return captureData;
|
|
@@ -118857,10 +119142,10 @@ function tokenizeMagicBlockFlow(effects, ok, nok) {
|
|
|
118857
119142
|
effects.exit('magicBlock');
|
|
118858
119143
|
return nok(code);
|
|
118859
119144
|
}
|
|
118860
|
-
if (code !==
|
|
119145
|
+
if (code !== codes_codes.lowercaseK) {
|
|
118861
119146
|
effects.exit('magicBlockMarkerEnd');
|
|
118862
119147
|
effects.enter('magicBlockData');
|
|
118863
|
-
if (code ===
|
|
119148
|
+
if (code === codes_codes.quotationMark)
|
|
118864
119149
|
jsonState.inString = true;
|
|
118865
119150
|
effects.consume(code);
|
|
118866
119151
|
return captureData;
|
|
@@ -118874,10 +119159,10 @@ function tokenizeMagicBlockFlow(effects, ok, nok) {
|
|
|
118874
119159
|
effects.exit('magicBlock');
|
|
118875
119160
|
return nok(code);
|
|
118876
119161
|
}
|
|
118877
|
-
if (code !==
|
|
119162
|
+
if (code !== codes_codes.rightSquareBracket) {
|
|
118878
119163
|
effects.exit('magicBlockMarkerEnd');
|
|
118879
119164
|
effects.enter('magicBlockData');
|
|
118880
|
-
if (code ===
|
|
119165
|
+
if (code === codes_codes.quotationMark)
|
|
118881
119166
|
jsonState.inString = true;
|
|
118882
119167
|
effects.consume(code);
|
|
118883
119168
|
return captureData;
|
|
@@ -118904,7 +119189,7 @@ function tokenizeMagicBlockFlow(effects, ok, nok) {
|
|
|
118904
119189
|
return ok(code);
|
|
118905
119190
|
}
|
|
118906
119191
|
// Space or tab - consume as trailing whitespace
|
|
118907
|
-
if (code ===
|
|
119192
|
+
if (code === codes_codes.space || code === codes_codes.horizontalTab) {
|
|
118908
119193
|
effects.enter('magicBlockTrailing');
|
|
118909
119194
|
effects.consume(code);
|
|
118910
119195
|
return consumeTrailingContinue;
|
|
@@ -118930,7 +119215,7 @@ function tokenizeMagicBlockFlow(effects, ok, nok) {
|
|
|
118930
119215
|
return ok(code);
|
|
118931
119216
|
}
|
|
118932
119217
|
// More space or tab - keep consuming
|
|
118933
|
-
if (code ===
|
|
119218
|
+
if (code === codes_codes.space || code === codes_codes.horizontalTab) {
|
|
118934
119219
|
effects.consume(code);
|
|
118935
119220
|
return consumeTrailingContinue;
|
|
118936
119221
|
}
|
|
@@ -118970,7 +119255,7 @@ function tokenizeMagicBlockText(effects, ok, nok) {
|
|
|
118970
119255
|
const closingMismatch = (code) => {
|
|
118971
119256
|
effects.exit('magicBlockMarkerEnd');
|
|
118972
119257
|
effects.enter('magicBlockData');
|
|
118973
|
-
if (code ===
|
|
119258
|
+
if (code === codes_codes.quotationMark)
|
|
118974
119259
|
jsonState.inString = true;
|
|
118975
119260
|
effects.consume(code);
|
|
118976
119261
|
return captureData;
|
|
@@ -118982,7 +119267,7 @@ function tokenizeMagicBlockText(effects, ok, nok) {
|
|
|
118982
119267
|
const closingFromData = createClosingMarkerParser(effects, closingSuccess, closingMismatch, closingEof, jsonState);
|
|
118983
119268
|
return start;
|
|
118984
119269
|
function start(code) {
|
|
118985
|
-
if (code !==
|
|
119270
|
+
if (code !== codes_codes.leftSquareBracket)
|
|
118986
119271
|
return nok(code);
|
|
118987
119272
|
effects.enter('magicBlock');
|
|
118988
119273
|
effects.enter('magicBlockMarkerStart');
|
|
@@ -119006,7 +119291,7 @@ function tokenizeMagicBlockText(effects, ok, nok) {
|
|
|
119006
119291
|
return beforeData;
|
|
119007
119292
|
}
|
|
119008
119293
|
// Check for closing marker directly (without entering data)
|
|
119009
|
-
if (code ===
|
|
119294
|
+
if (code === codes_codes.leftSquareBracket) {
|
|
119010
119295
|
effects.enter('magicBlockMarkerEnd');
|
|
119011
119296
|
effects.consume(code);
|
|
119012
119297
|
return closingFromBeforeData.expectSlash;
|
|
@@ -119017,11 +119302,11 @@ function tokenizeMagicBlockText(effects, ok, nok) {
|
|
|
119017
119302
|
return captureData(code);
|
|
119018
119303
|
}
|
|
119019
119304
|
// Skip whitespace (spaces/tabs) before the data
|
|
119020
|
-
if (code ===
|
|
119305
|
+
if (code === codes_codes.space || code === codes_codes.horizontalTab) {
|
|
119021
119306
|
return beforeDataWhitespace(code);
|
|
119022
119307
|
}
|
|
119023
119308
|
// Data must start with '{' for valid JSON
|
|
119024
|
-
if (code !==
|
|
119309
|
+
if (code !== codes_codes.leftCurlyBrace) {
|
|
119025
119310
|
return nok(code);
|
|
119026
119311
|
}
|
|
119027
119312
|
// We have '{' - enter data token and start capturing
|
|
@@ -119042,12 +119327,12 @@ function tokenizeMagicBlockText(effects, ok, nok) {
|
|
|
119042
119327
|
effects.exit('magicBlockLineEnding');
|
|
119043
119328
|
return beforeData;
|
|
119044
119329
|
}
|
|
119045
|
-
if (code ===
|
|
119330
|
+
if (code === codes_codes.space || code === codes_codes.horizontalTab) {
|
|
119046
119331
|
effects.enter('magicBlockData');
|
|
119047
119332
|
effects.consume(code);
|
|
119048
119333
|
return beforeDataWhitespaceContinue;
|
|
119049
119334
|
}
|
|
119050
|
-
if (code ===
|
|
119335
|
+
if (code === codes_codes.leftCurlyBrace) {
|
|
119051
119336
|
seenOpenBrace = true;
|
|
119052
119337
|
effects.enter('magicBlockData');
|
|
119053
119338
|
return captureData(code);
|
|
@@ -119069,11 +119354,11 @@ function tokenizeMagicBlockText(effects, ok, nok) {
|
|
|
119069
119354
|
effects.exit('magicBlockLineEnding');
|
|
119070
119355
|
return beforeData;
|
|
119071
119356
|
}
|
|
119072
|
-
if (code ===
|
|
119357
|
+
if (code === codes_codes.space || code === codes_codes.horizontalTab) {
|
|
119073
119358
|
effects.consume(code);
|
|
119074
119359
|
return beforeDataWhitespaceContinue;
|
|
119075
119360
|
}
|
|
119076
|
-
if (code ===
|
|
119361
|
+
if (code === codes_codes.leftCurlyBrace) {
|
|
119077
119362
|
seenOpenBrace = true;
|
|
119078
119363
|
return captureData(code);
|
|
119079
119364
|
}
|
|
@@ -119101,23 +119386,23 @@ function tokenizeMagicBlockText(effects, ok, nok) {
|
|
|
119101
119386
|
return captureData;
|
|
119102
119387
|
}
|
|
119103
119388
|
if (jsonState.inString) {
|
|
119104
|
-
if (code ===
|
|
119389
|
+
if (code === codes_codes.backslash) {
|
|
119105
119390
|
jsonState.escapeNext = true;
|
|
119106
119391
|
effects.consume(code);
|
|
119107
119392
|
return captureData;
|
|
119108
119393
|
}
|
|
119109
|
-
if (code ===
|
|
119394
|
+
if (code === codes_codes.quotationMark) {
|
|
119110
119395
|
jsonState.inString = false;
|
|
119111
119396
|
}
|
|
119112
119397
|
effects.consume(code);
|
|
119113
119398
|
return captureData;
|
|
119114
119399
|
}
|
|
119115
|
-
if (code ===
|
|
119400
|
+
if (code === codes_codes.quotationMark) {
|
|
119116
119401
|
jsonState.inString = true;
|
|
119117
119402
|
effects.consume(code);
|
|
119118
119403
|
return captureData;
|
|
119119
119404
|
}
|
|
119120
|
-
if (code ===
|
|
119405
|
+
if (code === codes_codes.leftSquareBracket) {
|
|
119121
119406
|
effects.exit('magicBlockData');
|
|
119122
119407
|
effects.enter('magicBlockMarkerEnd');
|
|
119123
119408
|
effects.consume(code);
|
|
@@ -119708,11 +119993,11 @@ function createTokenize(mode) {
|
|
|
119708
119993
|
// When a } brings braceDepth back to a saved value, we return to the
|
|
119709
119994
|
// template literal instead of continuing in the brace expression.
|
|
119710
119995
|
const templateStack = [];
|
|
119711
|
-
const isAlpha = (code) => (code >=
|
|
119712
|
-
(code >=
|
|
119996
|
+
const isAlpha = (code) => (code >= codes_codes.uppercaseA && code <= codes_codes.uppercaseZ) ||
|
|
119997
|
+
(code >= codes_codes.lowercaseA && code <= codes_codes.lowercaseZ);
|
|
119713
119998
|
const isSameCaseAsTag = (code) => isLowercaseTag
|
|
119714
|
-
? code >=
|
|
119715
|
-
: code >=
|
|
119999
|
+
? code >= codes_codes.lowercaseA && code <= codes_codes.lowercaseZ
|
|
120000
|
+
: code >= codes_codes.uppercaseA && code <= codes_codes.uppercaseZ;
|
|
119716
120001
|
// Shared brace-expression state machine. The two call sites differ only in where
|
|
119717
120002
|
// to continue after a line ending and where to return when braceDepth reaches zero.
|
|
119718
120003
|
function createBraceExprStates(continuationStart, afterBraceClose) {
|
|
@@ -119725,22 +120010,22 @@ function createTokenize(mode) {
|
|
|
119725
120010
|
effects.exit('mdxComponentData');
|
|
119726
120011
|
return continuationStart(code);
|
|
119727
120012
|
}
|
|
119728
|
-
if (code ===
|
|
120013
|
+
if (code === codes_codes.quotationMark || code === codes_codes.apostrophe) {
|
|
119729
120014
|
quoteChar = code;
|
|
119730
120015
|
effects.consume(code);
|
|
119731
120016
|
return braceString;
|
|
119732
120017
|
}
|
|
119733
|
-
if (code ===
|
|
120018
|
+
if (code === codes_codes.graveAccent) {
|
|
119734
120019
|
inTemplateLit = true;
|
|
119735
120020
|
effects.consume(code);
|
|
119736
120021
|
return braceTemplateLiteral;
|
|
119737
120022
|
}
|
|
119738
|
-
if (code ===
|
|
120023
|
+
if (code === codes_codes.leftCurlyBrace) {
|
|
119739
120024
|
braceDepth += 1;
|
|
119740
120025
|
effects.consume(code);
|
|
119741
120026
|
return braceExpr;
|
|
119742
120027
|
}
|
|
119743
|
-
if (code ===
|
|
120028
|
+
if (code === codes_codes.rightCurlyBrace) {
|
|
119744
120029
|
braceDepth -= 1;
|
|
119745
120030
|
effects.consume(code);
|
|
119746
120031
|
if (templateStack.length > 0 && braceDepth === templateStack[templateStack.length - 1]) {
|
|
@@ -119765,7 +120050,7 @@ function createTokenize(mode) {
|
|
|
119765
120050
|
effects.exit('mdxComponentData');
|
|
119766
120051
|
return continuationStart(code);
|
|
119767
120052
|
}
|
|
119768
|
-
if (code ===
|
|
120053
|
+
if (code === codes_codes.backslash) {
|
|
119769
120054
|
effects.consume(code);
|
|
119770
120055
|
return braceStringEscape;
|
|
119771
120056
|
}
|
|
@@ -119793,16 +120078,16 @@ function createTokenize(mode) {
|
|
|
119793
120078
|
effects.exit('mdxComponentData');
|
|
119794
120079
|
return continuationStart(code);
|
|
119795
120080
|
}
|
|
119796
|
-
if (code ===
|
|
120081
|
+
if (code === codes_codes.graveAccent) {
|
|
119797
120082
|
inTemplateLit = false;
|
|
119798
120083
|
effects.consume(code);
|
|
119799
120084
|
return braceExpr;
|
|
119800
120085
|
}
|
|
119801
|
-
if (code ===
|
|
120086
|
+
if (code === codes_codes.backslash) {
|
|
119802
120087
|
effects.consume(code);
|
|
119803
120088
|
return braceTemplateLiteralEscape;
|
|
119804
120089
|
}
|
|
119805
|
-
if (code ===
|
|
120090
|
+
if (code === codes_codes.dollarSign) {
|
|
119806
120091
|
effects.consume(code);
|
|
119807
120092
|
return braceTemplateLiteralDollar;
|
|
119808
120093
|
}
|
|
@@ -119817,7 +120102,7 @@ function createTokenize(mode) {
|
|
|
119817
120102
|
return braceTemplateLiteral;
|
|
119818
120103
|
}
|
|
119819
120104
|
function braceTemplateLiteralDollar(code) {
|
|
119820
|
-
if (code ===
|
|
120105
|
+
if (code === codes_codes.leftCurlyBrace) {
|
|
119821
120106
|
templateStack.push(braceDepth);
|
|
119822
120107
|
braceDepth += 1;
|
|
119823
120108
|
inTemplateLit = false;
|
|
@@ -119833,7 +120118,7 @@ function createTokenize(mode) {
|
|
|
119833
120118
|
return start;
|
|
119834
120119
|
// ── Start ──────────────────────────────────────────────────────────────
|
|
119835
120120
|
function start(code) {
|
|
119836
|
-
if (code !==
|
|
120121
|
+
if (code !== codes_codes.lessThan)
|
|
119837
120122
|
return nok(code);
|
|
119838
120123
|
effects.enter('mdxComponent');
|
|
119839
120124
|
effects.enter('mdxComponentData');
|
|
@@ -119845,7 +120130,7 @@ function createTokenize(mode) {
|
|
|
119845
120130
|
// Uppercase A-Z → PascalCase MDX component. Flow mode claims block
|
|
119846
120131
|
// components; text mode only claims inline components (Anchor, Glossary),
|
|
119847
120132
|
// which is enforced once the full name is known in `tagNameRest`.
|
|
119848
|
-
if (code !== null && code >=
|
|
120133
|
+
if (code !== null && code >= codes_codes.uppercaseA && code <= codes_codes.uppercaseZ) {
|
|
119849
120134
|
tagName = String.fromCharCode(code);
|
|
119850
120135
|
isLowercaseTag = false;
|
|
119851
120136
|
sawBraceAttr = false;
|
|
@@ -119855,7 +120140,7 @@ function createTokenize(mode) {
|
|
|
119855
120140
|
// Lowercase a-z → HTML tag (claim only if `{...}` attr appears). In
|
|
119856
120141
|
// flow mode, refuse to interrupt a paragraph — same rule as html-flow
|
|
119857
120142
|
// type-7. The text variant picks these up during inline parsing.
|
|
119858
|
-
if (code !== null && code >=
|
|
120143
|
+
if (code !== null && code >= codes_codes.lowercaseA && code <= codes_codes.lowercaseZ) {
|
|
119859
120144
|
if (isFlow && self.interrupt)
|
|
119860
120145
|
return nok(code);
|
|
119861
120146
|
tagName = String.fromCharCode(code);
|
|
@@ -119868,10 +120153,10 @@ function createTokenize(mode) {
|
|
|
119868
120153
|
}
|
|
119869
120154
|
function tagNameRest(code) {
|
|
119870
120155
|
if (code !== null &&
|
|
119871
|
-
((code >=
|
|
119872
|
-
(code >=
|
|
119873
|
-
(code >=
|
|
119874
|
-
code ===
|
|
120156
|
+
((code >= codes_codes.uppercaseA && code <= codes_codes.uppercaseZ) ||
|
|
120157
|
+
(code >= codes_codes.lowercaseA && code <= codes_codes.lowercaseZ) ||
|
|
120158
|
+
(code >= codes_codes.digit0 && code <= codes_codes.digit9) ||
|
|
120159
|
+
code === codes_codes.underscore)) {
|
|
119875
120160
|
tagName += String.fromCharCode(code);
|
|
119876
120161
|
effects.consume(code);
|
|
119877
120162
|
return tagNameRest;
|
|
@@ -119906,14 +120191,14 @@ function createTokenize(mode) {
|
|
|
119906
120191
|
return openTagContinuationStart(code);
|
|
119907
120192
|
}
|
|
119908
120193
|
// Self-closing />
|
|
119909
|
-
if (code ===
|
|
120194
|
+
if (code === codes_codes.slash) {
|
|
119910
120195
|
if (requiresBraceAttr && !sawBraceAttr)
|
|
119911
120196
|
return nok(code);
|
|
119912
120197
|
effects.consume(code);
|
|
119913
120198
|
return selfCloseGt;
|
|
119914
120199
|
}
|
|
119915
120200
|
// End of opening tag
|
|
119916
|
-
if (code ===
|
|
120201
|
+
if (code === codes_codes.greaterThan) {
|
|
119917
120202
|
if (requiresBraceAttr && !sawBraceAttr) {
|
|
119918
120203
|
// Plain lowercase block tags stay claimable in flow, gated per line by
|
|
119919
120204
|
// `plainClaimLineStart`; everything else falls through to CommonMark.
|
|
@@ -119926,13 +120211,13 @@ function createTokenize(mode) {
|
|
|
119926
120211
|
return body;
|
|
119927
120212
|
}
|
|
119928
120213
|
// Quoted attribute value
|
|
119929
|
-
if (code ===
|
|
120214
|
+
if (code === codes_codes.quotationMark || code === codes_codes.apostrophe) {
|
|
119930
120215
|
quoteChar = code;
|
|
119931
120216
|
effects.consume(code);
|
|
119932
120217
|
return inQuotedAttr;
|
|
119933
120218
|
}
|
|
119934
120219
|
// JSX expression attribute
|
|
119935
|
-
if (code ===
|
|
120220
|
+
if (code === codes_codes.leftCurlyBrace) {
|
|
119936
120221
|
braceDepth = 1;
|
|
119937
120222
|
sawBraceAttr = true;
|
|
119938
120223
|
effects.consume(code);
|
|
@@ -119950,7 +120235,7 @@ function createTokenize(mode) {
|
|
|
119950
120235
|
effects.exit('mdxComponentData');
|
|
119951
120236
|
return openTagContinuationStart(code);
|
|
119952
120237
|
}
|
|
119953
|
-
if (code ===
|
|
120238
|
+
if (code === codes_codes.backslash) {
|
|
119954
120239
|
effects.consume(code);
|
|
119955
120240
|
return inQuotedAttrEscape;
|
|
119956
120241
|
}
|
|
@@ -119970,7 +120255,7 @@ function createTokenize(mode) {
|
|
|
119970
120255
|
return inQuotedAttr;
|
|
119971
120256
|
}
|
|
119972
120257
|
function selfCloseGt(code) {
|
|
119973
|
-
if (code ===
|
|
120258
|
+
if (code === codes_codes.greaterThan) {
|
|
119974
120259
|
effects.consume(code);
|
|
119975
120260
|
// Self-closing tag completes the token
|
|
119976
120261
|
return afterClose;
|
|
@@ -120023,25 +120308,25 @@ function createTokenize(mode) {
|
|
|
120023
120308
|
atLineStart = true;
|
|
120024
120309
|
return bodyContinuationStart(code);
|
|
120025
120310
|
}
|
|
120026
|
-
if (code !==
|
|
120311
|
+
if (code !== codes_codes.space && code !== codes_codes.horizontalTab) {
|
|
120027
120312
|
openerLineHasContent = true;
|
|
120028
120313
|
}
|
|
120029
|
-
if (code ===
|
|
120314
|
+
if (code === codes_codes.backslash) {
|
|
120030
120315
|
effects.consume(code);
|
|
120031
120316
|
return bodyEscapedChar;
|
|
120032
120317
|
}
|
|
120033
|
-
if (code ===
|
|
120318
|
+
if (code === codes_codes.lessThan) {
|
|
120034
120319
|
effects.consume(code);
|
|
120035
120320
|
return bodyLessThan;
|
|
120036
120321
|
}
|
|
120037
120322
|
// Code span tracking
|
|
120038
|
-
if (code ===
|
|
120323
|
+
if (code === codes_codes.graveAccent) {
|
|
120039
120324
|
codeSpanOpenSize = 0;
|
|
120040
120325
|
return countOpenTicks(code);
|
|
120041
120326
|
}
|
|
120042
120327
|
// JSX expression child — track braces/template literals so the closing
|
|
120043
120328
|
// backtick of `{`...`}` is not misread as a code span opener
|
|
120044
|
-
if (code ===
|
|
120329
|
+
if (code === codes_codes.leftCurlyBrace) {
|
|
120045
120330
|
braceDepth = 1;
|
|
120046
120331
|
inTemplateLit = false;
|
|
120047
120332
|
effects.consume(code);
|
|
@@ -120061,14 +120346,14 @@ function createTokenize(mode) {
|
|
|
120061
120346
|
}
|
|
120062
120347
|
// ── Code span handling ─────────────────────────────────────────────────
|
|
120063
120348
|
function countOpenTicks(code) {
|
|
120064
|
-
if (code ===
|
|
120349
|
+
if (code === codes_codes.graveAccent) {
|
|
120065
120350
|
codeSpanOpenSize += 1;
|
|
120066
120351
|
effects.consume(code);
|
|
120067
120352
|
return countOpenTicks;
|
|
120068
120353
|
}
|
|
120069
120354
|
// 3+ backticks at line start = fenced code block
|
|
120070
120355
|
if (atLineStart && codeSpanOpenSize >= 3) {
|
|
120071
|
-
fenceChar =
|
|
120356
|
+
fenceChar = codes_codes.graveAccent;
|
|
120072
120357
|
fenceLength = codeSpanOpenSize;
|
|
120073
120358
|
atLineStart = false;
|
|
120074
120359
|
return inFencedCode(code);
|
|
@@ -120078,7 +120363,7 @@ function createTokenize(mode) {
|
|
|
120078
120363
|
function inCodeSpan(code) {
|
|
120079
120364
|
if (code === null || markdownLineEnding(code))
|
|
120080
120365
|
return body(code);
|
|
120081
|
-
if (code ===
|
|
120366
|
+
if (code === codes_codes.graveAccent) {
|
|
120082
120367
|
codeSpanCloseSize = 0;
|
|
120083
120368
|
return countCloseTicks(code);
|
|
120084
120369
|
}
|
|
@@ -120086,7 +120371,7 @@ function createTokenize(mode) {
|
|
|
120086
120371
|
return inCodeSpan;
|
|
120087
120372
|
}
|
|
120088
120373
|
function countCloseTicks(code) {
|
|
120089
|
-
if (code ===
|
|
120374
|
+
if (code === codes_codes.graveAccent) {
|
|
120090
120375
|
codeSpanCloseSize += 1;
|
|
120091
120376
|
effects.consume(code);
|
|
120092
120377
|
return countCloseTicks;
|
|
@@ -120149,7 +120434,7 @@ function createTokenize(mode) {
|
|
|
120149
120434
|
return body(code);
|
|
120150
120435
|
}
|
|
120151
120436
|
// Only spaces/tabs allowed after closing fence
|
|
120152
|
-
if (code ===
|
|
120437
|
+
if (code === codes_codes.space || code === codes_codes.horizontalTab) {
|
|
120153
120438
|
effects.consume(code);
|
|
120154
120439
|
return fenceCloseTrailing;
|
|
120155
120440
|
}
|
|
@@ -120158,7 +120443,7 @@ function createTokenize(mode) {
|
|
|
120158
120443
|
}
|
|
120159
120444
|
// ── Tilde fenced code detection ────────────────────────────────────────
|
|
120160
120445
|
function bodyAfterLineStart(code) {
|
|
120161
|
-
if (code ===
|
|
120446
|
+
if (code === codes_codes.tilde) {
|
|
120162
120447
|
fenceCloseLength = 1;
|
|
120163
120448
|
effects.consume(code);
|
|
120164
120449
|
return countTildes;
|
|
@@ -120167,13 +120452,13 @@ function createTokenize(mode) {
|
|
|
120167
120452
|
return body(code);
|
|
120168
120453
|
}
|
|
120169
120454
|
function countTildes(code) {
|
|
120170
|
-
if (code ===
|
|
120455
|
+
if (code === codes_codes.tilde) {
|
|
120171
120456
|
fenceCloseLength += 1;
|
|
120172
120457
|
effects.consume(code);
|
|
120173
120458
|
return countTildes;
|
|
120174
120459
|
}
|
|
120175
120460
|
if (fenceCloseLength >= 3) {
|
|
120176
|
-
fenceChar =
|
|
120461
|
+
fenceChar = codes_codes.tilde;
|
|
120177
120462
|
fenceLength = fenceCloseLength;
|
|
120178
120463
|
return inFencedCode(code);
|
|
120179
120464
|
}
|
|
@@ -120183,7 +120468,7 @@ function createTokenize(mode) {
|
|
|
120183
120468
|
}
|
|
120184
120469
|
// ── Tag detection inside body ──────────────────────────────────────────
|
|
120185
120470
|
function bodyLessThan(code) {
|
|
120186
|
-
if (code ===
|
|
120471
|
+
if (code === codes_codes.slash) {
|
|
120187
120472
|
if (onOpenerLine)
|
|
120188
120473
|
openerLineCloses += 1;
|
|
120189
120474
|
effects.consume(code);
|
|
@@ -120210,10 +120495,10 @@ function createTokenize(mode) {
|
|
|
120210
120495
|
// ── Nested opening tag ─────────────────────────────────────────────────
|
|
120211
120496
|
function nestedOpenTagName(code) {
|
|
120212
120497
|
if (code !== null &&
|
|
120213
|
-
((code >=
|
|
120214
|
-
(code >=
|
|
120215
|
-
(code >=
|
|
120216
|
-
code ===
|
|
120498
|
+
((code >= codes_codes.uppercaseA && code <= codes_codes.uppercaseZ) ||
|
|
120499
|
+
(code >= codes_codes.lowercaseA && code <= codes_codes.lowercaseZ) ||
|
|
120500
|
+
(code >= codes_codes.digit0 && code <= codes_codes.digit9) ||
|
|
120501
|
+
code === codes_codes.underscore)) {
|
|
120217
120502
|
closingTagName += String.fromCharCode(code);
|
|
120218
120503
|
effects.consume(code);
|
|
120219
120504
|
return nestedOpenTagName;
|
|
@@ -120221,10 +120506,10 @@ function createTokenize(mode) {
|
|
|
120221
120506
|
// Same-name opener followed by a tag-end char bumps depth. A line ending
|
|
120222
120507
|
// counts too: Prettier puts a newline right after the name (`<div\n …\n>`).
|
|
120223
120508
|
if (closingTagName === tagName &&
|
|
120224
|
-
(code ===
|
|
120225
|
-
code ===
|
|
120226
|
-
code ===
|
|
120227
|
-
code ===
|
|
120509
|
+
(code === codes_codes.greaterThan ||
|
|
120510
|
+
code === codes_codes.slash ||
|
|
120511
|
+
code === codes_codes.space ||
|
|
120512
|
+
code === codes_codes.horizontalTab ||
|
|
120228
120513
|
markdownLineEnding(code))) {
|
|
120229
120514
|
depth += 1;
|
|
120230
120515
|
}
|
|
@@ -120243,15 +120528,15 @@ function createTokenize(mode) {
|
|
|
120243
120528
|
}
|
|
120244
120529
|
function closingTagNameRest(code) {
|
|
120245
120530
|
if (code !== null &&
|
|
120246
|
-
((code >=
|
|
120247
|
-
(code >=
|
|
120248
|
-
(code >=
|
|
120249
|
-
code ===
|
|
120531
|
+
((code >= codes_codes.uppercaseA && code <= codes_codes.uppercaseZ) ||
|
|
120532
|
+
(code >= codes_codes.lowercaseA && code <= codes_codes.lowercaseZ) ||
|
|
120533
|
+
(code >= codes_codes.digit0 && code <= codes_codes.digit9) ||
|
|
120534
|
+
code === codes_codes.underscore)) {
|
|
120250
120535
|
closingTagName += String.fromCharCode(code);
|
|
120251
120536
|
effects.consume(code);
|
|
120252
120537
|
return closingTagNameRest;
|
|
120253
120538
|
}
|
|
120254
|
-
if (closingTagName === tagName && code ===
|
|
120539
|
+
if (closingTagName === tagName && code === codes_codes.greaterThan) {
|
|
120255
120540
|
depth -= 1;
|
|
120256
120541
|
effects.consume(code);
|
|
120257
120542
|
if (depth === 0) {
|
|
@@ -120335,9 +120620,9 @@ function createTokenize(mode) {
|
|
|
120335
120620
|
}
|
|
120336
120621
|
// Dispatch a non-blank continuation line: fenced code at line start, else body.
|
|
120337
120622
|
function bodyLineStart(code) {
|
|
120338
|
-
if (atLineStart && code ===
|
|
120623
|
+
if (atLineStart && code === codes_codes.tilde)
|
|
120339
120624
|
return bodyAfterLineStart(code);
|
|
120340
|
-
if (atLineStart && code ===
|
|
120625
|
+
if (atLineStart && code === codes_codes.graveAccent) {
|
|
120341
120626
|
codeSpanOpenSize = 0;
|
|
120342
120627
|
// Leave `atLineStart` set — `countOpenTicks` needs it to tell a fence from an
|
|
120343
120628
|
// inline code span once the run of backticks is fully counted; it's cleared once
|
|
@@ -120352,7 +120637,7 @@ function createTokenize(mode) {
|
|
|
120352
120637
|
// fence) refuses so CommonMark html-flow reparses it exactly as it does today.
|
|
120353
120638
|
function plainClaimLineStart(code) {
|
|
120354
120639
|
// Leading whitespace only → treat as a blank line, matching CommonMark.
|
|
120355
|
-
if (code ===
|
|
120640
|
+
if (code === codes_codes.space || code === codes_codes.horizontalTab) {
|
|
120356
120641
|
effects.consume(code);
|
|
120357
120642
|
return plainClaimLineStart;
|
|
120358
120643
|
}
|
|
@@ -120365,7 +120650,7 @@ function createTokenize(mode) {
|
|
|
120365
120650
|
// paragraph that merely starts with a tag must fall back so its markdown
|
|
120366
120651
|
// parses and rehype-raw re-nests it into the wrapper.
|
|
120367
120652
|
if (pendingBlankLine) {
|
|
120368
|
-
if (code !==
|
|
120653
|
+
if (code !== codes_codes.lessThan)
|
|
120369
120654
|
return nok(code);
|
|
120370
120655
|
return effects.check(markupOnlyContinuation, plainClaimContinue, nok)(code);
|
|
120371
120656
|
}
|
|
@@ -120418,7 +120703,7 @@ function tokenizeMarkupOnlyContinuation(effects, ok, nok) {
|
|
|
120418
120703
|
return afterLessThan;
|
|
120419
120704
|
}
|
|
120420
120705
|
function afterLessThan(code) {
|
|
120421
|
-
if (code ===
|
|
120706
|
+
if (code === codes_codes.slash) {
|
|
120422
120707
|
effects.consume(code);
|
|
120423
120708
|
return afterSlash;
|
|
120424
120709
|
}
|
|
@@ -120437,7 +120722,7 @@ function tokenizeMarkupOnlyContinuation(effects, ok, nok) {
|
|
|
120437
120722
|
function scanToLineEnd(code) {
|
|
120438
120723
|
if (code === null || markdownLineEnding(code)) {
|
|
120439
120724
|
effects.exit(types_types.data);
|
|
120440
|
-
return lastNonSpace ===
|
|
120725
|
+
return lastNonSpace === codes_codes.greaterThan ? ok(code) : nok(code);
|
|
120441
120726
|
}
|
|
120442
120727
|
if (!markdownSpace(code))
|
|
120443
120728
|
lastNonSpace = code;
|
|
@@ -120470,8 +120755,8 @@ function tokenizeMarkupOnlyContinuation(effects, ok, nok) {
|
|
|
120470
120755
|
*/
|
|
120471
120756
|
function syntax_mdxComponent() {
|
|
120472
120757
|
return {
|
|
120473
|
-
flow: { [
|
|
120474
|
-
text: { [
|
|
120758
|
+
flow: { [codes_codes.lessThan]: [mdxComponentFlowConstruct] },
|
|
120759
|
+
text: { [codes_codes.lessThan]: [mdxComponentTextConstruct] },
|
|
120475
120760
|
};
|
|
120476
120761
|
}
|
|
120477
120762
|
|
|
@@ -120691,6 +120976,7 @@ const mdxishInlineMdxComponents = () => tree => {
|
|
|
120691
120976
|
|
|
120692
120977
|
|
|
120693
120978
|
|
|
120979
|
+
|
|
120694
120980
|
/** Matches a JSX attribute expression (e.g. `key={i}`) anywhere in a string. */
|
|
120695
120981
|
const NESTED_ATTR_EXPRESSION_RE = /[\w-]+\s*=\s*\{/;
|
|
120696
120982
|
/**
|
|
@@ -120734,18 +121020,6 @@ const parseSibling = (stack, parent, index, sibling, safeMode) => {
|
|
|
120734
121020
|
stack.push(parent);
|
|
120735
121021
|
}
|
|
120736
121022
|
};
|
|
120737
|
-
/**
|
|
120738
|
-
* Advance a point by the substring of source consumed from it.
|
|
120739
|
-
*/
|
|
120740
|
-
const pointAfter = (start, consumed) => {
|
|
120741
|
-
const newlineIndex = consumed.lastIndexOf('\n');
|
|
120742
|
-
const newlineCount = newlineIndex === -1 ? 0 : consumed.split('\n').length - 1;
|
|
120743
|
-
return {
|
|
120744
|
-
line: start.line + newlineCount,
|
|
120745
|
-
column: newlineCount === 0 ? start.column + consumed.length : consumed.length - newlineIndex,
|
|
120746
|
-
offset: start.offset + consumed.length,
|
|
120747
|
-
};
|
|
120748
|
-
};
|
|
120749
121023
|
/**
|
|
120750
121024
|
* Build a position ending at `consumedLength` into the html node's value, so the
|
|
120751
121025
|
* component doesn't claim trailing content the tokenizer swallowed into one node.
|
|
@@ -121293,26 +121567,183 @@ const evalExpression = (expression, scope) => {
|
|
|
121293
121567
|
return evalJsxProgram(program, scope);
|
|
121294
121568
|
};
|
|
121295
121569
|
|
|
121296
|
-
;// ./processor/transform/mdxish/
|
|
121570
|
+
;// ./processor/transform/mdxish/style-object-to-css.ts
|
|
121297
121571
|
|
|
121572
|
+
/**
|
|
121573
|
+
* CSS properties React treats as unitless — a bare number stays as-is instead of
|
|
121574
|
+
* getting `px` appended. Mirrors React DOM's `isUnitlessNumber` whitelist.
|
|
121575
|
+
* @see https://github.com/facebook/react/blob/main/packages/react-dom-bindings/src/shared/CSSProperty.js
|
|
121576
|
+
*/
|
|
121577
|
+
const UNITLESS_CSS_PROPERTIES = new Set([
|
|
121578
|
+
'animationIterationCount',
|
|
121579
|
+
'aspectRatio',
|
|
121580
|
+
'borderImageOutset',
|
|
121581
|
+
'borderImageSlice',
|
|
121582
|
+
'borderImageWidth',
|
|
121583
|
+
'boxFlex',
|
|
121584
|
+
'boxFlexGroup',
|
|
121585
|
+
'boxOrdinalGroup',
|
|
121586
|
+
'columnCount',
|
|
121587
|
+
'columns',
|
|
121588
|
+
'flex',
|
|
121589
|
+
'flexGrow',
|
|
121590
|
+
'flexPositive',
|
|
121591
|
+
'flexShrink',
|
|
121592
|
+
'flexNegative',
|
|
121593
|
+
'flexOrder',
|
|
121594
|
+
'gridArea',
|
|
121595
|
+
'gridRow',
|
|
121596
|
+
'gridRowEnd',
|
|
121597
|
+
'gridRowSpan',
|
|
121598
|
+
'gridRowStart',
|
|
121599
|
+
'gridColumn',
|
|
121600
|
+
'gridColumnEnd',
|
|
121601
|
+
'gridColumnSpan',
|
|
121602
|
+
'gridColumnStart',
|
|
121603
|
+
'fontWeight',
|
|
121604
|
+
'lineClamp',
|
|
121605
|
+
'lineHeight',
|
|
121606
|
+
'opacity',
|
|
121607
|
+
'order',
|
|
121608
|
+
'orphans',
|
|
121609
|
+
'tabSize',
|
|
121610
|
+
'widows',
|
|
121611
|
+
'zIndex',
|
|
121612
|
+
'zoom',
|
|
121613
|
+
'fillOpacity',
|
|
121614
|
+
'floodOpacity',
|
|
121615
|
+
'stopOpacity',
|
|
121616
|
+
'strokeDasharray',
|
|
121617
|
+
'strokeDashoffset',
|
|
121618
|
+
'strokeMiterlimit',
|
|
121619
|
+
'strokeOpacity',
|
|
121620
|
+
'strokeWidth',
|
|
121621
|
+
]);
|
|
121622
|
+
/** Convert a camelCase (or CSS custom property) key into its kebab-case CSS name. */
|
|
121623
|
+
const cssPropertyName = (key) => (key.startsWith('--') ? key : key.replace(/[A-Z]/g, m => `-${m.toLowerCase()}`));
|
|
121624
|
+
/** React appends `px` to non-zero numeric values, except unitless and custom properties. */
|
|
121625
|
+
const cssPropertyValue = (key, value) => typeof value === 'number' && value !== 0 && !key.startsWith('--') && !UNITLESS_CSS_PROPERTIES.has(key)
|
|
121626
|
+
? `${value}px`
|
|
121627
|
+
: `${value}`;
|
|
121628
|
+
/**
|
|
121629
|
+
* True for a value that should be serialized as a style object rather than passed through
|
|
121630
|
+
* as an already-CSS string. React elements are excluded since they're valid objects too.
|
|
121631
|
+
*/
|
|
121632
|
+
const style_object_to_css_isPlainObject = (value) => typeof value === 'object' && value !== null && !Array.isArray(value) && !external_react_default().isValidElement(value);
|
|
121633
|
+
/**
|
|
121634
|
+
* Serialize a React-style inline style object (`{ color: "red", fontSize: 12 }`) into a
|
|
121635
|
+
* CSS declaration string (`color:red;font-size:12px`), the shape hast/HTML expects for a
|
|
121636
|
+
* `style` attribute. Empty (`undefined`/`null`/`''`) entries are dropped.
|
|
121637
|
+
*/
|
|
121638
|
+
const styleObjectToCssText = (style) => Object.entries(style)
|
|
121639
|
+
.filter(([, value]) => value !== undefined && value !== null && value !== '')
|
|
121640
|
+
.map(([key, value]) => `${cssPropertyName(key)}:${cssPropertyValue(key, value)}`)
|
|
121641
|
+
.join(';');
|
|
121298
121642
|
|
|
121643
|
+
;// ./processor/transform/mdxish/react-element-to-hast.ts
|
|
121299
121644
|
|
|
121300
121645
|
|
|
121301
|
-
|
|
121302
|
-
|
|
121303
|
-
|
|
121304
|
-
|
|
121305
|
-
|
|
121306
|
-
|
|
121646
|
+
|
|
121647
|
+
// React props that never map to an HTML/hast attribute.
|
|
121648
|
+
const RESERVED_PROPS = new Set(['children', 'key', 'ref']);
|
|
121649
|
+
/**
|
|
121650
|
+
* Translate React props into hast `properties`: reserved and function props (event handlers)
|
|
121651
|
+
* are dropped (known gap), `style` objects flatten to CSS text. Names stay as authored (`className`); the
|
|
121652
|
+
* hast → HTML boundary maps them to `class`/`for` downstream.
|
|
121653
|
+
*/
|
|
121654
|
+
function propsToHastProperties(props) {
|
|
121655
|
+
const properties = {};
|
|
121656
|
+
Object.entries(props).forEach(([key, value]) => {
|
|
121657
|
+
if (RESERVED_PROPS.has(key) || typeof value === 'function' || value === undefined)
|
|
121658
|
+
return;
|
|
121659
|
+
properties[key] = key === 'style' && style_object_to_css_isPlainObject(value) ? styleObjectToCssText(value) : value;
|
|
121660
|
+
});
|
|
121661
|
+
// Values are resolved React props, wider than hast's HTML-attribute `PropertyValue` union.
|
|
121662
|
+
return properties;
|
|
121663
|
+
}
|
|
121664
|
+
/**
|
|
121665
|
+
* Render an element with React's own renderer as a last resort, wrapped as a hast `raw` node —
|
|
121666
|
+
* the same node type markdown's literal HTML blocks produce, so it re-enters rehypeRaw's
|
|
121667
|
+
* parse5 pass normally. Used for element types this converter can't resolve on its own (wrapped
|
|
121668
|
+
* component types, or a function component that throws when called outside React, e.g. one
|
|
121669
|
+
* using hooks). It's not immune to the invalid-HTML-nesting this module otherwise avoids, but
|
|
121670
|
+
* that's a fair trade against silently dropping the content.
|
|
121671
|
+
*/
|
|
121672
|
+
function renderFallbackHtml(element) {
|
|
121673
|
+
try {
|
|
121674
|
+
const rawNode = { type: 'raw', value: (0,server_node/* renderToStaticMarkup */.qV)(element) };
|
|
121675
|
+
return [rawNode];
|
|
121676
|
+
}
|
|
121677
|
+
catch {
|
|
121678
|
+
return [];
|
|
121307
121679
|
}
|
|
121308
|
-
|
|
121309
|
-
|
|
121310
|
-
|
|
121311
|
-
|
|
121680
|
+
}
|
|
121681
|
+
/**
|
|
121682
|
+
* Convert a React element tree into hast. Emitting `mdx-jsx` nodes (rehypeRaw passthrough, later normalized to `element`)
|
|
121683
|
+
* preserves nesting that is valid JSX but not valid HTML, which parse5 would otherwise
|
|
121684
|
+
* restructure — e.g. an `<a>` wrapping another `<a>`.
|
|
121685
|
+
* Recursively converts the tree into an array of hast nodes, dealing with arrays and null/undefined/boolean values.
|
|
121686
|
+
*/
|
|
121687
|
+
function reactElementToHast(node) {
|
|
121688
|
+
if (Array.isArray(node))
|
|
121689
|
+
return node.flatMap(reactElementToHast);
|
|
121690
|
+
if (node === null || node === undefined || typeof node === 'boolean')
|
|
121691
|
+
return [];
|
|
121692
|
+
if (typeof node === 'string' || typeof node === 'number') {
|
|
121693
|
+
const textNode = { type: 'text', value: String(node) };
|
|
121694
|
+
return [textNode];
|
|
121312
121695
|
}
|
|
121313
|
-
|
|
121314
|
-
return
|
|
121696
|
+
if (!external_react_default().isValidElement(node))
|
|
121697
|
+
return [];
|
|
121698
|
+
const { type, props } = node;
|
|
121699
|
+
// Fragments contribute their children with no wrapper element.
|
|
121700
|
+
if (type === (external_react_default()).Fragment)
|
|
121701
|
+
return reactElementToHast(props.children);
|
|
121702
|
+
// Resolve function components to their rendered output so the tree is plain intrinsic
|
|
121703
|
+
// elements. If invoking it directly throws (e.g. it uses hooks, which need React's own
|
|
121704
|
+
// render context), fall back to React's renderer for just this subtree.
|
|
121705
|
+
if (typeof type === 'function') {
|
|
121706
|
+
try {
|
|
121707
|
+
return reactElementToHast(type(props));
|
|
121708
|
+
}
|
|
121709
|
+
catch {
|
|
121710
|
+
return renderFallbackHtml(node);
|
|
121711
|
+
}
|
|
121315
121712
|
}
|
|
121713
|
+
// Non-intrinsic, non-callable element types — `React.memo`, `React.forwardRef`,
|
|
121714
|
+
// `Context.Provider`/`Consumer`, `React.lazy` — have no `type` we can resolve ourselves.
|
|
121715
|
+
if (typeof type !== 'string')
|
|
121716
|
+
return renderFallbackHtml(node);
|
|
121717
|
+
const mdxJsxNode = {
|
|
121718
|
+
type: 'mdx-jsx',
|
|
121719
|
+
tagName: type,
|
|
121720
|
+
properties: propsToHastProperties(props),
|
|
121721
|
+
children: reactElementToHast(props.children),
|
|
121722
|
+
};
|
|
121723
|
+
return [mdxJsxNode];
|
|
121724
|
+
}
|
|
121725
|
+
|
|
121726
|
+
;// ./processor/transform/mdxish/evaluate-expressions.ts
|
|
121727
|
+
|
|
121728
|
+
|
|
121729
|
+
|
|
121730
|
+
|
|
121731
|
+
/**
|
|
121732
|
+
* We divide the result of an expression into two categories:
|
|
121733
|
+
* 1. Renderable values: HTML, JSX, e.g. .map() returning JSX
|
|
121734
|
+
* 2. Non-renderable values: a string, number, or object, regular JS values
|
|
121735
|
+
*/
|
|
121736
|
+
const isRenderable = (value) => {
|
|
121737
|
+
if (external_react_default().isValidElement(value))
|
|
121738
|
+
return true;
|
|
121739
|
+
return Array.isArray(value) && value.some(isRenderable);
|
|
121740
|
+
};
|
|
121741
|
+
/** Turn a non-renderable evaluation result into a text node. */
|
|
121742
|
+
const createTextNode = (result, position) => {
|
|
121743
|
+
if (result === null || result === undefined)
|
|
121744
|
+
return { type: 'text', value: '', position };
|
|
121745
|
+
if (typeof result === 'object')
|
|
121746
|
+
return { type: 'text', value: JSON.stringify(result), position };
|
|
121316
121747
|
return { type: 'text', value: String(result), position };
|
|
121317
121748
|
};
|
|
121318
121749
|
/**
|
|
@@ -121328,13 +121759,23 @@ const evaluateExpressions = () => (tree, file) => {
|
|
|
121328
121759
|
lib_visit(tree, ['mdxFlowExpression', 'mdxTextExpression'], (node, index, parent) => {
|
|
121329
121760
|
if (!parent || index === null || index === undefined)
|
|
121330
121761
|
return;
|
|
121331
|
-
const
|
|
121762
|
+
const expressionNode = node;
|
|
121763
|
+
const { value, position } = expressionNode;
|
|
121332
121764
|
const expression = value?.trim();
|
|
121333
121765
|
if (!expression)
|
|
121334
121766
|
return;
|
|
121335
121767
|
try {
|
|
121336
121768
|
const result = evalExpression(expression, scope);
|
|
121337
|
-
|
|
121769
|
+
if (isRenderable(result)) {
|
|
121770
|
+
// Stash hast built straight from the React tree; `mdxExpressionHandler` emits it and it
|
|
121771
|
+
// passes through rehypeRaw/parse5 step later in the pipeline. This ensures that the
|
|
121772
|
+
// expression result is not parsed by parse5 and fragmenting the nesting that is valid JSX
|
|
121773
|
+
// but invalid HTML — e.g. an `<a>` wrapping `<a>`.
|
|
121774
|
+
expressionNode.data = { ...expressionNode.data, hChildren: reactElementToHast(result) };
|
|
121775
|
+
}
|
|
121776
|
+
else {
|
|
121777
|
+
parent.children.splice(index, 1, createTextNode(result, position));
|
|
121778
|
+
}
|
|
121338
121779
|
}
|
|
121339
121780
|
catch (_error) {
|
|
121340
121781
|
// Evaluation failed — fall back to literal `{...}` text. The expression
|
|
@@ -122931,21 +123372,21 @@ function resolveEntity(name) {
|
|
|
122931
123372
|
function tokenizeLooseHtmlEntity(effects, ok, nok) {
|
|
122932
123373
|
let length = 0;
|
|
122933
123374
|
const start = (code) => {
|
|
122934
|
-
if (code !==
|
|
123375
|
+
if (code !== codes_codes.ampersand)
|
|
122935
123376
|
return nok(code);
|
|
122936
123377
|
effects.enter('looseHtmlEntity');
|
|
122937
123378
|
effects.consume(code);
|
|
122938
123379
|
return afterAmpersand;
|
|
122939
123380
|
};
|
|
122940
123381
|
const afterAmpersand = (code) => {
|
|
122941
|
-
if (code ===
|
|
123382
|
+
if (code === codes_codes.numberSign) {
|
|
122942
123383
|
effects.consume(code);
|
|
122943
123384
|
return afterHash;
|
|
122944
123385
|
}
|
|
122945
123386
|
return accumulateNamed(code);
|
|
122946
123387
|
};
|
|
122947
123388
|
const afterHash = (code) => {
|
|
122948
|
-
if (code ===
|
|
123389
|
+
if (code === codes_codes.lowercaseX || code === codes_codes.uppercaseX) {
|
|
122949
123390
|
effects.consume(code);
|
|
122950
123391
|
return accumulateHex;
|
|
122951
123392
|
}
|
|
@@ -122959,7 +123400,7 @@ function tokenizeLooseHtmlEntity(effects, ok, nok) {
|
|
|
122959
123400
|
}
|
|
122960
123401
|
if (length === 0)
|
|
122961
123402
|
return nok(code);
|
|
122962
|
-
if (code ===
|
|
123403
|
+
if (code === codes_codes.semicolon)
|
|
122963
123404
|
return nok(code);
|
|
122964
123405
|
effects.exit('looseHtmlEntity');
|
|
122965
123406
|
return ok(code);
|
|
@@ -122972,7 +123413,7 @@ function tokenizeLooseHtmlEntity(effects, ok, nok) {
|
|
|
122972
123413
|
}
|
|
122973
123414
|
if (length === 0)
|
|
122974
123415
|
return nok(code);
|
|
122975
|
-
if (code ===
|
|
123416
|
+
if (code === codes_codes.semicolon)
|
|
122976
123417
|
return nok(code);
|
|
122977
123418
|
effects.exit('looseHtmlEntity');
|
|
122978
123419
|
return ok(code);
|
|
@@ -122985,7 +123426,7 @@ function tokenizeLooseHtmlEntity(effects, ok, nok) {
|
|
|
122985
123426
|
}
|
|
122986
123427
|
if (length === 0)
|
|
122987
123428
|
return nok(code);
|
|
122988
|
-
if (code ===
|
|
123429
|
+
if (code === codes_codes.semicolon)
|
|
122989
123430
|
return nok(code);
|
|
122990
123431
|
effects.exit('looseHtmlEntity');
|
|
122991
123432
|
return ok(code);
|
|
@@ -123020,7 +123461,7 @@ function exitLooseHtmlEntity(token) {
|
|
|
123020
123461
|
}
|
|
123021
123462
|
function looseHtmlEntity() {
|
|
123022
123463
|
return {
|
|
123023
|
-
text: { [
|
|
123464
|
+
text: { [codes_codes.ampersand]: looseHtmlEntityConstruct },
|
|
123024
123465
|
};
|
|
123025
123466
|
}
|
|
123026
123467
|
function looseHtmlEntityFromMarkdown() {
|
|
@@ -124665,79 +125106,6 @@ function removeJSXComments(content) {
|
|
|
124665
125106
|
return content.replace(JSX_COMMENT_REGEX, '');
|
|
124666
125107
|
}
|
|
124667
125108
|
|
|
124668
|
-
;// ./processor/transform/mdxish/style-object-to-css.ts
|
|
124669
|
-
|
|
124670
|
-
/**
|
|
124671
|
-
* CSS properties React treats as unitless — a bare number stays as-is instead of
|
|
124672
|
-
* getting `px` appended. Mirrors React DOM's `isUnitlessNumber` whitelist.
|
|
124673
|
-
* @see https://github.com/facebook/react/blob/main/packages/react-dom-bindings/src/shared/CSSProperty.js
|
|
124674
|
-
*/
|
|
124675
|
-
const UNITLESS_CSS_PROPERTIES = new Set([
|
|
124676
|
-
'animationIterationCount',
|
|
124677
|
-
'aspectRatio',
|
|
124678
|
-
'borderImageOutset',
|
|
124679
|
-
'borderImageSlice',
|
|
124680
|
-
'borderImageWidth',
|
|
124681
|
-
'boxFlex',
|
|
124682
|
-
'boxFlexGroup',
|
|
124683
|
-
'boxOrdinalGroup',
|
|
124684
|
-
'columnCount',
|
|
124685
|
-
'columns',
|
|
124686
|
-
'flex',
|
|
124687
|
-
'flexGrow',
|
|
124688
|
-
'flexPositive',
|
|
124689
|
-
'flexShrink',
|
|
124690
|
-
'flexNegative',
|
|
124691
|
-
'flexOrder',
|
|
124692
|
-
'gridArea',
|
|
124693
|
-
'gridRow',
|
|
124694
|
-
'gridRowEnd',
|
|
124695
|
-
'gridRowSpan',
|
|
124696
|
-
'gridRowStart',
|
|
124697
|
-
'gridColumn',
|
|
124698
|
-
'gridColumnEnd',
|
|
124699
|
-
'gridColumnSpan',
|
|
124700
|
-
'gridColumnStart',
|
|
124701
|
-
'fontWeight',
|
|
124702
|
-
'lineClamp',
|
|
124703
|
-
'lineHeight',
|
|
124704
|
-
'opacity',
|
|
124705
|
-
'order',
|
|
124706
|
-
'orphans',
|
|
124707
|
-
'tabSize',
|
|
124708
|
-
'widows',
|
|
124709
|
-
'zIndex',
|
|
124710
|
-
'zoom',
|
|
124711
|
-
'fillOpacity',
|
|
124712
|
-
'floodOpacity',
|
|
124713
|
-
'stopOpacity',
|
|
124714
|
-
'strokeDasharray',
|
|
124715
|
-
'strokeDashoffset',
|
|
124716
|
-
'strokeMiterlimit',
|
|
124717
|
-
'strokeOpacity',
|
|
124718
|
-
'strokeWidth',
|
|
124719
|
-
]);
|
|
124720
|
-
/** Convert a camelCase (or CSS custom property) key into its kebab-case CSS name. */
|
|
124721
|
-
const cssPropertyName = (key) => (key.startsWith('--') ? key : key.replace(/[A-Z]/g, m => `-${m.toLowerCase()}`));
|
|
124722
|
-
/** React appends `px` to non-zero numeric values, except unitless and custom properties. */
|
|
124723
|
-
const cssPropertyValue = (key, value) => typeof value === 'number' && value !== 0 && !key.startsWith('--') && !UNITLESS_CSS_PROPERTIES.has(key)
|
|
124724
|
-
? `${value}px`
|
|
124725
|
-
: `${value}`;
|
|
124726
|
-
/**
|
|
124727
|
-
* True for a value that should be serialized as a style object rather than passed through
|
|
124728
|
-
* as an already-CSS string. React elements are excluded since they're valid objects too.
|
|
124729
|
-
*/
|
|
124730
|
-
const style_object_to_css_isPlainObject = (value) => typeof value === 'object' && value !== null && !Array.isArray(value) && !external_react_default().isValidElement(value);
|
|
124731
|
-
/**
|
|
124732
|
-
* Serialize a React-style inline style object (`{ color: "red", fontSize: 12 }`) into a
|
|
124733
|
-
* CSS declaration string (`color:red;font-size:12px`), the shape hast/HTML expects for a
|
|
124734
|
-
* `style` attribute. Empty (`undefined`/`null`/`''`) entries are dropped.
|
|
124735
|
-
*/
|
|
124736
|
-
const styleObjectToCssText = (style) => Object.entries(style)
|
|
124737
|
-
.filter(([, value]) => value !== undefined && value !== null && value !== '')
|
|
124738
|
-
.map(([key, value]) => `${cssPropertyName(key)}:${cssPropertyValue(key, value)}`)
|
|
124739
|
-
.join(';');
|
|
124740
|
-
|
|
124741
125109
|
;// ./processor/transform/mdxish/resolve-deferred-attribute-expression-props.ts
|
|
124742
125110
|
|
|
124743
125111
|
|
|
@@ -125377,7 +125745,7 @@ function jsx_table_jsxTableFromMarkdown() {
|
|
|
125377
125745
|
function tokenizeJsxComment(effects, ok, nok) {
|
|
125378
125746
|
return start;
|
|
125379
125747
|
function start(code) {
|
|
125380
|
-
if (code !==
|
|
125748
|
+
if (code !== codes_codes.leftCurlyBrace)
|
|
125381
125749
|
return nok(code);
|
|
125382
125750
|
effects.enter('mdxFlowExpression');
|
|
125383
125751
|
effects.enter('mdxFlowExpressionMarker');
|
|
@@ -125386,7 +125754,7 @@ function tokenizeJsxComment(effects, ok, nok) {
|
|
|
125386
125754
|
return expectSlash;
|
|
125387
125755
|
}
|
|
125388
125756
|
function expectSlash(code) {
|
|
125389
|
-
if (code !==
|
|
125757
|
+
if (code !== codes_codes.slash) {
|
|
125390
125758
|
effects.exit('mdxFlowExpression');
|
|
125391
125759
|
return nok(code);
|
|
125392
125760
|
}
|
|
@@ -125395,7 +125763,7 @@ function tokenizeJsxComment(effects, ok, nok) {
|
|
|
125395
125763
|
return expectStar;
|
|
125396
125764
|
}
|
|
125397
125765
|
function expectStar(code) {
|
|
125398
|
-
if (code !==
|
|
125766
|
+
if (code !== codes_codes.asterisk) {
|
|
125399
125767
|
effects.exit('mdxFlowExpressionChunk');
|
|
125400
125768
|
effects.exit('mdxFlowExpression');
|
|
125401
125769
|
return nok(code);
|
|
@@ -125422,7 +125790,7 @@ function tokenizeJsxComment(effects, ok, nok) {
|
|
|
125422
125790
|
effects.exit('mdxFlowExpressionChunk');
|
|
125423
125791
|
return before(code);
|
|
125424
125792
|
}
|
|
125425
|
-
if (code ===
|
|
125793
|
+
if (code === codes_codes.asterisk) {
|
|
125426
125794
|
effects.consume(code);
|
|
125427
125795
|
return maybeClosed;
|
|
125428
125796
|
}
|
|
@@ -125434,11 +125802,11 @@ function tokenizeJsxComment(effects, ok, nok) {
|
|
|
125434
125802
|
effects.exit('mdxFlowExpressionChunk');
|
|
125435
125803
|
return before(code);
|
|
125436
125804
|
}
|
|
125437
|
-
if (code ===
|
|
125805
|
+
if (code === codes_codes.slash) {
|
|
125438
125806
|
effects.consume(code);
|
|
125439
125807
|
return expectClosingBrace;
|
|
125440
125808
|
}
|
|
125441
|
-
if (code ===
|
|
125809
|
+
if (code === codes_codes.asterisk) {
|
|
125442
125810
|
effects.consume(code);
|
|
125443
125811
|
return maybeClosed;
|
|
125444
125812
|
}
|
|
@@ -125450,7 +125818,7 @@ function tokenizeJsxComment(effects, ok, nok) {
|
|
|
125450
125818
|
effects.exit('mdxFlowExpressionChunk');
|
|
125451
125819
|
return before(code);
|
|
125452
125820
|
}
|
|
125453
|
-
if (code ===
|
|
125821
|
+
if (code === codes_codes.rightCurlyBrace) {
|
|
125454
125822
|
effects.exit('mdxFlowExpressionChunk');
|
|
125455
125823
|
effects.enter('mdxFlowExpressionMarker');
|
|
125456
125824
|
effects.consume(code);
|
|
@@ -125458,7 +125826,7 @@ function tokenizeJsxComment(effects, ok, nok) {
|
|
|
125458
125826
|
effects.exit('mdxFlowExpression');
|
|
125459
125827
|
return ok;
|
|
125460
125828
|
}
|
|
125461
|
-
if (code ===
|
|
125829
|
+
if (code === codes_codes.asterisk) {
|
|
125462
125830
|
effects.consume(code);
|
|
125463
125831
|
return maybeClosed;
|
|
125464
125832
|
}
|
|
@@ -125469,7 +125837,7 @@ function tokenizeJsxComment(effects, ok, nok) {
|
|
|
125469
125837
|
function jsxComment() {
|
|
125470
125838
|
return {
|
|
125471
125839
|
flow: {
|
|
125472
|
-
[
|
|
125840
|
+
[codes_codes.leftCurlyBrace]: {
|
|
125473
125841
|
name: 'jsxComment',
|
|
125474
125842
|
concrete: true,
|
|
125475
125843
|
tokenize: tokenizeJsxComment,
|
|
@@ -125510,7 +125878,7 @@ function tokenizeJsxTable(effects, ok, nok) {
|
|
|
125510
125878
|
let codeSpanOpenSize = 0;
|
|
125511
125879
|
let codeSpanCloseSize = 0;
|
|
125512
125880
|
let depth = 1;
|
|
125513
|
-
const ABLE_SUFFIX = [
|
|
125881
|
+
const ABLE_SUFFIX = [codes_codes.lowercaseA, codes_codes.lowercaseB, codes_codes.lowercaseL, codes_codes.lowercaseE];
|
|
125514
125882
|
/** Build a state chain that matches a sequence of character codes. */
|
|
125515
125883
|
function matchChars(chars, onMatch, onFail) {
|
|
125516
125884
|
if (chars.length === 0)
|
|
@@ -125525,7 +125893,7 @@ function tokenizeJsxTable(effects, ok, nok) {
|
|
|
125525
125893
|
}
|
|
125526
125894
|
return start;
|
|
125527
125895
|
function start(code) {
|
|
125528
|
-
if (code !==
|
|
125896
|
+
if (code !== codes_codes.lessThan)
|
|
125529
125897
|
return nok(code);
|
|
125530
125898
|
effects.enter('jsxTable');
|
|
125531
125899
|
effects.enter('jsxTableData');
|
|
@@ -125533,14 +125901,14 @@ function tokenizeJsxTable(effects, ok, nok) {
|
|
|
125533
125901
|
return afterLessThan;
|
|
125534
125902
|
}
|
|
125535
125903
|
function afterLessThan(code) {
|
|
125536
|
-
if (code ===
|
|
125904
|
+
if (code === codes_codes.uppercaseT || code === codes_codes.lowercaseT) {
|
|
125537
125905
|
effects.consume(code);
|
|
125538
125906
|
return matchChars(ABLE_SUFFIX, afterTagName, nok);
|
|
125539
125907
|
}
|
|
125540
125908
|
return nok(code);
|
|
125541
125909
|
}
|
|
125542
125910
|
function afterTagName(code) {
|
|
125543
|
-
if (code ===
|
|
125911
|
+
if (code === codes_codes.greaterThan || code === codes_codes.slash || code === codes_codes.space || code === codes_codes.horizontalTab) {
|
|
125544
125912
|
effects.consume(code);
|
|
125545
125913
|
return body;
|
|
125546
125914
|
}
|
|
@@ -125556,17 +125924,17 @@ function tokenizeJsxTable(effects, ok, nok) {
|
|
|
125556
125924
|
effects.exit('jsxTableData');
|
|
125557
125925
|
return continuationStart(code);
|
|
125558
125926
|
}
|
|
125559
|
-
if (code ===
|
|
125927
|
+
if (code === codes_codes.backslash) {
|
|
125560
125928
|
effects.consume(code);
|
|
125561
125929
|
return escapedChar;
|
|
125562
125930
|
}
|
|
125563
|
-
if (code ===
|
|
125931
|
+
if (code === codes_codes.lessThan) {
|
|
125564
125932
|
effects.consume(code);
|
|
125565
125933
|
return closeSlash;
|
|
125566
125934
|
}
|
|
125567
125935
|
// Skip over backtick code spans so `</Table>` in inline code isn't
|
|
125568
125936
|
// treated as the closing tag
|
|
125569
|
-
if (code ===
|
|
125937
|
+
if (code === codes_codes.graveAccent) {
|
|
125570
125938
|
codeSpanOpenSize = 0;
|
|
125571
125939
|
return countOpenTicks(code);
|
|
125572
125940
|
}
|
|
@@ -125574,7 +125942,7 @@ function tokenizeJsxTable(effects, ok, nok) {
|
|
|
125574
125942
|
return body;
|
|
125575
125943
|
}
|
|
125576
125944
|
function countOpenTicks(code) {
|
|
125577
|
-
if (code ===
|
|
125945
|
+
if (code === codes_codes.graveAccent) {
|
|
125578
125946
|
codeSpanOpenSize += 1;
|
|
125579
125947
|
effects.consume(code);
|
|
125580
125948
|
return countOpenTicks;
|
|
@@ -125584,7 +125952,7 @@ function tokenizeJsxTable(effects, ok, nok) {
|
|
|
125584
125952
|
function inCodeSpan(code) {
|
|
125585
125953
|
if (code === null || markdownLineEnding(code))
|
|
125586
125954
|
return body(code);
|
|
125587
|
-
if (code ===
|
|
125955
|
+
if (code === codes_codes.graveAccent) {
|
|
125588
125956
|
codeSpanCloseSize = 0;
|
|
125589
125957
|
return countCloseTicks(code);
|
|
125590
125958
|
}
|
|
@@ -125592,7 +125960,7 @@ function tokenizeJsxTable(effects, ok, nok) {
|
|
|
125592
125960
|
return inCodeSpan;
|
|
125593
125961
|
}
|
|
125594
125962
|
function countCloseTicks(code) {
|
|
125595
|
-
if (code ===
|
|
125963
|
+
if (code === codes_codes.graveAccent) {
|
|
125596
125964
|
codeSpanCloseSize += 1;
|
|
125597
125965
|
effects.consume(code);
|
|
125598
125966
|
return countCloseTicks;
|
|
@@ -125607,25 +125975,25 @@ function tokenizeJsxTable(effects, ok, nok) {
|
|
|
125607
125975
|
return body;
|
|
125608
125976
|
}
|
|
125609
125977
|
function closeSlash(code) {
|
|
125610
|
-
if (code ===
|
|
125978
|
+
if (code === codes_codes.slash) {
|
|
125611
125979
|
effects.consume(code);
|
|
125612
125980
|
return closeTagFirstChar;
|
|
125613
125981
|
}
|
|
125614
|
-
if (code ===
|
|
125982
|
+
if (code === codes_codes.uppercaseT || code === codes_codes.lowercaseT) {
|
|
125615
125983
|
effects.consume(code);
|
|
125616
125984
|
return matchChars(ABLE_SUFFIX, openAfterTagName, body);
|
|
125617
125985
|
}
|
|
125618
125986
|
return body(code);
|
|
125619
125987
|
}
|
|
125620
125988
|
function closeTagFirstChar(code) {
|
|
125621
|
-
if (code ===
|
|
125989
|
+
if (code === codes_codes.uppercaseT || code === codes_codes.lowercaseT) {
|
|
125622
125990
|
effects.consume(code);
|
|
125623
125991
|
return matchChars(ABLE_SUFFIX, closeGt, body);
|
|
125624
125992
|
}
|
|
125625
125993
|
return body(code);
|
|
125626
125994
|
}
|
|
125627
125995
|
function openAfterTagName(code) {
|
|
125628
|
-
if (code ===
|
|
125996
|
+
if (code === codes_codes.greaterThan || code === codes_codes.slash || code === codes_codes.space || code === codes_codes.horizontalTab) {
|
|
125629
125997
|
depth += 1;
|
|
125630
125998
|
effects.consume(code);
|
|
125631
125999
|
return body;
|
|
@@ -125633,7 +126001,7 @@ function tokenizeJsxTable(effects, ok, nok) {
|
|
|
125633
126001
|
return body(code);
|
|
125634
126002
|
}
|
|
125635
126003
|
function closeGt(code) {
|
|
125636
|
-
if (code ===
|
|
126004
|
+
if (code === codes_codes.greaterThan) {
|
|
125637
126005
|
depth -= 1;
|
|
125638
126006
|
effects.consume(code);
|
|
125639
126007
|
if (depth === 0) {
|
|
@@ -125707,7 +126075,7 @@ function jsx_table_syntax_tokenizeNonLazyContinuationStart(effects, ok, nok) {
|
|
|
125707
126075
|
function syntax_jsxTable() {
|
|
125708
126076
|
return {
|
|
125709
126077
|
flow: {
|
|
125710
|
-
[
|
|
126078
|
+
[codes_codes.lessThan]: [jsxTableConstruct],
|
|
125711
126079
|
},
|
|
125712
126080
|
};
|
|
125713
126081
|
}
|
|
@@ -125734,7 +126102,7 @@ function tokenizeTextExpression(effects, ok, nok) {
|
|
|
125734
126102
|
let depth = 0;
|
|
125735
126103
|
return start;
|
|
125736
126104
|
function start(code) {
|
|
125737
|
-
if (code !==
|
|
126105
|
+
if (code !== codes_codes.leftCurlyBrace)
|
|
125738
126106
|
return nok(code);
|
|
125739
126107
|
effects.enter('mdxTextExpression');
|
|
125740
126108
|
effects.enter('mdxTextExpressionMarker');
|
|
@@ -125743,7 +126111,7 @@ function tokenizeTextExpression(effects, ok, nok) {
|
|
|
125743
126111
|
return before;
|
|
125744
126112
|
}
|
|
125745
126113
|
function before(code) {
|
|
125746
|
-
if (code ===
|
|
126114
|
+
if (code === codes_codes.eof) {
|
|
125747
126115
|
effects.exit('mdxTextExpression');
|
|
125748
126116
|
return nok(code);
|
|
125749
126117
|
}
|
|
@@ -125753,24 +126121,24 @@ function tokenizeTextExpression(effects, ok, nok) {
|
|
|
125753
126121
|
effects.exit('lineEnding');
|
|
125754
126122
|
return before;
|
|
125755
126123
|
}
|
|
125756
|
-
if (code ===
|
|
126124
|
+
if (code === codes_codes.rightCurlyBrace && depth === 0) {
|
|
125757
126125
|
return close(code);
|
|
125758
126126
|
}
|
|
125759
126127
|
effects.enter('mdxTextExpressionChunk');
|
|
125760
126128
|
return inside(code);
|
|
125761
126129
|
}
|
|
125762
126130
|
function inside(code) {
|
|
125763
|
-
if (code ===
|
|
126131
|
+
if (code === codes_codes.eof || markdownLineEnding(code)) {
|
|
125764
126132
|
effects.exit('mdxTextExpressionChunk');
|
|
125765
126133
|
return before(code);
|
|
125766
126134
|
}
|
|
125767
|
-
if (code ===
|
|
126135
|
+
if (code === codes_codes.rightCurlyBrace && depth === 0) {
|
|
125768
126136
|
effects.exit('mdxTextExpressionChunk');
|
|
125769
126137
|
return close(code);
|
|
125770
126138
|
}
|
|
125771
|
-
if (code ===
|
|
126139
|
+
if (code === codes_codes.leftCurlyBrace)
|
|
125772
126140
|
depth += 1;
|
|
125773
|
-
else if (code ===
|
|
126141
|
+
else if (code === codes_codes.rightCurlyBrace)
|
|
125774
126142
|
depth -= 1;
|
|
125775
126143
|
effects.consume(code);
|
|
125776
126144
|
return inside;
|
|
@@ -125786,7 +126154,7 @@ function tokenizeTextExpression(effects, ok, nok) {
|
|
|
125786
126154
|
function mdxExpressionLenient() {
|
|
125787
126155
|
return {
|
|
125788
126156
|
text: {
|
|
125789
|
-
[
|
|
126157
|
+
[codes_codes.leftCurlyBrace]: {
|
|
125790
126158
|
name: 'mdxTextExpression',
|
|
125791
126159
|
tokenize: tokenizeTextExpression,
|
|
125792
126160
|
},
|
|
@@ -126500,6 +126868,332 @@ const mdxishTags_tags = (doc) => {
|
|
|
126500
126868
|
};
|
|
126501
126869
|
/* harmony default export */ const mdxishTags = ((/* unused pure expression or super */ null && (mdxishTags_tags)));
|
|
126502
126870
|
|
|
126871
|
+
;// ./lib/mdast-util/html-block-component/index.ts
|
|
126872
|
+
const html_block_component_contextMap = new WeakMap();
|
|
126873
|
+
function findHtmlBlockComponentToken() {
|
|
126874
|
+
const events = this.tokenStack;
|
|
126875
|
+
for (let i = events.length - 1; i >= 0; i -= 1) {
|
|
126876
|
+
if (events[i][0].type === 'htmlBlockComponent')
|
|
126877
|
+
return events[i][0];
|
|
126878
|
+
}
|
|
126879
|
+
return undefined;
|
|
126880
|
+
}
|
|
126881
|
+
function enterHtmlBlockComponent(token) {
|
|
126882
|
+
html_block_component_contextMap.set(token, { chunks: [], lastEndLine: token.start.line });
|
|
126883
|
+
this.enter({ type: 'html', value: '' }, token);
|
|
126884
|
+
}
|
|
126885
|
+
function exitHtmlBlockComponentData(token) {
|
|
126886
|
+
const componentToken = findHtmlBlockComponentToken.call(this);
|
|
126887
|
+
if (!componentToken)
|
|
126888
|
+
return;
|
|
126889
|
+
const ctx = html_block_component_contextMap.get(componentToken);
|
|
126890
|
+
if (ctx) {
|
|
126891
|
+
const gap = token.start.line - ctx.lastEndLine;
|
|
126892
|
+
if (ctx.chunks.length > 0 && gap > 0) {
|
|
126893
|
+
ctx.chunks.push('\n'.repeat(gap));
|
|
126894
|
+
}
|
|
126895
|
+
ctx.chunks.push(this.sliceSerialize(token));
|
|
126896
|
+
ctx.lastEndLine = token.end.line;
|
|
126897
|
+
}
|
|
126898
|
+
}
|
|
126899
|
+
function exitHtmlBlockComponent(token) {
|
|
126900
|
+
const ctx = html_block_component_contextMap.get(token);
|
|
126901
|
+
const node = this.stack[this.stack.length - 1];
|
|
126902
|
+
if (ctx) {
|
|
126903
|
+
node.value = ctx.chunks.join('');
|
|
126904
|
+
html_block_component_contextMap.delete(token);
|
|
126905
|
+
}
|
|
126906
|
+
this.exit(token);
|
|
126907
|
+
}
|
|
126908
|
+
function html_block_component_htmlBlockComponentFromMarkdown() {
|
|
126909
|
+
return {
|
|
126910
|
+
enter: {
|
|
126911
|
+
htmlBlockComponent: enterHtmlBlockComponent,
|
|
126912
|
+
},
|
|
126913
|
+
exit: {
|
|
126914
|
+
htmlBlockComponentData: exitHtmlBlockComponentData,
|
|
126915
|
+
htmlBlockComponent: exitHtmlBlockComponent,
|
|
126916
|
+
},
|
|
126917
|
+
};
|
|
126918
|
+
}
|
|
126919
|
+
|
|
126920
|
+
;// ./lib/micromark/html-block-component/syntax.ts
|
|
126921
|
+
|
|
126922
|
+
|
|
126923
|
+
const TAG_SUFFIX = [
|
|
126924
|
+
codes_codes.uppercaseT,
|
|
126925
|
+
codes_codes.uppercaseM,
|
|
126926
|
+
codes_codes.uppercaseL,
|
|
126927
|
+
codes_codes.uppercaseB,
|
|
126928
|
+
codes_codes.lowercaseL,
|
|
126929
|
+
codes_codes.lowercaseO,
|
|
126930
|
+
codes_codes.lowercaseC,
|
|
126931
|
+
codes_codes.lowercaseK,
|
|
126932
|
+
];
|
|
126933
|
+
// ---------------------------------------------------------------------------
|
|
126934
|
+
// Shared tokenizer factory
|
|
126935
|
+
// ---------------------------------------------------------------------------
|
|
126936
|
+
/**
|
|
126937
|
+
* Creates a tokenize function for `<HTMLBlock>...</HTMLBlock>`.
|
|
126938
|
+
*
|
|
126939
|
+
* - **flow** (block-level): supports multiline content via line continuations,
|
|
126940
|
+
* consumes trailing whitespace after the closing tag.
|
|
126941
|
+
* - **text** (inline): single-line only, exits immediately after the closing tag.
|
|
126942
|
+
*/
|
|
126943
|
+
function syntax_createTokenize(mode) {
|
|
126944
|
+
return function tokenize(effects, ok, nok) {
|
|
126945
|
+
let depth = 1;
|
|
126946
|
+
function matchChars(chars, onMatch, onFail) {
|
|
126947
|
+
if (chars.length === 0)
|
|
126948
|
+
return onMatch;
|
|
126949
|
+
const next = (code) => {
|
|
126950
|
+
if (code === chars[0]) {
|
|
126951
|
+
effects.consume(code);
|
|
126952
|
+
return matchChars(chars.slice(1), onMatch, onFail);
|
|
126953
|
+
}
|
|
126954
|
+
return onFail(code);
|
|
126955
|
+
};
|
|
126956
|
+
return next;
|
|
126957
|
+
}
|
|
126958
|
+
function matchTagName(onMatch, onFail) {
|
|
126959
|
+
const next = (code) => {
|
|
126960
|
+
if (code === codes_codes.uppercaseH) {
|
|
126961
|
+
effects.consume(code);
|
|
126962
|
+
return matchChars(TAG_SUFFIX, onMatch, onFail);
|
|
126963
|
+
}
|
|
126964
|
+
return onFail(code);
|
|
126965
|
+
};
|
|
126966
|
+
return next;
|
|
126967
|
+
}
|
|
126968
|
+
return start;
|
|
126969
|
+
function start(code) {
|
|
126970
|
+
if (code !== codes_codes.lessThan)
|
|
126971
|
+
return nok(code);
|
|
126972
|
+
effects.enter('htmlBlockComponent');
|
|
126973
|
+
effects.enter('htmlBlockComponentData');
|
|
126974
|
+
effects.consume(code);
|
|
126975
|
+
return matchTagName(afterTagName, nok);
|
|
126976
|
+
}
|
|
126977
|
+
function afterTagName(code) {
|
|
126978
|
+
if (code === codes_codes.greaterThan) {
|
|
126979
|
+
effects.consume(code);
|
|
126980
|
+
return body;
|
|
126981
|
+
}
|
|
126982
|
+
if (code === codes_codes.space || code === codes_codes.horizontalTab) {
|
|
126983
|
+
effects.consume(code);
|
|
126984
|
+
return inAttributes;
|
|
126985
|
+
}
|
|
126986
|
+
if (mode === 'flow' && markdownLineEnding(code)) {
|
|
126987
|
+
effects.exit('htmlBlockComponentData');
|
|
126988
|
+
return attributeContinuationStart(code);
|
|
126989
|
+
}
|
|
126990
|
+
if (code === codes_codes.slash) {
|
|
126991
|
+
effects.consume(code);
|
|
126992
|
+
return selfClose;
|
|
126993
|
+
}
|
|
126994
|
+
return nok(code);
|
|
126995
|
+
}
|
|
126996
|
+
function inAttributes(code) {
|
|
126997
|
+
if (code === codes_codes.greaterThan) {
|
|
126998
|
+
effects.consume(code);
|
|
126999
|
+
return body;
|
|
127000
|
+
}
|
|
127001
|
+
if (code === null) {
|
|
127002
|
+
return nok(code);
|
|
127003
|
+
}
|
|
127004
|
+
if (markdownLineEnding(code)) {
|
|
127005
|
+
if (mode === 'text')
|
|
127006
|
+
return nok(code);
|
|
127007
|
+
effects.exit('htmlBlockComponentData');
|
|
127008
|
+
return attributeContinuationStart(code);
|
|
127009
|
+
}
|
|
127010
|
+
effects.consume(code);
|
|
127011
|
+
return inAttributes;
|
|
127012
|
+
}
|
|
127013
|
+
function attributeContinuationStart(code) {
|
|
127014
|
+
return effects.check(html_block_component_syntax_nonLazyContinuationStart, attributeContinuationNonLazy, continuationAfter)(code);
|
|
127015
|
+
}
|
|
127016
|
+
function attributeContinuationNonLazy(code) {
|
|
127017
|
+
effects.enter(types_types.lineEnding);
|
|
127018
|
+
effects.consume(code);
|
|
127019
|
+
effects.exit(types_types.lineEnding);
|
|
127020
|
+
return attributeContinuationBefore;
|
|
127021
|
+
}
|
|
127022
|
+
function attributeContinuationBefore(code) {
|
|
127023
|
+
if (code === null || markdownLineEnding(code)) {
|
|
127024
|
+
return attributeContinuationStart(code);
|
|
127025
|
+
}
|
|
127026
|
+
effects.enter('htmlBlockComponentData');
|
|
127027
|
+
return inAttributes(code);
|
|
127028
|
+
}
|
|
127029
|
+
function selfClose(code) {
|
|
127030
|
+
if (code === codes_codes.greaterThan) {
|
|
127031
|
+
effects.consume(code);
|
|
127032
|
+
return mode === 'flow' ? afterClose : done(code);
|
|
127033
|
+
}
|
|
127034
|
+
return nok(code);
|
|
127035
|
+
}
|
|
127036
|
+
function body(code) {
|
|
127037
|
+
if (code === null)
|
|
127038
|
+
return nok(code);
|
|
127039
|
+
if (markdownLineEnding(code)) {
|
|
127040
|
+
if (mode === 'text') {
|
|
127041
|
+
// Text constructs operate on paragraph content which spans lines
|
|
127042
|
+
effects.consume(code);
|
|
127043
|
+
return body;
|
|
127044
|
+
}
|
|
127045
|
+
effects.exit('htmlBlockComponentData');
|
|
127046
|
+
return continuationStart(code);
|
|
127047
|
+
}
|
|
127048
|
+
if (code === codes_codes.lessThan) {
|
|
127049
|
+
effects.consume(code);
|
|
127050
|
+
return closeSlash;
|
|
127051
|
+
}
|
|
127052
|
+
effects.consume(code);
|
|
127053
|
+
return body;
|
|
127054
|
+
}
|
|
127055
|
+
function closeSlash(code) {
|
|
127056
|
+
if (code === codes_codes.slash) {
|
|
127057
|
+
effects.consume(code);
|
|
127058
|
+
return matchTagName(closeGt, body);
|
|
127059
|
+
}
|
|
127060
|
+
return matchTagName(openAfterTagName, body)(code);
|
|
127061
|
+
}
|
|
127062
|
+
function openAfterTagName(code) {
|
|
127063
|
+
if (code === codes_codes.greaterThan || code === codes_codes.space || code === codes_codes.horizontalTab) {
|
|
127064
|
+
depth += 1;
|
|
127065
|
+
effects.consume(code);
|
|
127066
|
+
return body;
|
|
127067
|
+
}
|
|
127068
|
+
return body(code);
|
|
127069
|
+
}
|
|
127070
|
+
function closeGt(code) {
|
|
127071
|
+
if (code === codes_codes.greaterThan) {
|
|
127072
|
+
depth -= 1;
|
|
127073
|
+
effects.consume(code);
|
|
127074
|
+
if (depth === 0) {
|
|
127075
|
+
return mode === 'flow' ? afterClose : done(code);
|
|
127076
|
+
}
|
|
127077
|
+
return body;
|
|
127078
|
+
}
|
|
127079
|
+
return body(code);
|
|
127080
|
+
}
|
|
127081
|
+
// -- flow-only states ---------------------------------------------------
|
|
127082
|
+
function afterClose(code) {
|
|
127083
|
+
if (code === null || markdownLineEnding(code)) {
|
|
127084
|
+
return done(code);
|
|
127085
|
+
}
|
|
127086
|
+
if (code === codes_codes.space || code === codes_codes.horizontalTab) {
|
|
127087
|
+
effects.consume(code);
|
|
127088
|
+
return afterClose;
|
|
127089
|
+
}
|
|
127090
|
+
// Reject so the block re-parses as a paragraph, deferring to the
|
|
127091
|
+
// text tokenizer which preserves trailing content in the same line.
|
|
127092
|
+
return nok(code);
|
|
127093
|
+
}
|
|
127094
|
+
// -- flow-only: line continuation ---------------------------------------
|
|
127095
|
+
function continuationStart(code) {
|
|
127096
|
+
return effects.check(html_block_component_syntax_nonLazyContinuationStart, continuationStartNonLazy, continuationAfter)(code);
|
|
127097
|
+
}
|
|
127098
|
+
function continuationStartNonLazy(code) {
|
|
127099
|
+
effects.enter(types_types.lineEnding);
|
|
127100
|
+
effects.consume(code);
|
|
127101
|
+
effects.exit(types_types.lineEnding);
|
|
127102
|
+
return continuationBefore;
|
|
127103
|
+
}
|
|
127104
|
+
function continuationBefore(code) {
|
|
127105
|
+
if (code === null || markdownLineEnding(code)) {
|
|
127106
|
+
return continuationStart(code);
|
|
127107
|
+
}
|
|
127108
|
+
effects.enter('htmlBlockComponentData');
|
|
127109
|
+
return body(code);
|
|
127110
|
+
}
|
|
127111
|
+
function continuationAfter(code) {
|
|
127112
|
+
if (code === null)
|
|
127113
|
+
return nok(code);
|
|
127114
|
+
effects.exit('htmlBlockComponent');
|
|
127115
|
+
return ok(code);
|
|
127116
|
+
}
|
|
127117
|
+
// -- shared exit --------------------------------------------------------
|
|
127118
|
+
function done(_code) {
|
|
127119
|
+
effects.exit('htmlBlockComponentData');
|
|
127120
|
+
effects.exit('htmlBlockComponent');
|
|
127121
|
+
return ok(_code);
|
|
127122
|
+
}
|
|
127123
|
+
};
|
|
127124
|
+
}
|
|
127125
|
+
// ---------------------------------------------------------------------------
|
|
127126
|
+
// Flow construct (block-level)
|
|
127127
|
+
// ---------------------------------------------------------------------------
|
|
127128
|
+
const html_block_component_syntax_nonLazyContinuationStart = {
|
|
127129
|
+
tokenize: html_block_component_syntax_tokenizeNonLazyContinuationStart,
|
|
127130
|
+
partial: true,
|
|
127131
|
+
};
|
|
127132
|
+
function resolveToHtmlBlockComponent(events) {
|
|
127133
|
+
let index = events.length;
|
|
127134
|
+
while (index > 0) {
|
|
127135
|
+
index -= 1;
|
|
127136
|
+
if (events[index][0] === 'enter' && events[index][1].type === 'htmlBlockComponent') {
|
|
127137
|
+
break;
|
|
127138
|
+
}
|
|
127139
|
+
}
|
|
127140
|
+
if (index > 1 && events[index - 2][1].type === types_types.linePrefix) {
|
|
127141
|
+
events[index][1].start = events[index - 2][1].start;
|
|
127142
|
+
events[index + 1][1].start = events[index - 2][1].start;
|
|
127143
|
+
events.splice(index - 2, 2);
|
|
127144
|
+
}
|
|
127145
|
+
return events;
|
|
127146
|
+
}
|
|
127147
|
+
const htmlBlockComponentFlowConstruct = {
|
|
127148
|
+
name: 'htmlBlockComponent',
|
|
127149
|
+
tokenize: syntax_createTokenize('flow'),
|
|
127150
|
+
resolveTo: resolveToHtmlBlockComponent,
|
|
127151
|
+
concrete: true,
|
|
127152
|
+
};
|
|
127153
|
+
function html_block_component_syntax_tokenizeNonLazyContinuationStart(effects, ok, nok) {
|
|
127154
|
+
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
127155
|
+
const self = this;
|
|
127156
|
+
return start;
|
|
127157
|
+
function start(code) {
|
|
127158
|
+
if (markdownLineEnding(code)) {
|
|
127159
|
+
effects.enter(types_types.lineEnding);
|
|
127160
|
+
effects.consume(code);
|
|
127161
|
+
effects.exit(types_types.lineEnding);
|
|
127162
|
+
return after;
|
|
127163
|
+
}
|
|
127164
|
+
return nok(code);
|
|
127165
|
+
}
|
|
127166
|
+
function after(code) {
|
|
127167
|
+
if (self.parser.lazy[self.now().line]) {
|
|
127168
|
+
return nok(code);
|
|
127169
|
+
}
|
|
127170
|
+
return ok(code);
|
|
127171
|
+
}
|
|
127172
|
+
}
|
|
127173
|
+
// ---------------------------------------------------------------------------
|
|
127174
|
+
// Text construct (inline)
|
|
127175
|
+
// ---------------------------------------------------------------------------
|
|
127176
|
+
const htmlBlockComponentTextConstruct = {
|
|
127177
|
+
name: 'htmlBlockComponent',
|
|
127178
|
+
tokenize: syntax_createTokenize('text'),
|
|
127179
|
+
};
|
|
127180
|
+
// ---------------------------------------------------------------------------
|
|
127181
|
+
// Extension
|
|
127182
|
+
// ---------------------------------------------------------------------------
|
|
127183
|
+
function syntax_htmlBlockComponent() {
|
|
127184
|
+
return {
|
|
127185
|
+
flow: {
|
|
127186
|
+
[codes.lessThan]: [htmlBlockComponentFlowConstruct],
|
|
127187
|
+
},
|
|
127188
|
+
text: {
|
|
127189
|
+
[codes.lessThan]: [htmlBlockComponentTextConstruct],
|
|
127190
|
+
},
|
|
127191
|
+
};
|
|
127192
|
+
}
|
|
127193
|
+
|
|
127194
|
+
;// ./lib/micromark/html-block-component/index.ts
|
|
127195
|
+
|
|
127196
|
+
|
|
126503
127197
|
;// ./lib/stripComments.ts
|
|
126504
127198
|
|
|
126505
127199
|
|
|
@@ -126514,19 +127208,22 @@ const mdxishTags_tags = (doc) => {
|
|
|
126514
127208
|
|
|
126515
127209
|
|
|
126516
127210
|
|
|
127211
|
+
|
|
127212
|
+
|
|
126517
127213
|
/**
|
|
126518
127214
|
* Removes Markdown and MDX comments.
|
|
126519
127215
|
*/
|
|
126520
127216
|
async function stripComments(doc, { mdx, mdxish } = {}) {
|
|
126521
127217
|
const { replaced, blocks } = extractMagicBlocks(doc);
|
|
126522
127218
|
const processor = unified();
|
|
126523
|
-
// we still require these
|
|
127219
|
+
// we still require these extensions because:
|
|
126524
127220
|
// 1. we can rely on remarkMdx to parse MDXish
|
|
126525
127221
|
// 2. we need to parse JSX comments into mdxTextExpression nodes so that the transformers can pick them up
|
|
127222
|
+
// 3. we need to claim <HTMLBlock> before htmlFlow intercepts its inner HTML tags
|
|
126526
127223
|
if (mdxish) {
|
|
126527
127224
|
processor
|
|
126528
|
-
.data('micromarkExtensions', [jsxTable(), mdxExpression({ allowEmpty: true })])
|
|
126529
|
-
.data('fromMarkdownExtensions', [jsxTableFromMarkdown(), mdxExpressionFromMarkdown()])
|
|
127225
|
+
.data('micromarkExtensions', [htmlBlockComponent(), jsxTable(), mdxExpression({ allowEmpty: true })])
|
|
127226
|
+
.data('fromMarkdownExtensions', [htmlBlockComponentFromMarkdown(), jsxTableFromMarkdown(), mdxExpressionFromMarkdown()])
|
|
126530
127227
|
.data('toMarkdownExtensions', [mdxExpressionToMarkdown()]);
|
|
126531
127228
|
}
|
|
126532
127229
|
processor
|