@readme/markdown 14.2.0 → 14.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/main.js +271 -186
- package/dist/main.node.js +271 -186
- package/dist/main.node.js.map +1 -1
- package/package.json +3 -1
package/dist/main.js
CHANGED
|
@@ -71230,6 +71230,87 @@ function gemojiFromMarkdown() {
|
|
|
71230
71230
|
};
|
|
71231
71231
|
}
|
|
71232
71232
|
|
|
71233
|
+
;// ./lib/mdast-util/legacy-variable/index.ts
|
|
71234
|
+
|
|
71235
|
+
const contextMap = new WeakMap();
|
|
71236
|
+
function findlegacyVariableToken() {
|
|
71237
|
+
// tokenStack is micromark's current open token ancestry; find the nearest legacyVariable token.
|
|
71238
|
+
const events = this.tokenStack;
|
|
71239
|
+
for (let i = events.length - 1; i >= 0; i -= 1) {
|
|
71240
|
+
const token = events[i][0];
|
|
71241
|
+
if (token.type === 'legacyVariable')
|
|
71242
|
+
return token;
|
|
71243
|
+
}
|
|
71244
|
+
return undefined;
|
|
71245
|
+
}
|
|
71246
|
+
function enterlegacyVariable(token) {
|
|
71247
|
+
contextMap.set(token, { value: '' });
|
|
71248
|
+
}
|
|
71249
|
+
function exitlegacyVariableValue(token) {
|
|
71250
|
+
const variableToken = findlegacyVariableToken.call(this);
|
|
71251
|
+
if (!variableToken)
|
|
71252
|
+
return;
|
|
71253
|
+
const ctx = contextMap.get(variableToken);
|
|
71254
|
+
// Build up the variable characters
|
|
71255
|
+
if (ctx)
|
|
71256
|
+
ctx.value += this.sliceSerialize(token);
|
|
71257
|
+
}
|
|
71258
|
+
function exitlegacyVariable(token) {
|
|
71259
|
+
const ctx = contextMap.get(token);
|
|
71260
|
+
const serialized = this.sliceSerialize(token);
|
|
71261
|
+
const variableName = serialized.startsWith('<<') && serialized.endsWith('>>')
|
|
71262
|
+
? serialized.slice(2, -2)
|
|
71263
|
+
: ctx?.value ?? '';
|
|
71264
|
+
const nodePosition = {
|
|
71265
|
+
start: {
|
|
71266
|
+
offset: token.start.offset,
|
|
71267
|
+
line: token.start.line,
|
|
71268
|
+
column: token.start.column,
|
|
71269
|
+
},
|
|
71270
|
+
end: {
|
|
71271
|
+
offset: token.end.offset,
|
|
71272
|
+
line: token.end.line,
|
|
71273
|
+
column: token.end.column,
|
|
71274
|
+
},
|
|
71275
|
+
};
|
|
71276
|
+
if (variableName.startsWith('glossary:')) {
|
|
71277
|
+
const term = variableName.slice('glossary:'.length).trim();
|
|
71278
|
+
this.enter({
|
|
71279
|
+
type: NodeTypes.glossary,
|
|
71280
|
+
data: {
|
|
71281
|
+
hName: 'Glossary',
|
|
71282
|
+
hProperties: { term },
|
|
71283
|
+
},
|
|
71284
|
+
children: [{ type: 'text', value: term }],
|
|
71285
|
+
position: nodePosition,
|
|
71286
|
+
}, token);
|
|
71287
|
+
this.exit(token);
|
|
71288
|
+
contextMap.delete(token);
|
|
71289
|
+
return;
|
|
71290
|
+
}
|
|
71291
|
+
this.enter({
|
|
71292
|
+
type: NodeTypes.variable,
|
|
71293
|
+
data: {
|
|
71294
|
+
hName: 'Variable',
|
|
71295
|
+
hProperties: { name: variableName.trim(), isLegacy: true },
|
|
71296
|
+
},
|
|
71297
|
+
value: `<<${variableName}>>`,
|
|
71298
|
+
}, token);
|
|
71299
|
+
this.exit(token);
|
|
71300
|
+
contextMap.delete(token);
|
|
71301
|
+
}
|
|
71302
|
+
function legacyVariableFromMarkdown() {
|
|
71303
|
+
return {
|
|
71304
|
+
enter: {
|
|
71305
|
+
legacyVariable: enterlegacyVariable,
|
|
71306
|
+
},
|
|
71307
|
+
exit: {
|
|
71308
|
+
legacyVariableValue: exitlegacyVariableValue,
|
|
71309
|
+
legacyVariable: exitlegacyVariable,
|
|
71310
|
+
},
|
|
71311
|
+
};
|
|
71312
|
+
}
|
|
71313
|
+
|
|
71233
71314
|
;// ./node_modules/micromark-util-symbol/lib/codes.js
|
|
71234
71315
|
/**
|
|
71235
71316
|
* Character codes.
|
|
@@ -71483,6 +71564,74 @@ function syntax_gemoji() {
|
|
|
71483
71564
|
*/
|
|
71484
71565
|
|
|
71485
71566
|
|
|
71567
|
+
;// ./lib/micromark/legacy-variable/syntax.ts
|
|
71568
|
+
|
|
71569
|
+
|
|
71570
|
+
function isAllowedValueChar(code) {
|
|
71571
|
+
return (code !== null &&
|
|
71572
|
+
code !== codes.lessThan &&
|
|
71573
|
+
code !== codes.greaterThan &&
|
|
71574
|
+
!markdownLineEnding(code));
|
|
71575
|
+
}
|
|
71576
|
+
const legacyVariableConstruct = {
|
|
71577
|
+
name: 'legacyVariable',
|
|
71578
|
+
tokenize: syntax_tokenize,
|
|
71579
|
+
};
|
|
71580
|
+
function syntax_tokenize(effects, ok, nok) {
|
|
71581
|
+
let hasValue = false;
|
|
71582
|
+
const start = (code) => {
|
|
71583
|
+
if (code !== codes.lessThan)
|
|
71584
|
+
return nok(code);
|
|
71585
|
+
effects.enter('legacyVariable');
|
|
71586
|
+
effects.enter('legacyVariableMarkerStart');
|
|
71587
|
+
effects.consume(code); // <
|
|
71588
|
+
return open2;
|
|
71589
|
+
};
|
|
71590
|
+
const open2 = (code) => {
|
|
71591
|
+
if (code !== codes.lessThan)
|
|
71592
|
+
return nok(code);
|
|
71593
|
+
effects.consume(code); // <<
|
|
71594
|
+
effects.exit('legacyVariableMarkerStart');
|
|
71595
|
+
effects.enter('legacyVariableValue');
|
|
71596
|
+
return value;
|
|
71597
|
+
};
|
|
71598
|
+
const value = (code) => {
|
|
71599
|
+
if (code === codes.greaterThan) {
|
|
71600
|
+
if (!hasValue)
|
|
71601
|
+
return nok(code);
|
|
71602
|
+
effects.exit('legacyVariableValue');
|
|
71603
|
+
effects.enter('legacyVariableMarkerEnd');
|
|
71604
|
+
effects.consume(code); // >
|
|
71605
|
+
return close2;
|
|
71606
|
+
}
|
|
71607
|
+
if (!isAllowedValueChar(code))
|
|
71608
|
+
return nok(code);
|
|
71609
|
+
hasValue = true;
|
|
71610
|
+
effects.consume(code);
|
|
71611
|
+
return value;
|
|
71612
|
+
};
|
|
71613
|
+
const close2 = (code) => {
|
|
71614
|
+
if (code !== codes.greaterThan)
|
|
71615
|
+
return nok(code);
|
|
71616
|
+
effects.consume(code); // >>
|
|
71617
|
+
effects.exit('legacyVariableMarkerEnd');
|
|
71618
|
+
effects.exit('legacyVariable');
|
|
71619
|
+
return ok;
|
|
71620
|
+
};
|
|
71621
|
+
return start;
|
|
71622
|
+
}
|
|
71623
|
+
function legacyVariable() {
|
|
71624
|
+
return {
|
|
71625
|
+
text: { [codes.lessThan]: legacyVariableConstruct },
|
|
71626
|
+
};
|
|
71627
|
+
}
|
|
71628
|
+
|
|
71629
|
+
;// ./lib/micromark/legacy-variable/index.ts
|
|
71630
|
+
/**
|
|
71631
|
+
* Micromark extension for <<variable>> / <<glossary:term>> inline syntax.
|
|
71632
|
+
*/
|
|
71633
|
+
|
|
71634
|
+
|
|
71486
71635
|
;// ./processor/transform/mdxish/normalize-malformed-md-syntax.ts
|
|
71487
71636
|
|
|
71488
71637
|
// Marker patterns for multi-node emphasis detection
|
|
@@ -71861,20 +72010,59 @@ const unwrapSoleParagraph = (children) => {
|
|
|
71861
72010
|
|
|
71862
72011
|
|
|
71863
72012
|
|
|
72013
|
+
|
|
72014
|
+
|
|
72015
|
+
|
|
71864
72016
|
const isTableCell = (node) => isMDXElement(node) && ['th', 'td'].includes(node.name);
|
|
71865
72017
|
const tableTypes = {
|
|
71866
72018
|
tr: 'tableRow',
|
|
71867
72019
|
th: 'tableCell',
|
|
71868
72020
|
td: 'tableCell',
|
|
71869
72021
|
};
|
|
71870
|
-
|
|
71871
|
-
|
|
71872
|
-
|
|
72022
|
+
// `mdxjs` + `mdxFromMarkdown` is what `remarkMdx` registers internally; we
|
|
72023
|
+
// register them manually so we control ordering against our other tokenizers.
|
|
72024
|
+
// The fallback omits these so blank-line-separated markdown inside cells still
|
|
72025
|
+
// parses when mdxjs throws on malformed JSX.
|
|
72026
|
+
const buildTableNodeProcessor = (withMdx) => unified()
|
|
72027
|
+
.data('micromarkExtensions', [...(withMdx ? [mdxjs()] : []), syntax_gemoji(), legacyVariable()])
|
|
72028
|
+
.data('fromMarkdownExtensions', [
|
|
72029
|
+
...(withMdx ? [mdxFromMarkdown()] : []),
|
|
72030
|
+
gemojiFromMarkdown(),
|
|
72031
|
+
legacyVariableFromMarkdown(),
|
|
72032
|
+
])
|
|
71873
72033
|
.use(remarkParse)
|
|
71874
|
-
.use(remarkMdx)
|
|
71875
72034
|
.use(normalize_malformed_md_syntax)
|
|
71876
72035
|
.use([[callouts, { isMdxish: true }], code_tabs])
|
|
71877
72036
|
.use(remarkGfm);
|
|
72037
|
+
const tableNodeProcessor = buildTableNodeProcessor(true);
|
|
72038
|
+
const fallbackTableNodeProcessor = buildTableNodeProcessor(false);
|
|
72039
|
+
// Since we use a subparser in `tableNodeProcessor` to parse `node.value`,
|
|
72040
|
+
// positions are relative to that substring. Shifting them by the base
|
|
72041
|
+
// offset and line number makes them valid in the outer source coordinate space.
|
|
72042
|
+
// Otherwise, consumers who directly slice based on position would read and grab the
|
|
72043
|
+
// wrong content
|
|
72044
|
+
const parseTableNode = (processor, node) => {
|
|
72045
|
+
let parsed;
|
|
72046
|
+
try {
|
|
72047
|
+
parsed = processor.runSync(processor.parse(node.value));
|
|
72048
|
+
}
|
|
72049
|
+
catch {
|
|
72050
|
+
return undefined;
|
|
72051
|
+
}
|
|
72052
|
+
const baseOffset = node.position?.start?.offset ?? 0;
|
|
72053
|
+
const baseLine = (node.position?.start?.line ?? 1) - 1;
|
|
72054
|
+
visit(parsed, child => {
|
|
72055
|
+
if (child.position?.start) {
|
|
72056
|
+
child.position.start.offset = (child.position.start.offset ?? 0) + baseOffset;
|
|
72057
|
+
child.position.start.line += baseLine;
|
|
72058
|
+
}
|
|
72059
|
+
if (child.position?.end) {
|
|
72060
|
+
child.position.end.offset = (child.position.end.offset ?? 0) + baseOffset;
|
|
72061
|
+
child.position.end.line += baseLine;
|
|
72062
|
+
}
|
|
72063
|
+
});
|
|
72064
|
+
return parsed;
|
|
72065
|
+
};
|
|
71878
72066
|
/**
|
|
71879
72067
|
* Check if children are only text nodes that might contain markdown
|
|
71880
72068
|
*/
|
|
@@ -71977,27 +72165,54 @@ const processTableNode = (node, index, parent, documentPosition) => {
|
|
|
71977
72165
|
}
|
|
71978
72166
|
// All cells are phrasing-only — convert to markdown table
|
|
71979
72167
|
const children = [];
|
|
72168
|
+
// Collect `<td>`/`<th>` cells under any container (a `<tr>`, or a section
|
|
72169
|
+
// when cells are bare).
|
|
72170
|
+
const collectCells = (container) => {
|
|
72171
|
+
const cells = [];
|
|
72172
|
+
visit(container, isTableCell, ({ name, children: cellChildren, position: cellPosition }) => {
|
|
72173
|
+
cells.push({
|
|
72174
|
+
type: tableTypes[name],
|
|
72175
|
+
children: unwrapSoleParagraph(cellChildren),
|
|
72176
|
+
position: cellPosition,
|
|
72177
|
+
});
|
|
72178
|
+
});
|
|
72179
|
+
return cells;
|
|
72180
|
+
};
|
|
72181
|
+
// remarkMdx wraps inline `<tr>`s in a paragraph; unwrap one level so the
|
|
72182
|
+
// hasRow check below sees them.
|
|
72183
|
+
const flattenSectionChildren = (nodes) => nodes.flatMap(n => n.type === 'paragraph' && 'children' in n && Array.isArray(n.children) ? n.children : [n]);
|
|
71980
72184
|
visit(node, isMDXElement, (child) => {
|
|
71981
|
-
if (child.name
|
|
72185
|
+
if (child.name !== 'thead' && child.name !== 'tbody')
|
|
72186
|
+
return;
|
|
72187
|
+
const sectionChildren = flattenSectionChildren(child.children);
|
|
72188
|
+
const hasRow = sectionChildren.some(c => isMDXElement(c) && c.name === 'tr');
|
|
72189
|
+
if (hasRow) {
|
|
71982
72190
|
visit(child, isMDXElement, (row) => {
|
|
71983
72191
|
if (row.name !== 'tr')
|
|
71984
72192
|
return;
|
|
71985
|
-
const rowChildren = [];
|
|
71986
|
-
visit(row, isTableCell, ({ name, children: cellChildren, position: cellPosition }) => {
|
|
71987
|
-
const parsedChildren = unwrapSoleParagraph(cellChildren);
|
|
71988
|
-
rowChildren.push({
|
|
71989
|
-
type: tableTypes[name],
|
|
71990
|
-
children: parsedChildren,
|
|
71991
|
-
position: cellPosition,
|
|
71992
|
-
});
|
|
71993
|
-
});
|
|
71994
72193
|
children.push({
|
|
71995
72194
|
type: 'tableRow',
|
|
71996
|
-
children:
|
|
72195
|
+
children: collectCells(row),
|
|
71997
72196
|
position: row.position,
|
|
71998
72197
|
});
|
|
71999
72198
|
});
|
|
72000
72199
|
}
|
|
72200
|
+
else {
|
|
72201
|
+
// No `<tr>`, chunk bare cells into rows using the prior row's column
|
|
72202
|
+
// count (e.g. from `<thead>`), so 4 bare `<td>`s under a 2-col header
|
|
72203
|
+
// become 2 rows of 2.
|
|
72204
|
+
const cells = collectCells(child);
|
|
72205
|
+
if (cells.length === 0)
|
|
72206
|
+
return;
|
|
72207
|
+
const cols = children[0]?.children?.length || cells.length;
|
|
72208
|
+
for (let i = 0; i < cells.length; i += cols) {
|
|
72209
|
+
children.push({
|
|
72210
|
+
type: 'tableRow',
|
|
72211
|
+
children: cells.slice(i, i + cols),
|
|
72212
|
+
position: child.position,
|
|
72213
|
+
});
|
|
72214
|
+
}
|
|
72215
|
+
}
|
|
72001
72216
|
});
|
|
72002
72217
|
const firstRow = children[0];
|
|
72003
72218
|
const columnCount = firstRow?.children?.length || 0;
|
|
@@ -72030,35 +72245,22 @@ const mdxishTables = () => tree => {
|
|
|
72030
72245
|
return;
|
|
72031
72246
|
if (!node.value.startsWith('<Table') && !node.value.startsWith('<table'))
|
|
72032
72247
|
return;
|
|
72033
|
-
|
|
72034
|
-
|
|
72035
|
-
// since we use a subparser in `tableNodeProcessor` to parse `node.value`,
|
|
72036
|
-
// positions are relative to that substring. shifting them by the base
|
|
72037
|
-
// offset and line number makes them valid in the outer source coordinate space.
|
|
72038
|
-
// otherwise, consumers who directly slice based on position would read and grab the
|
|
72039
|
-
// wrong content
|
|
72040
|
-
const baseOffset = node.position?.start?.offset ?? 0;
|
|
72041
|
-
const baseLine = (node.position?.start?.line ?? 1) - 1;
|
|
72042
|
-
visit(parsed, child => {
|
|
72043
|
-
if (child.position?.start) {
|
|
72044
|
-
child.position.start.offset = (child.position.start.offset ?? 0) + baseOffset;
|
|
72045
|
-
child.position.start.line += baseLine;
|
|
72046
|
-
}
|
|
72047
|
-
if (child.position?.end) {
|
|
72048
|
-
child.position.end.offset = (child.position.end.offset ?? 0) + baseOffset;
|
|
72049
|
-
child.position.end.line += baseLine;
|
|
72050
|
-
}
|
|
72051
|
-
});
|
|
72248
|
+
const parsed = parseTableNode(tableNodeProcessor, node);
|
|
72249
|
+
if (parsed) {
|
|
72052
72250
|
visit(parsed, isMDXElement, (tableNode) => {
|
|
72053
72251
|
if (tableNode.name !== 'Table' && tableNode.name !== 'table')
|
|
72054
72252
|
return undefined;
|
|
72055
72253
|
processTableNode(tableNode, index, parent, node.position);
|
|
72056
72254
|
return EXIT;
|
|
72057
72255
|
});
|
|
72256
|
+
return;
|
|
72058
72257
|
}
|
|
72059
|
-
|
|
72060
|
-
|
|
72061
|
-
|
|
72258
|
+
// MDX parse failed (usually unbalanced JSX). Re-parse without MDX so
|
|
72259
|
+
// markdown between `<td>` and `</td>` still renders; tags stay as raw HTML.
|
|
72260
|
+
const fallback = parseTableNode(fallbackTableNodeProcessor, node);
|
|
72261
|
+
if (!fallback || fallback.children.length <= 1)
|
|
72262
|
+
return;
|
|
72263
|
+
parent.children.splice(index, 1, ...fallback.children);
|
|
72062
72264
|
});
|
|
72063
72265
|
return tree;
|
|
72064
72266
|
};
|
|
@@ -94871,87 +95073,6 @@ function emptyTaskListItemFromMarkdown() {
|
|
|
94871
95073
|
};
|
|
94872
95074
|
}
|
|
94873
95075
|
|
|
94874
|
-
;// ./lib/mdast-util/legacy-variable/index.ts
|
|
94875
|
-
|
|
94876
|
-
const contextMap = new WeakMap();
|
|
94877
|
-
function findlegacyVariableToken() {
|
|
94878
|
-
// tokenStack is micromark's current open token ancestry; find the nearest legacyVariable token.
|
|
94879
|
-
const events = this.tokenStack;
|
|
94880
|
-
for (let i = events.length - 1; i >= 0; i -= 1) {
|
|
94881
|
-
const token = events[i][0];
|
|
94882
|
-
if (token.type === 'legacyVariable')
|
|
94883
|
-
return token;
|
|
94884
|
-
}
|
|
94885
|
-
return undefined;
|
|
94886
|
-
}
|
|
94887
|
-
function enterlegacyVariable(token) {
|
|
94888
|
-
contextMap.set(token, { value: '' });
|
|
94889
|
-
}
|
|
94890
|
-
function exitlegacyVariableValue(token) {
|
|
94891
|
-
const variableToken = findlegacyVariableToken.call(this);
|
|
94892
|
-
if (!variableToken)
|
|
94893
|
-
return;
|
|
94894
|
-
const ctx = contextMap.get(variableToken);
|
|
94895
|
-
// Build up the variable characters
|
|
94896
|
-
if (ctx)
|
|
94897
|
-
ctx.value += this.sliceSerialize(token);
|
|
94898
|
-
}
|
|
94899
|
-
function exitlegacyVariable(token) {
|
|
94900
|
-
const ctx = contextMap.get(token);
|
|
94901
|
-
const serialized = this.sliceSerialize(token);
|
|
94902
|
-
const variableName = serialized.startsWith('<<') && serialized.endsWith('>>')
|
|
94903
|
-
? serialized.slice(2, -2)
|
|
94904
|
-
: ctx?.value ?? '';
|
|
94905
|
-
const nodePosition = {
|
|
94906
|
-
start: {
|
|
94907
|
-
offset: token.start.offset,
|
|
94908
|
-
line: token.start.line,
|
|
94909
|
-
column: token.start.column,
|
|
94910
|
-
},
|
|
94911
|
-
end: {
|
|
94912
|
-
offset: token.end.offset,
|
|
94913
|
-
line: token.end.line,
|
|
94914
|
-
column: token.end.column,
|
|
94915
|
-
},
|
|
94916
|
-
};
|
|
94917
|
-
if (variableName.startsWith('glossary:')) {
|
|
94918
|
-
const term = variableName.slice('glossary:'.length).trim();
|
|
94919
|
-
this.enter({
|
|
94920
|
-
type: NodeTypes.glossary,
|
|
94921
|
-
data: {
|
|
94922
|
-
hName: 'Glossary',
|
|
94923
|
-
hProperties: { term },
|
|
94924
|
-
},
|
|
94925
|
-
children: [{ type: 'text', value: term }],
|
|
94926
|
-
position: nodePosition,
|
|
94927
|
-
}, token);
|
|
94928
|
-
this.exit(token);
|
|
94929
|
-
contextMap.delete(token);
|
|
94930
|
-
return;
|
|
94931
|
-
}
|
|
94932
|
-
this.enter({
|
|
94933
|
-
type: NodeTypes.variable,
|
|
94934
|
-
data: {
|
|
94935
|
-
hName: 'Variable',
|
|
94936
|
-
hProperties: { name: variableName.trim(), isLegacy: true },
|
|
94937
|
-
},
|
|
94938
|
-
value: `<<${variableName}>>`,
|
|
94939
|
-
}, token);
|
|
94940
|
-
this.exit(token);
|
|
94941
|
-
contextMap.delete(token);
|
|
94942
|
-
}
|
|
94943
|
-
function legacyVariableFromMarkdown() {
|
|
94944
|
-
return {
|
|
94945
|
-
enter: {
|
|
94946
|
-
legacyVariable: enterlegacyVariable,
|
|
94947
|
-
},
|
|
94948
|
-
exit: {
|
|
94949
|
-
legacyVariableValue: exitlegacyVariableValue,
|
|
94950
|
-
legacyVariable: exitlegacyVariable,
|
|
94951
|
-
},
|
|
94952
|
-
};
|
|
94953
|
-
}
|
|
94954
|
-
|
|
94955
95076
|
;// ./lib/mdast-util/magic-block/index.ts
|
|
94956
95077
|
const magic_block_contextMap = new WeakMap();
|
|
94957
95078
|
/**
|
|
@@ -95141,74 +95262,6 @@ function mdxComponentFromMarkdown() {
|
|
|
95141
95262
|
};
|
|
95142
95263
|
}
|
|
95143
95264
|
|
|
95144
|
-
;// ./lib/micromark/legacy-variable/syntax.ts
|
|
95145
|
-
|
|
95146
|
-
|
|
95147
|
-
function isAllowedValueChar(code) {
|
|
95148
|
-
return (code !== null &&
|
|
95149
|
-
code !== codes.lessThan &&
|
|
95150
|
-
code !== codes.greaterThan &&
|
|
95151
|
-
!markdownLineEnding(code));
|
|
95152
|
-
}
|
|
95153
|
-
const legacyVariableConstruct = {
|
|
95154
|
-
name: 'legacyVariable',
|
|
95155
|
-
tokenize: syntax_tokenize,
|
|
95156
|
-
};
|
|
95157
|
-
function syntax_tokenize(effects, ok, nok) {
|
|
95158
|
-
let hasValue = false;
|
|
95159
|
-
const start = (code) => {
|
|
95160
|
-
if (code !== codes.lessThan)
|
|
95161
|
-
return nok(code);
|
|
95162
|
-
effects.enter('legacyVariable');
|
|
95163
|
-
effects.enter('legacyVariableMarkerStart');
|
|
95164
|
-
effects.consume(code); // <
|
|
95165
|
-
return open2;
|
|
95166
|
-
};
|
|
95167
|
-
const open2 = (code) => {
|
|
95168
|
-
if (code !== codes.lessThan)
|
|
95169
|
-
return nok(code);
|
|
95170
|
-
effects.consume(code); // <<
|
|
95171
|
-
effects.exit('legacyVariableMarkerStart');
|
|
95172
|
-
effects.enter('legacyVariableValue');
|
|
95173
|
-
return value;
|
|
95174
|
-
};
|
|
95175
|
-
const value = (code) => {
|
|
95176
|
-
if (code === codes.greaterThan) {
|
|
95177
|
-
if (!hasValue)
|
|
95178
|
-
return nok(code);
|
|
95179
|
-
effects.exit('legacyVariableValue');
|
|
95180
|
-
effects.enter('legacyVariableMarkerEnd');
|
|
95181
|
-
effects.consume(code); // >
|
|
95182
|
-
return close2;
|
|
95183
|
-
}
|
|
95184
|
-
if (!isAllowedValueChar(code))
|
|
95185
|
-
return nok(code);
|
|
95186
|
-
hasValue = true;
|
|
95187
|
-
effects.consume(code);
|
|
95188
|
-
return value;
|
|
95189
|
-
};
|
|
95190
|
-
const close2 = (code) => {
|
|
95191
|
-
if (code !== codes.greaterThan)
|
|
95192
|
-
return nok(code);
|
|
95193
|
-
effects.consume(code); // >>
|
|
95194
|
-
effects.exit('legacyVariableMarkerEnd');
|
|
95195
|
-
effects.exit('legacyVariable');
|
|
95196
|
-
return ok;
|
|
95197
|
-
};
|
|
95198
|
-
return start;
|
|
95199
|
-
}
|
|
95200
|
-
function legacyVariable() {
|
|
95201
|
-
return {
|
|
95202
|
-
text: { [codes.lessThan]: legacyVariableConstruct },
|
|
95203
|
-
};
|
|
95204
|
-
}
|
|
95205
|
-
|
|
95206
|
-
;// ./lib/micromark/legacy-variable/index.ts
|
|
95207
|
-
/**
|
|
95208
|
-
* Micromark extension for <<variable>> / <<glossary:term>> inline syntax.
|
|
95209
|
-
*/
|
|
95210
|
-
|
|
95211
|
-
|
|
95212
95265
|
;// ./lib/micromark/magic-block/syntax.ts
|
|
95213
95266
|
|
|
95214
95267
|
|
|
@@ -100527,11 +100580,43 @@ const transformMagicBlockEmbed = (node) => {
|
|
|
100527
100580
|
};
|
|
100528
100581
|
};
|
|
100529
100582
|
const mdxish_jsx_to_mdast_isTableCell = (node) => isMDXElement(node) && ['th', 'td'].includes(node.name);
|
|
100583
|
+
/**
|
|
100584
|
+
* Wraps bare `<td>`/`<th>` cells directly inside `<thead>`/`<tbody>` with an
|
|
100585
|
+
* implicit `<tr>`. remarkMdx may wrap inline JSX elements in paragraph nodes,
|
|
100586
|
+
* so unwrap those first.
|
|
100587
|
+
*/
|
|
100588
|
+
const wrapBareCellsInRow = (node) => {
|
|
100589
|
+
visit(node, isMDXElement, (section) => {
|
|
100590
|
+
if (section.name !== 'thead' && section.name !== 'tbody')
|
|
100591
|
+
return;
|
|
100592
|
+
const children = section.children;
|
|
100593
|
+
const hasRow = children.some(c => isMDXElement(c) && c.name === 'tr');
|
|
100594
|
+
if (hasRow)
|
|
100595
|
+
return;
|
|
100596
|
+
const unwrapped = children.flatMap(c => {
|
|
100597
|
+
if (c.type === 'paragraph' && 'children' in c && Array.isArray(c.children)) {
|
|
100598
|
+
return c.children;
|
|
100599
|
+
}
|
|
100600
|
+
return [c];
|
|
100601
|
+
});
|
|
100602
|
+
const cells = unwrapped.filter(c => mdxish_jsx_to_mdast_isTableCell(c));
|
|
100603
|
+
if (cells.length === 0)
|
|
100604
|
+
return;
|
|
100605
|
+
const tr = {
|
|
100606
|
+
type: 'mdxJsxFlowElement',
|
|
100607
|
+
name: 'tr',
|
|
100608
|
+
attributes: [],
|
|
100609
|
+
children: cells,
|
|
100610
|
+
};
|
|
100611
|
+
section.children = [tr];
|
|
100612
|
+
});
|
|
100613
|
+
};
|
|
100530
100614
|
/**
|
|
100531
100615
|
* Converts a JSX <Table> element to an MDAST table node with alignment.
|
|
100532
100616
|
* Returns null for header-less tables since MDAST always promotes the first row to <thead>.
|
|
100533
100617
|
*/
|
|
100534
100618
|
const transformTable = (jsx) => {
|
|
100619
|
+
wrapBareCellsInRow(jsx);
|
|
100535
100620
|
let hasThead = false;
|
|
100536
100621
|
visit(jsx, isMDXElement, (child) => {
|
|
100537
100622
|
if (child.name === 'thead')
|