@readme/markdown 14.12.0 → 14.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/Cards/index.tsx +14 -2
- package/dist/components/Cards/index.d.ts +2 -1
- package/dist/main.js +174 -81
- package/dist/main.node.js +174 -81
- package/dist/main.node.js.map +1 -1
- package/dist/processor/plugin/hard-breaks.d.ts +13 -0
- package/dist/processor/transform/mdxish/collapse-foreign-content-blank-lines.d.ts +6 -0
- package/dist/processor/transform/mdxish/indentation.d.ts +19 -0
- package/dist/render-fixture.node.js +174 -81
- package/dist/render-fixture.node.js.map +1 -1
- package/dist/utils/common-html-words.d.ts +6 -0
- package/package.json +1 -2
package/dist/main.node.js
CHANGED
|
@@ -19523,8 +19523,8 @@ const Callout = (props) => {
|
|
|
19523
19523
|
|
|
19524
19524
|
|
|
19525
19525
|
|
|
19526
|
-
const Card = ({ badge, children, href, kind = 'card', icon, iconColor, target, title }) => {
|
|
19527
|
-
const Tag = href ?
|
|
19526
|
+
const Card = ({ badge, children, href, kind = 'card', icon, iconColor, LinkComponent = 'a', target, title, }) => {
|
|
19527
|
+
const Tag = href ? LinkComponent : 'div';
|
|
19528
19528
|
return (external_react_default().createElement(Tag, { className: `Card Card_${kind}`, href: href, target: target },
|
|
19529
19529
|
icon && external_react_default().createElement(components_Icon, { className: "Card-icon", icon: icon, iconColor: iconColor }),
|
|
19530
19530
|
external_react_default().createElement("div", { className: "Card-content" },
|
|
@@ -96525,6 +96525,12 @@ const HTML_TABLE_STRUCTURE_TAGS = new Set([
|
|
|
96525
96525
|
'caption',
|
|
96526
96526
|
'colgroup',
|
|
96527
96527
|
]);
|
|
96528
|
+
/**
|
|
96529
|
+
* The two HTML "foreign content" namespaces: SVG and MathML. Their descendants
|
|
96530
|
+
* (`<path>`, `<mrow>`, …) are namespaced XML, not HTML tags or components. A closed
|
|
96531
|
+
* set per the HTML spec, so transforms can treat these roots as opaque islands.
|
|
96532
|
+
*/
|
|
96533
|
+
const FOREIGN_CONTENT_TAGS = ['svg', 'math'];
|
|
96528
96534
|
/**
|
|
96529
96535
|
* HTML void elements — elements that have no closing tag and no children.
|
|
96530
96536
|
*
|
|
@@ -109882,63 +109888,6 @@ function rehypeSanitize(options) {
|
|
|
109882
109888
|
}
|
|
109883
109889
|
}
|
|
109884
109890
|
|
|
109885
|
-
;// ./node_modules/mdast-util-newline-to-break/lib/index.js
|
|
109886
|
-
/**
|
|
109887
|
-
* @typedef {import('mdast').Nodes} Nodes
|
|
109888
|
-
* @typedef {import('mdast-util-find-and-replace').ReplaceFunction} ReplaceFunction
|
|
109889
|
-
*/
|
|
109890
|
-
|
|
109891
|
-
|
|
109892
|
-
|
|
109893
|
-
/**
|
|
109894
|
-
* Turn normal line endings into hard breaks.
|
|
109895
|
-
*
|
|
109896
|
-
* @param {Nodes} tree
|
|
109897
|
-
* Tree to change.
|
|
109898
|
-
* @returns {undefined}
|
|
109899
|
-
* Nothing.
|
|
109900
|
-
*/
|
|
109901
|
-
function newlineToBreak(tree) {
|
|
109902
|
-
findAndReplace(tree, [/\r?\n|\r/g, lib_replace])
|
|
109903
|
-
}
|
|
109904
|
-
|
|
109905
|
-
/**
|
|
109906
|
-
* Replace line endings.
|
|
109907
|
-
*
|
|
109908
|
-
* @type {ReplaceFunction}
|
|
109909
|
-
*/
|
|
109910
|
-
function lib_replace() {
|
|
109911
|
-
return {type: 'break'}
|
|
109912
|
-
}
|
|
109913
|
-
|
|
109914
|
-
;// ./node_modules/remark-breaks/lib/index.js
|
|
109915
|
-
/**
|
|
109916
|
-
* @typedef {import('mdast').Root} Root
|
|
109917
|
-
*/
|
|
109918
|
-
|
|
109919
|
-
|
|
109920
|
-
|
|
109921
|
-
/**
|
|
109922
|
-
* Support hard breaks without needing spaces or escapes (turns enters into
|
|
109923
|
-
* `<br>`s).
|
|
109924
|
-
*
|
|
109925
|
-
* @returns
|
|
109926
|
-
* Transform.
|
|
109927
|
-
*/
|
|
109928
|
-
function remarkBreaks() {
|
|
109929
|
-
/**
|
|
109930
|
-
* Transform.
|
|
109931
|
-
*
|
|
109932
|
-
* @param {Root} tree
|
|
109933
|
-
* Tree.
|
|
109934
|
-
* @returns {undefined}
|
|
109935
|
-
* Nothing.
|
|
109936
|
-
*/
|
|
109937
|
-
return function (tree) {
|
|
109938
|
-
newlineToBreak(tree)
|
|
109939
|
-
}
|
|
109940
|
-
}
|
|
109941
|
-
|
|
109942
109891
|
;// ./errors/mdx-syntax-error.ts
|
|
109943
109892
|
class MdxSyntaxError extends SyntaxError {
|
|
109944
109893
|
original = null;
|
|
@@ -109960,6 +109909,22 @@ class MdxSyntaxError extends SyntaxError {
|
|
|
109960
109909
|
}
|
|
109961
109910
|
}
|
|
109962
109911
|
|
|
109912
|
+
;// ./processor/plugin/hard-breaks.ts
|
|
109913
|
+
|
|
109914
|
+
/**
|
|
109915
|
+
* Converts LF and CRLF line endings into hard breaks while leaving standalone
|
|
109916
|
+
* carriage returns as soft whitespace.
|
|
109917
|
+
*
|
|
109918
|
+
* Unlike `remark-breaks`, this does not promote a lone `\r` into a `<br>`.
|
|
109919
|
+
* Standalone carriage returns can be left behind by generators that replace
|
|
109920
|
+
* the LF in Windows line endings with an explicit `<br>`, producing input such
|
|
109921
|
+
* as `\r<br>`. Treating both characters as hard breaks doubles the spacing.
|
|
109922
|
+
*/
|
|
109923
|
+
const hardBreaks = () => tree => {
|
|
109924
|
+
findAndReplace(tree, [/\r?\n/g, () => ({ type: 'break' })]);
|
|
109925
|
+
};
|
|
109926
|
+
/* harmony default export */ const hard_breaks = (hardBreaks);
|
|
109927
|
+
|
|
109963
109928
|
;// ./node_modules/estree-util-value-to-estree/dist/estree-util-value-to-estree.js
|
|
109964
109929
|
/**
|
|
109965
109930
|
* Create an ESTree identifier node for a given name.
|
|
@@ -112664,7 +112629,7 @@ const compile_compile = (text, { components = {}, missingComponents, copyButtons
|
|
|
112664
112629
|
const remarkPlugins = [
|
|
112665
112630
|
remarkFrontmatter,
|
|
112666
112631
|
remarkGfm,
|
|
112667
|
-
...(hardBreaks ? [
|
|
112632
|
+
...(hardBreaks ? [hard_breaks] : []),
|
|
112668
112633
|
...Object.values(transforms),
|
|
112669
112634
|
[codeTabsTransformer, { copyButtons }],
|
|
112670
112635
|
[
|
|
@@ -119195,6 +119160,9 @@ function getComponentName(componentName, components) {
|
|
|
119195
119160
|
|
|
119196
119161
|
|
|
119197
119162
|
|
|
119163
|
+
// Foreign-content (SVG/MathML) roots — subtrees the component transform leaves
|
|
119164
|
+
// untouched (their children are namespaced XML, not HTML tags/components).
|
|
119165
|
+
const FOREIGN_CONTENT_ROOTS = new Set(FOREIGN_CONTENT_TAGS);
|
|
119198
119166
|
function isElementContentNode(node) {
|
|
119199
119167
|
return node.type === 'element' || node.type === 'text' || node.type === 'comment';
|
|
119200
119168
|
}
|
|
@@ -119370,6 +119338,12 @@ const rehypeMdxishComponents = ({ components, processMarkdown }) => {
|
|
|
119370
119338
|
visit(tree, 'element', (node, index, parent) => {
|
|
119371
119339
|
if (index === undefined || !parent)
|
|
119372
119340
|
return;
|
|
119341
|
+
// Skip foreign-content subtrees: their namespaced children (<path>, <mrow>, …)
|
|
119342
|
+
// aren't HTML tags or components, so the "unknown component" removal below would
|
|
119343
|
+
// otherwise delete them. (svg/math themselves are standard HTML tags, kept.)
|
|
119344
|
+
// eslint-disable-next-line consistent-return
|
|
119345
|
+
if (FOREIGN_CONTENT_ROOTS.has(node.tagName))
|
|
119346
|
+
return SKIP;
|
|
119373
119347
|
// Parse Image caption as markdown so it renders formatted (bold, code,
|
|
119374
119348
|
// decoded entities) in the figcaption instead of as a raw string.
|
|
119375
119349
|
// rehypeRaw strips children from <img> (void element), so we must
|
|
@@ -119681,6 +119655,81 @@ function closeSelfClosingHtmlTags(content) {
|
|
|
119681
119655
|
return restoreCodeBlocks(result, protectedCode);
|
|
119682
119656
|
}
|
|
119683
119657
|
|
|
119658
|
+
;// ./processor/transform/mdxish/collapse-foreign-content-blank-lines.ts
|
|
119659
|
+
|
|
119660
|
+
|
|
119661
|
+
// `svg|math`, from the canonical list so this stays in sync with the component transform.
|
|
119662
|
+
const ROOT_ALT = FOREIGN_CONTENT_TAGS.join('|');
|
|
119663
|
+
// A foreign-content opener. The `[\s/>]` boundary requires a real tag delimiter after the
|
|
119664
|
+
// root name, so lookalikes like `<svgfoo>` and custom elements like `<svg-icon>` are ignored.
|
|
119665
|
+
const ANY_ROOT_RE = new RegExp(`<(?:${ROOT_ALT})(?=[\\s/>])`, 'i');
|
|
119666
|
+
// Tag body: swallows whole quoted attribute values so a `>` inside a quote (e.g.
|
|
119667
|
+
// `<svg data-x="a > b" />`) can't be mistaken for the tag terminator; other non-`>`
|
|
119668
|
+
// chars (including newlines) are consumed one at a time.
|
|
119669
|
+
const TAG_BODY = '(?:"[^"]*"|\'[^\']*\'|[^>\'"])*?';
|
|
119670
|
+
// One whole svg/math tag (opener, self-closer, or closer), matched whole so attributes
|
|
119671
|
+
// and `>` may span lines. The `[\s/>]` boundary after the root name keeps `<svgfoo>`/
|
|
119672
|
+
// `<svg-icon>` out. Group 1 is `/` only for a self-closer.
|
|
119673
|
+
const FOREIGN_TAG_RE = new RegExp(`<(?:${ROOT_ALT})(?=[\\s/>])${TAG_BODY}(/)?>|</(?:${ROOT_ALT})(?=[\\s/>])${TAG_BODY}>`, 'gi');
|
|
119674
|
+
// An HTML comment. Foreign markup inside one is inert and must not open an island.
|
|
119675
|
+
const HTML_COMMENT_RE = /<!--[\s\S]*?-->/g;
|
|
119676
|
+
const withinAny = (spans, offset) => spans.some(([start, end]) => offset >= start && offset < end);
|
|
119677
|
+
/**
|
|
119678
|
+
* `[start, end)` spans of every *matched* SVG/MathML pair — the regions whose blank
|
|
119679
|
+
* lines are known-insignificant XML. Matching whole tags (not per-line open/close
|
|
119680
|
+
* counts) keeps multi-line openers and self-closers balanced, so a wrapped
|
|
119681
|
+
* `<svg … />` can't latch and swallow the doc (#1545).
|
|
119682
|
+
*
|
|
119683
|
+
* Tags are paired innermost-first, as a parser would; an opener still unpaired at EOF
|
|
119684
|
+
* closed nothing and so covers nothing. That keeps a stray `<svg>` in prose from
|
|
119685
|
+
* swallowing every blank line after it, without hiding the real islands that follow.
|
|
119686
|
+
*/
|
|
119687
|
+
function findForeignContentSpans(text) {
|
|
119688
|
+
const spans = [];
|
|
119689
|
+
// Foreign tags inside an HTML comment are inert; a stray `<svg>`/`<math>` in a comment
|
|
119690
|
+
// must not open an island and latch onto the rest of the doc.
|
|
119691
|
+
const comments = [...text.matchAll(HTML_COMMENT_RE)].map((m) => [m.index ?? 0, (m.index ?? 0) + m[0].length]);
|
|
119692
|
+
// Offsets of openers still waiting for their closer, innermost last.
|
|
119693
|
+
const openOffsets = [];
|
|
119694
|
+
[...text.matchAll(FOREIGN_TAG_RE)].forEach(match => {
|
|
119695
|
+
const offset = match.index ?? 0;
|
|
119696
|
+
if (withinAny(comments, offset))
|
|
119697
|
+
return; // markup inside an HTML comment is inert
|
|
119698
|
+
if (match[1] === '/')
|
|
119699
|
+
return; // self-closing tag opens no island
|
|
119700
|
+
if (match[0].startsWith('</')) {
|
|
119701
|
+
const start = openOffsets.pop();
|
|
119702
|
+
if (start !== undefined)
|
|
119703
|
+
spans.push([start, offset + match[0].length]); // a closer with no opener closes nothing
|
|
119704
|
+
}
|
|
119705
|
+
else {
|
|
119706
|
+
openOffsets.push(offset);
|
|
119707
|
+
}
|
|
119708
|
+
});
|
|
119709
|
+
return spans;
|
|
119710
|
+
}
|
|
119711
|
+
/**
|
|
119712
|
+
* Drop blank lines inside `<svg>`/`<math>` islands: their whitespace is
|
|
119713
|
+
* insignificant XML, but a blank line ends the CommonMark HTML block and spills the
|
|
119714
|
+
* children out as a code block (#1545). Collapsing keeps the island one block.
|
|
119715
|
+
*/
|
|
119716
|
+
function collapseForeignContentBlankLines(content) {
|
|
119717
|
+
// Fast path: nothing to do when the doc has no foreign-content island.
|
|
119718
|
+
if (!ANY_ROOT_RE.test(content))
|
|
119719
|
+
return content;
|
|
119720
|
+
const { protectedContent, protectedCode } = protectCodeBlocks(content);
|
|
119721
|
+
const islands = findForeignContentSpans(protectedContent);
|
|
119722
|
+
// Drop blank lines inside an island; keep everything else verbatim.
|
|
119723
|
+
const lines = [];
|
|
119724
|
+
let lineStart = 0;
|
|
119725
|
+
protectedContent.split('\n').forEach(line => {
|
|
119726
|
+
if (line.trim().length > 0 || !withinAny(islands, lineStart))
|
|
119727
|
+
lines.push(line);
|
|
119728
|
+
lineStart += line.length + 1; // +1 for the '\n' that split() removed
|
|
119729
|
+
});
|
|
119730
|
+
return restoreCodeBlocks(lines.join('\n'), protectedCode);
|
|
119731
|
+
}
|
|
119732
|
+
|
|
119684
119733
|
;// ./lib/utils/mdxish/mdxish-component-tag-parser.ts
|
|
119685
119734
|
// Extract the tag name (PascalCase or lowercase HTML) at the start of a tag string.
|
|
119686
119735
|
const tagNamePattern = /^<([A-Za-z][A-Za-z0-9_-]*)/;
|
|
@@ -122848,10 +122897,36 @@ const mdxishInlineMdxComponents = () => tree => {
|
|
|
122848
122897
|
};
|
|
122849
122898
|
/* harmony default export */ const inline_mdx_blocks = (mdxishInlineMdxComponents);
|
|
122850
122899
|
|
|
122900
|
+
;// ./processor/transform/mdxish/indentation.ts
|
|
122901
|
+
/**
|
|
122902
|
+
* CommonMark indentation helpers, shared by the mdxish preprocessors so tab- and
|
|
122903
|
+
* space-indented content is measured (and sliced) on one scale.
|
|
122904
|
+
*
|
|
122905
|
+
* CommonMark's indented-code threshold is 4 *columns*, and a tab is a 4-column tab
|
|
122906
|
+
* stop — not a fixed 4 characters. Counting characters (tab = 1) under-measures
|
|
122907
|
+
* tab-indented lines, letting them slip past the 4-column gate so their content
|
|
122908
|
+
* fragments into code blocks. Keeping one implementation here stops the two callers
|
|
122909
|
+
* from drifting on what "4 columns" means.
|
|
122910
|
+
*/
|
|
122911
|
+
/** The run of leading spaces/tabs on a line. */
|
|
122912
|
+
const leadingIndent = (line) => line.match(/^[ \t]*/)?.[0] ?? '';
|
|
122913
|
+
/**
|
|
122914
|
+
* Expand a leading-whitespace run to spaces using CommonMark's 4-column tab stops,
|
|
122915
|
+
* so a run of mixed tabs/spaces can be measured by length and sliced by column.
|
|
122916
|
+
*/
|
|
122917
|
+
function expandIndentToColumns(indent) {
|
|
122918
|
+
return indent
|
|
122919
|
+
.split('')
|
|
122920
|
+
.reduce((columns, char) => columns + (char === '\t' ? ' '.repeat(4 - (columns.length % 4)) : ' '), '');
|
|
122921
|
+
}
|
|
122922
|
+
/** Indentation width of a line in CommonMark columns (a tab advances to the next 4-column stop). */
|
|
122923
|
+
const indentWidth = (line) => expandIndentToColumns(leadingIndent(line)).length;
|
|
122924
|
+
|
|
122851
122925
|
;// ./processor/transform/mdxish/terminate-html-flow-blocks.ts
|
|
122852
122926
|
|
|
122853
122927
|
|
|
122854
122928
|
|
|
122929
|
+
|
|
122855
122930
|
const STANDALONE_HTML_LINE_REGEX = /^(<[a-z][^<>]*>|<\/[a-z][^<>]*>)+\s*$/;
|
|
122856
122931
|
const HTML_LINE_WITH_CONTENT_REGEX = /^<[a-z][^<>]*>.*<\/[a-z][^<>]*>(?:[^<]*)$/;
|
|
122857
122932
|
// A line that is exactly one lowercase opening (or self-closing) tag — the shape
|
|
@@ -122877,11 +122952,6 @@ function countRawContentTags(line) {
|
|
|
122877
122952
|
closes: (line.match(close) ?? []).length,
|
|
122878
122953
|
}));
|
|
122879
122954
|
}
|
|
122880
|
-
// Indentation width in columns, counting a tab as 4 per CommonMark.
|
|
122881
|
-
function indentWidth(line) {
|
|
122882
|
-
const leading = line.match(/^[ \t]*/)?.[0] ?? '';
|
|
122883
|
-
return leading.replace(/\t/g, ' ').length;
|
|
122884
|
-
}
|
|
122885
122955
|
/**
|
|
122886
122956
|
* Decides whether a blank line belongs between `line` and `next` so the HTML
|
|
122887
122957
|
* flow block opened on `line` terminates and `next` parses as markdown.
|
|
@@ -122953,6 +123023,7 @@ function terminateHtmlFlowBlocks(content) {
|
|
|
122953
123023
|
|
|
122954
123024
|
|
|
122955
123025
|
|
|
123026
|
+
|
|
122956
123027
|
// Matches a JSX attribute expression (e.g. `key={i}`) anywhere in a string. */
|
|
122957
123028
|
const NESTED_ATTR_EXPRESSION_RE = /[\w-]+\s*=\s*\{/;
|
|
122958
123029
|
// Name shape mirrors `componentTagPattern`; the lookbehind skips the inner tag
|
|
@@ -122963,25 +123034,33 @@ const NESTED_COMPONENT_TAG_RE = /(?<!<)<([A-Z][A-Za-z0-9_]*)[\s/>]/g;
|
|
|
122963
123034
|
const hasNestedGenericComponentTag = (content) => [...content.matchAll(NESTED_COMPONENT_TAG_RE)].some(match => !GENERIC_MDX_COMPONENT_EXCLUDED_TAGS.has(match[1]));
|
|
122964
123035
|
/**
|
|
122965
123036
|
* Strip the shared leading indentation from a component body so readability indentation
|
|
122966
|
-
* isn't parsed as indented code (4+
|
|
123037
|
+
* isn't parsed as indented code (4+ columns), e.g. ` <p>` / ` text` -> `<p>` / ` text`.
|
|
122967
123038
|
* Relative indentation is kept, so content genuinely 4+ columns deeper stays code. We
|
|
122968
123039
|
* only strip when a line actually reaches 4 columns; otherwise the body is left as-is so
|
|
122969
123040
|
* its leading whitespace survives as text nodes (mixed component + HTML content needs it).
|
|
123041
|
+
*
|
|
123042
|
+
* Indentation is measured in CommonMark columns (tab = up to 4), matching how the parser
|
|
123043
|
+
* decides indented code. A char count (tab = 1) under-measures tab-indented bodies, so
|
|
123044
|
+
* they slip past the 4-column gate and their nested content fragments into code blocks.
|
|
122970
123045
|
*/
|
|
122971
123046
|
function safeDeindent(text) {
|
|
122972
123047
|
const lines = text.split('\n');
|
|
122973
123048
|
const nonEmptyLines = lines.filter(line => line.trim().length > 0);
|
|
122974
123049
|
if (nonEmptyLines.length === 0)
|
|
122975
123050
|
return text;
|
|
122976
|
-
|
|
122977
|
-
// (tab = 4) in terminate-html-flow-blocks.
|
|
122978
|
-
const indents = nonEmptyLines.map(line => line.match(/^(\s*)/)?.[1].length ?? 0);
|
|
123051
|
+
const indents = nonEmptyLines.map(line => expandIndentToColumns(leadingIndent(line)).length);
|
|
122979
123052
|
const minIndent = Math.min(...indents);
|
|
122980
123053
|
const maxIndent = Math.max(...indents);
|
|
122981
|
-
|
|
122982
|
-
if (stripAmount === 0)
|
|
123054
|
+
if (maxIndent < 4 || minIndent === 0)
|
|
122983
123055
|
return text;
|
|
122984
|
-
|
|
123056
|
+
// Expand each line's leading run to spaces before slicing so a shared indent of mixed
|
|
123057
|
+
// tabs/spaces (and partial-tab remainders) strips cleanly while relative depth survives.
|
|
123058
|
+
return lines
|
|
123059
|
+
.map(line => {
|
|
123060
|
+
const indent = leadingIndent(line);
|
|
123061
|
+
return expandIndentToColumns(indent).slice(minIndent) + line.slice(indent.length);
|
|
123062
|
+
})
|
|
123063
|
+
.join('\n');
|
|
122985
123064
|
}
|
|
122986
123065
|
/**
|
|
122987
123066
|
* Parse component-body markdown into mdast children. Dedenting shifts columns and
|
|
@@ -124158,7 +124237,7 @@ const textToBlock = (text) => [{ children: textToInline(text), type: 'paragraph'
|
|
|
124158
124237
|
/**
|
|
124159
124238
|
* Converts leading newlines in magic block content to `<br>` tags.
|
|
124160
124239
|
* Leading newlines are stripped by remark-parse before they become soft break nodes,
|
|
124161
|
-
* so
|
|
124240
|
+
* so the hard-breaks plugin cannot handle them. We convert them to HTML `<br>` tags instead.
|
|
124162
124241
|
*/
|
|
124163
124242
|
const ensureLeadingBreaks = (text) => text.replace(/^\n+/, match => '<br>'.repeat(match.length));
|
|
124164
124243
|
/** Preprocesses magic block body content before parsing. */
|
|
@@ -124170,7 +124249,7 @@ const contentParser = unified()
|
|
|
124170
124249
|
.data('micromarkExtensions', [syntax_gemoji(), legacyVariable(), looseHtmlEntity()])
|
|
124171
124250
|
.data('fromMarkdownExtensions', [gemojiFromMarkdown(), legacyVariableFromMarkdown(), emptyTaskListItemFromMarkdown(), looseHtmlEntityFromMarkdown()])
|
|
124172
124251
|
.use(remarkParse)
|
|
124173
|
-
.use(
|
|
124252
|
+
.use(hard_breaks)
|
|
124174
124253
|
.use(remarkGfm)
|
|
124175
124254
|
.use(normalize_malformed_md_syntax);
|
|
124176
124255
|
/**
|
|
@@ -126790,6 +126869,7 @@ function loadComponents() {
|
|
|
126790
126869
|
|
|
126791
126870
|
|
|
126792
126871
|
|
|
126872
|
+
|
|
126793
126873
|
|
|
126794
126874
|
|
|
126795
126875
|
const defaultTransformers = [
|
|
@@ -126804,10 +126884,11 @@ const defaultTransformers = [
|
|
|
126804
126884
|
* Runs a series of string-level transformations before micromark/remark parsing:
|
|
126805
126885
|
* 1. Canonicalize closing tags with stray whitespace (e.g., `</ td >` → `</td>`)
|
|
126806
126886
|
* 2. Normalize malformed table separator syntax (e.g., `|: ---` → `| :---`)
|
|
126807
|
-
* 3.
|
|
126808
|
-
* 4.
|
|
126809
|
-
* 5.
|
|
126810
|
-
* 6.
|
|
126887
|
+
* 3. Collapse blank lines inside `<svg>`/`<math>` so their children aren't fragmented
|
|
126888
|
+
* 4. Terminate HTML flow blocks so subsequent content isn't swallowed
|
|
126889
|
+
* 5. Close invalid "self-closing" HTML tags (e.g., `<i />` → `<i></i>`)
|
|
126890
|
+
* 6. Normalize compact ATX headings (e.g., `#Heading` → `# Heading`)
|
|
126891
|
+
* 7. Replace snake_case component names with parser-safe placeholders
|
|
126811
126892
|
*/
|
|
126812
126893
|
function preprocessContent(content, opts) {
|
|
126813
126894
|
const { knownComponents } = opts;
|
|
@@ -126815,6 +126896,10 @@ function preprocessContent(content, opts) {
|
|
|
126815
126896
|
// classification in `terminateHtmlFlowBlocks` is accurate)
|
|
126816
126897
|
let result = normalizeClosingTagWhitespace(content);
|
|
126817
126898
|
result = normalizeTableSeparator(result);
|
|
126899
|
+
// Before terminateHtmlFlowBlocks: a blank line inside an <svg>/<math> island
|
|
126900
|
+
// would otherwise fragment it (children spill out as an indented code block once
|
|
126901
|
+
// a wrapper re-parses its deindented body — #1545).
|
|
126902
|
+
result = collapseForeignContentBlankLines(result);
|
|
126818
126903
|
result = terminateHtmlFlowBlocks(result);
|
|
126819
126904
|
result = closeSelfClosingHtmlTags(result);
|
|
126820
126905
|
result = normalizeCompactHeadings(result);
|
|
@@ -126954,7 +127039,7 @@ function mdxish(mdContent, opts = {}) {
|
|
|
126954
127039
|
const { processor, parserReadyContent } = mdxishAstProcessor(contentWithoutComments, opts);
|
|
126955
127040
|
processor
|
|
126956
127041
|
.use(safeMode ? undefined : evaluate_exports) // Evaluate `export const/function` and stash scope on file.data.mdxishScope
|
|
126957
|
-
.use(
|
|
127042
|
+
.use(hard_breaks) // Must precede evaluateExpressions to avoid splitting the \n in an evaluated template literal into a <br> node
|
|
126958
127043
|
.use(safeMode ? undefined : evaluate_expressions) // Evaluate self-contained MDX expressions (e.g. `{1+1}`)
|
|
126959
127044
|
.use(safeMode ? undefined : evaluate_style_block_expressions) // Evaluate `<style>{`...`}</style>` template literals into plain CSS
|
|
126960
127045
|
.use(variables_code, { variables }) // Resolve <<...>> and {user.*} inside code and inline code nodes
|
|
@@ -127538,6 +127623,8 @@ function restoreMagicBlocks(replaced, blocks) {
|
|
|
127538
127623
|
|
|
127539
127624
|
|
|
127540
127625
|
|
|
127626
|
+
|
|
127627
|
+
|
|
127541
127628
|
/**
|
|
127542
127629
|
* Removes Markdown and MDX comments.
|
|
127543
127630
|
*/
|
|
@@ -127548,10 +127635,16 @@ async function stripComments(doc, { mdx, mdxish } = {}) {
|
|
|
127548
127635
|
// 1. we can rely on remarkMdx to parse MDXish
|
|
127549
127636
|
// 2. we need to parse JSX comments into mdxTextExpression nodes so that the transformers can pick them up
|
|
127550
127637
|
// 3. we need to claim <HTMLBlock> before htmlFlow intercepts its inner HTML tags
|
|
127638
|
+
// 4. we need mdxComponent to parse custom components as one node, and prevent the tag from getting escaped
|
|
127551
127639
|
if (mdxish) {
|
|
127552
127640
|
processor
|
|
127553
|
-
.data('micromarkExtensions', [htmlBlockComponent(), jsxTable(), mdxExpression({ allowEmpty: true })])
|
|
127554
|
-
.data('fromMarkdownExtensions', [
|
|
127641
|
+
.data('micromarkExtensions', [htmlBlockComponent(), jsxTable(), mdxComponent(), mdxExpression({ allowEmpty: true })])
|
|
127642
|
+
.data('fromMarkdownExtensions', [
|
|
127643
|
+
htmlBlockComponentFromMarkdown(),
|
|
127644
|
+
jsxTableFromMarkdown(),
|
|
127645
|
+
mdxComponentFromMarkdown(),
|
|
127646
|
+
mdxExpressionFromMarkdown(),
|
|
127647
|
+
])
|
|
127555
127648
|
.data('toMarkdownExtensions', [mdxExpressionToMarkdown()]);
|
|
127556
127649
|
}
|
|
127557
127650
|
processor
|