@readme/markdown 14.12.0 → 14.12.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 +64 -75
- package/dist/main.node.js +62 -73
- package/dist/main.node.js.map +1 -1
- package/dist/processor/plugin/hard-breaks.d.ts +13 -0
- package/dist/processor/transform/mdxish/indentation.d.ts +19 -0
- package/dist/render-fixture.node.js +62 -73
- package/dist/render-fixture.node.js.map +1 -1
- package/package.json +1 -2
package/dist/main.js
CHANGED
|
@@ -1893,7 +1893,7 @@ module.exports = function (exec) {
|
|
|
1893
1893
|
|
|
1894
1894
|
/***/ }),
|
|
1895
1895
|
|
|
1896
|
-
/***/
|
|
1896
|
+
/***/ 1842:
|
|
1897
1897
|
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
1898
1898
|
|
|
1899
1899
|
module.exports = __webpack_require__(4556)('native-function-to-string', Function.toString);
|
|
@@ -2493,7 +2493,7 @@ var global = __webpack_require__(7526);
|
|
|
2493
2493
|
var hide = __webpack_require__(3341);
|
|
2494
2494
|
var has = __webpack_require__(7917);
|
|
2495
2495
|
var SRC = __webpack_require__(4415)('src');
|
|
2496
|
-
var $toString = __webpack_require__(
|
|
2496
|
+
var $toString = __webpack_require__(1842);
|
|
2497
2497
|
var TO_STRING = 'toString';
|
|
2498
2498
|
var TPL = ('' + $toString).split(TO_STRING);
|
|
2499
2499
|
|
|
@@ -89658,63 +89658,6 @@ function rehypeSanitize(options) {
|
|
|
89658
89658
|
}
|
|
89659
89659
|
}
|
|
89660
89660
|
|
|
89661
|
-
;// ./node_modules/mdast-util-newline-to-break/lib/index.js
|
|
89662
|
-
/**
|
|
89663
|
-
* @typedef {import('mdast').Nodes} Nodes
|
|
89664
|
-
* @typedef {import('mdast-util-find-and-replace').ReplaceFunction} ReplaceFunction
|
|
89665
|
-
*/
|
|
89666
|
-
|
|
89667
|
-
|
|
89668
|
-
|
|
89669
|
-
/**
|
|
89670
|
-
* Turn normal line endings into hard breaks.
|
|
89671
|
-
*
|
|
89672
|
-
* @param {Nodes} tree
|
|
89673
|
-
* Tree to change.
|
|
89674
|
-
* @returns {undefined}
|
|
89675
|
-
* Nothing.
|
|
89676
|
-
*/
|
|
89677
|
-
function newlineToBreak(tree) {
|
|
89678
|
-
findAndReplace(tree, [/\r?\n|\r/g, lib_replace])
|
|
89679
|
-
}
|
|
89680
|
-
|
|
89681
|
-
/**
|
|
89682
|
-
* Replace line endings.
|
|
89683
|
-
*
|
|
89684
|
-
* @type {ReplaceFunction}
|
|
89685
|
-
*/
|
|
89686
|
-
function lib_replace() {
|
|
89687
|
-
return {type: 'break'}
|
|
89688
|
-
}
|
|
89689
|
-
|
|
89690
|
-
;// ./node_modules/remark-breaks/lib/index.js
|
|
89691
|
-
/**
|
|
89692
|
-
* @typedef {import('mdast').Root} Root
|
|
89693
|
-
*/
|
|
89694
|
-
|
|
89695
|
-
|
|
89696
|
-
|
|
89697
|
-
/**
|
|
89698
|
-
* Support hard breaks without needing spaces or escapes (turns enters into
|
|
89699
|
-
* `<br>`s).
|
|
89700
|
-
*
|
|
89701
|
-
* @returns
|
|
89702
|
-
* Transform.
|
|
89703
|
-
*/
|
|
89704
|
-
function remarkBreaks() {
|
|
89705
|
-
/**
|
|
89706
|
-
* Transform.
|
|
89707
|
-
*
|
|
89708
|
-
* @param {Root} tree
|
|
89709
|
-
* Tree.
|
|
89710
|
-
* @returns {undefined}
|
|
89711
|
-
* Nothing.
|
|
89712
|
-
*/
|
|
89713
|
-
return function (tree) {
|
|
89714
|
-
newlineToBreak(tree)
|
|
89715
|
-
}
|
|
89716
|
-
}
|
|
89717
|
-
|
|
89718
89661
|
;// ./errors/mdx-syntax-error.ts
|
|
89719
89662
|
class MdxSyntaxError extends SyntaxError {
|
|
89720
89663
|
original = null;
|
|
@@ -89736,6 +89679,22 @@ class MdxSyntaxError extends SyntaxError {
|
|
|
89736
89679
|
}
|
|
89737
89680
|
}
|
|
89738
89681
|
|
|
89682
|
+
;// ./processor/plugin/hard-breaks.ts
|
|
89683
|
+
|
|
89684
|
+
/**
|
|
89685
|
+
* Converts LF and CRLF line endings into hard breaks while leaving standalone
|
|
89686
|
+
* carriage returns as soft whitespace.
|
|
89687
|
+
*
|
|
89688
|
+
* Unlike `remark-breaks`, this does not promote a lone `\r` into a `<br>`.
|
|
89689
|
+
* Standalone carriage returns can be left behind by generators that replace
|
|
89690
|
+
* the LF in Windows line endings with an explicit `<br>`, producing input such
|
|
89691
|
+
* as `\r<br>`. Treating both characters as hard breaks doubles the spacing.
|
|
89692
|
+
*/
|
|
89693
|
+
const hardBreaks = () => tree => {
|
|
89694
|
+
findAndReplace(tree, [/\r?\n/g, () => ({ type: 'break' })]);
|
|
89695
|
+
};
|
|
89696
|
+
/* harmony default export */ const hard_breaks = (hardBreaks);
|
|
89697
|
+
|
|
89739
89698
|
;// ./node_modules/estree-util-value-to-estree/dist/estree-util-value-to-estree.js
|
|
89740
89699
|
/**
|
|
89741
89700
|
* Create an ESTree identifier node for a given name.
|
|
@@ -92440,7 +92399,7 @@ const compile_compile = (text, { components = {}, missingComponents, copyButtons
|
|
|
92440
92399
|
const remarkPlugins = [
|
|
92441
92400
|
remarkFrontmatter,
|
|
92442
92401
|
remarkGfm,
|
|
92443
|
-
...(hardBreaks ? [
|
|
92402
|
+
...(hardBreaks ? [hard_breaks] : []),
|
|
92444
92403
|
...Object.values(transforms),
|
|
92445
92404
|
[codeTabsTransformer, { copyButtons }],
|
|
92446
92405
|
[
|
|
@@ -102624,10 +102583,36 @@ const mdxishInlineMdxComponents = () => tree => {
|
|
|
102624
102583
|
};
|
|
102625
102584
|
/* harmony default export */ const inline_mdx_blocks = (mdxishInlineMdxComponents);
|
|
102626
102585
|
|
|
102586
|
+
;// ./processor/transform/mdxish/indentation.ts
|
|
102587
|
+
/**
|
|
102588
|
+
* CommonMark indentation helpers, shared by the mdxish preprocessors so tab- and
|
|
102589
|
+
* space-indented content is measured (and sliced) on one scale.
|
|
102590
|
+
*
|
|
102591
|
+
* CommonMark's indented-code threshold is 4 *columns*, and a tab is a 4-column tab
|
|
102592
|
+
* stop — not a fixed 4 characters. Counting characters (tab = 1) under-measures
|
|
102593
|
+
* tab-indented lines, letting them slip past the 4-column gate so their content
|
|
102594
|
+
* fragments into code blocks. Keeping one implementation here stops the two callers
|
|
102595
|
+
* from drifting on what "4 columns" means.
|
|
102596
|
+
*/
|
|
102597
|
+
/** The run of leading spaces/tabs on a line. */
|
|
102598
|
+
const leadingIndent = (line) => line.match(/^[ \t]*/)?.[0] ?? '';
|
|
102599
|
+
/**
|
|
102600
|
+
* Expand a leading-whitespace run to spaces using CommonMark's 4-column tab stops,
|
|
102601
|
+
* so a run of mixed tabs/spaces can be measured by length and sliced by column.
|
|
102602
|
+
*/
|
|
102603
|
+
function expandIndentToColumns(indent) {
|
|
102604
|
+
return indent
|
|
102605
|
+
.split('')
|
|
102606
|
+
.reduce((columns, char) => columns + (char === '\t' ? ' '.repeat(4 - (columns.length % 4)) : ' '), '');
|
|
102607
|
+
}
|
|
102608
|
+
/** Indentation width of a line in CommonMark columns (a tab advances to the next 4-column stop). */
|
|
102609
|
+
const indentWidth = (line) => expandIndentToColumns(leadingIndent(line)).length;
|
|
102610
|
+
|
|
102627
102611
|
;// ./processor/transform/mdxish/terminate-html-flow-blocks.ts
|
|
102628
102612
|
|
|
102629
102613
|
|
|
102630
102614
|
|
|
102615
|
+
|
|
102631
102616
|
const STANDALONE_HTML_LINE_REGEX = /^(<[a-z][^<>]*>|<\/[a-z][^<>]*>)+\s*$/;
|
|
102632
102617
|
const HTML_LINE_WITH_CONTENT_REGEX = /^<[a-z][^<>]*>.*<\/[a-z][^<>]*>(?:[^<]*)$/;
|
|
102633
102618
|
// A line that is exactly one lowercase opening (or self-closing) tag — the shape
|
|
@@ -102653,11 +102638,6 @@ function countRawContentTags(line) {
|
|
|
102653
102638
|
closes: (line.match(close) ?? []).length,
|
|
102654
102639
|
}));
|
|
102655
102640
|
}
|
|
102656
|
-
// Indentation width in columns, counting a tab as 4 per CommonMark.
|
|
102657
|
-
function indentWidth(line) {
|
|
102658
|
-
const leading = line.match(/^[ \t]*/)?.[0] ?? '';
|
|
102659
|
-
return leading.replace(/\t/g, ' ').length;
|
|
102660
|
-
}
|
|
102661
102641
|
/**
|
|
102662
102642
|
* Decides whether a blank line belongs between `line` and `next` so the HTML
|
|
102663
102643
|
* flow block opened on `line` terminates and `next` parses as markdown.
|
|
@@ -102729,6 +102709,7 @@ function terminateHtmlFlowBlocks(content) {
|
|
|
102729
102709
|
|
|
102730
102710
|
|
|
102731
102711
|
|
|
102712
|
+
|
|
102732
102713
|
// Matches a JSX attribute expression (e.g. `key={i}`) anywhere in a string. */
|
|
102733
102714
|
const NESTED_ATTR_EXPRESSION_RE = /[\w-]+\s*=\s*\{/;
|
|
102734
102715
|
// Name shape mirrors `componentTagPattern`; the lookbehind skips the inner tag
|
|
@@ -102739,25 +102720,33 @@ const NESTED_COMPONENT_TAG_RE = /(?<!<)<([A-Z][A-Za-z0-9_]*)[\s/>]/g;
|
|
|
102739
102720
|
const hasNestedGenericComponentTag = (content) => [...content.matchAll(NESTED_COMPONENT_TAG_RE)].some(match => !GENERIC_MDX_COMPONENT_EXCLUDED_TAGS.has(match[1]));
|
|
102740
102721
|
/**
|
|
102741
102722
|
* Strip the shared leading indentation from a component body so readability indentation
|
|
102742
|
-
* isn't parsed as indented code (4+
|
|
102723
|
+
* isn't parsed as indented code (4+ columns), e.g. ` <p>` / ` text` -> `<p>` / ` text`.
|
|
102743
102724
|
* Relative indentation is kept, so content genuinely 4+ columns deeper stays code. We
|
|
102744
102725
|
* only strip when a line actually reaches 4 columns; otherwise the body is left as-is so
|
|
102745
102726
|
* its leading whitespace survives as text nodes (mixed component + HTML content needs it).
|
|
102727
|
+
*
|
|
102728
|
+
* Indentation is measured in CommonMark columns (tab = up to 4), matching how the parser
|
|
102729
|
+
* decides indented code. A char count (tab = 1) under-measures tab-indented bodies, so
|
|
102730
|
+
* they slip past the 4-column gate and their nested content fragments into code blocks.
|
|
102746
102731
|
*/
|
|
102747
102732
|
function safeDeindent(text) {
|
|
102748
102733
|
const lines = text.split('\n');
|
|
102749
102734
|
const nonEmptyLines = lines.filter(line => line.trim().length > 0);
|
|
102750
102735
|
if (nonEmptyLines.length === 0)
|
|
102751
102736
|
return text;
|
|
102752
|
-
|
|
102753
|
-
// (tab = 4) in terminate-html-flow-blocks.
|
|
102754
|
-
const indents = nonEmptyLines.map(line => line.match(/^(\s*)/)?.[1].length ?? 0);
|
|
102737
|
+
const indents = nonEmptyLines.map(line => expandIndentToColumns(leadingIndent(line)).length);
|
|
102755
102738
|
const minIndent = Math.min(...indents);
|
|
102756
102739
|
const maxIndent = Math.max(...indents);
|
|
102757
|
-
|
|
102758
|
-
if (stripAmount === 0)
|
|
102740
|
+
if (maxIndent < 4 || minIndent === 0)
|
|
102759
102741
|
return text;
|
|
102760
|
-
|
|
102742
|
+
// Expand each line's leading run to spaces before slicing so a shared indent of mixed
|
|
102743
|
+
// tabs/spaces (and partial-tab remainders) strips cleanly while relative depth survives.
|
|
102744
|
+
return lines
|
|
102745
|
+
.map(line => {
|
|
102746
|
+
const indent = leadingIndent(line);
|
|
102747
|
+
return expandIndentToColumns(indent).slice(minIndent) + line.slice(indent.length);
|
|
102748
|
+
})
|
|
102749
|
+
.join('\n');
|
|
102761
102750
|
}
|
|
102762
102751
|
/**
|
|
102763
102752
|
* Parse component-body markdown into mdast children. Dedenting shifts columns and
|
|
@@ -103934,7 +103923,7 @@ const textToBlock = (text) => [{ children: textToInline(text), type: 'paragraph'
|
|
|
103934
103923
|
/**
|
|
103935
103924
|
* Converts leading newlines in magic block content to `<br>` tags.
|
|
103936
103925
|
* Leading newlines are stripped by remark-parse before they become soft break nodes,
|
|
103937
|
-
* so
|
|
103926
|
+
* so the hard-breaks plugin cannot handle them. We convert them to HTML `<br>` tags instead.
|
|
103938
103927
|
*/
|
|
103939
103928
|
const ensureLeadingBreaks = (text) => text.replace(/^\n+/, match => '<br>'.repeat(match.length));
|
|
103940
103929
|
/** Preprocesses magic block body content before parsing. */
|
|
@@ -103946,7 +103935,7 @@ const contentParser = unified()
|
|
|
103946
103935
|
.data('micromarkExtensions', [syntax_gemoji(), legacyVariable(), looseHtmlEntity()])
|
|
103947
103936
|
.data('fromMarkdownExtensions', [gemojiFromMarkdown(), legacyVariableFromMarkdown(), emptyTaskListItemFromMarkdown(), looseHtmlEntityFromMarkdown()])
|
|
103948
103937
|
.use(remarkParse)
|
|
103949
|
-
.use(
|
|
103938
|
+
.use(hard_breaks)
|
|
103950
103939
|
.use(remarkGfm)
|
|
103951
103940
|
.use(normalize_malformed_md_syntax);
|
|
103952
103941
|
/**
|
|
@@ -106730,7 +106719,7 @@ function mdxish(mdContent, opts = {}) {
|
|
|
106730
106719
|
const { processor, parserReadyContent } = mdxishAstProcessor(contentWithoutComments, opts);
|
|
106731
106720
|
processor
|
|
106732
106721
|
.use(safeMode ? undefined : evaluate_exports) // Evaluate `export const/function` and stash scope on file.data.mdxishScope
|
|
106733
|
-
.use(
|
|
106722
|
+
.use(hard_breaks) // Must precede evaluateExpressions to avoid splitting the \n in an evaluated template literal into a <br> node
|
|
106734
106723
|
.use(safeMode ? undefined : evaluate_expressions) // Evaluate self-contained MDX expressions (e.g. `{1+1}`)
|
|
106735
106724
|
.use(safeMode ? undefined : evaluate_style_block_expressions) // Evaluate `<style>{`...`}</style>` template literals into plain CSS
|
|
106736
106725
|
.use(variables_code, { variables }) // Resolve <<...>> and {user.*} inside code and inline code nodes
|
package/dist/main.node.js
CHANGED
|
@@ -109882,63 +109882,6 @@ function rehypeSanitize(options) {
|
|
|
109882
109882
|
}
|
|
109883
109883
|
}
|
|
109884
109884
|
|
|
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
109885
|
;// ./errors/mdx-syntax-error.ts
|
|
109943
109886
|
class MdxSyntaxError extends SyntaxError {
|
|
109944
109887
|
original = null;
|
|
@@ -109960,6 +109903,22 @@ class MdxSyntaxError extends SyntaxError {
|
|
|
109960
109903
|
}
|
|
109961
109904
|
}
|
|
109962
109905
|
|
|
109906
|
+
;// ./processor/plugin/hard-breaks.ts
|
|
109907
|
+
|
|
109908
|
+
/**
|
|
109909
|
+
* Converts LF and CRLF line endings into hard breaks while leaving standalone
|
|
109910
|
+
* carriage returns as soft whitespace.
|
|
109911
|
+
*
|
|
109912
|
+
* Unlike `remark-breaks`, this does not promote a lone `\r` into a `<br>`.
|
|
109913
|
+
* Standalone carriage returns can be left behind by generators that replace
|
|
109914
|
+
* the LF in Windows line endings with an explicit `<br>`, producing input such
|
|
109915
|
+
* as `\r<br>`. Treating both characters as hard breaks doubles the spacing.
|
|
109916
|
+
*/
|
|
109917
|
+
const hardBreaks = () => tree => {
|
|
109918
|
+
findAndReplace(tree, [/\r?\n/g, () => ({ type: 'break' })]);
|
|
109919
|
+
};
|
|
109920
|
+
/* harmony default export */ const hard_breaks = (hardBreaks);
|
|
109921
|
+
|
|
109963
109922
|
;// ./node_modules/estree-util-value-to-estree/dist/estree-util-value-to-estree.js
|
|
109964
109923
|
/**
|
|
109965
109924
|
* Create an ESTree identifier node for a given name.
|
|
@@ -112664,7 +112623,7 @@ const compile_compile = (text, { components = {}, missingComponents, copyButtons
|
|
|
112664
112623
|
const remarkPlugins = [
|
|
112665
112624
|
remarkFrontmatter,
|
|
112666
112625
|
remarkGfm,
|
|
112667
|
-
...(hardBreaks ? [
|
|
112626
|
+
...(hardBreaks ? [hard_breaks] : []),
|
|
112668
112627
|
...Object.values(transforms),
|
|
112669
112628
|
[codeTabsTransformer, { copyButtons }],
|
|
112670
112629
|
[
|
|
@@ -122848,10 +122807,36 @@ const mdxishInlineMdxComponents = () => tree => {
|
|
|
122848
122807
|
};
|
|
122849
122808
|
/* harmony default export */ const inline_mdx_blocks = (mdxishInlineMdxComponents);
|
|
122850
122809
|
|
|
122810
|
+
;// ./processor/transform/mdxish/indentation.ts
|
|
122811
|
+
/**
|
|
122812
|
+
* CommonMark indentation helpers, shared by the mdxish preprocessors so tab- and
|
|
122813
|
+
* space-indented content is measured (and sliced) on one scale.
|
|
122814
|
+
*
|
|
122815
|
+
* CommonMark's indented-code threshold is 4 *columns*, and a tab is a 4-column tab
|
|
122816
|
+
* stop — not a fixed 4 characters. Counting characters (tab = 1) under-measures
|
|
122817
|
+
* tab-indented lines, letting them slip past the 4-column gate so their content
|
|
122818
|
+
* fragments into code blocks. Keeping one implementation here stops the two callers
|
|
122819
|
+
* from drifting on what "4 columns" means.
|
|
122820
|
+
*/
|
|
122821
|
+
/** The run of leading spaces/tabs on a line. */
|
|
122822
|
+
const leadingIndent = (line) => line.match(/^[ \t]*/)?.[0] ?? '';
|
|
122823
|
+
/**
|
|
122824
|
+
* Expand a leading-whitespace run to spaces using CommonMark's 4-column tab stops,
|
|
122825
|
+
* so a run of mixed tabs/spaces can be measured by length and sliced by column.
|
|
122826
|
+
*/
|
|
122827
|
+
function expandIndentToColumns(indent) {
|
|
122828
|
+
return indent
|
|
122829
|
+
.split('')
|
|
122830
|
+
.reduce((columns, char) => columns + (char === '\t' ? ' '.repeat(4 - (columns.length % 4)) : ' '), '');
|
|
122831
|
+
}
|
|
122832
|
+
/** Indentation width of a line in CommonMark columns (a tab advances to the next 4-column stop). */
|
|
122833
|
+
const indentWidth = (line) => expandIndentToColumns(leadingIndent(line)).length;
|
|
122834
|
+
|
|
122851
122835
|
;// ./processor/transform/mdxish/terminate-html-flow-blocks.ts
|
|
122852
122836
|
|
|
122853
122837
|
|
|
122854
122838
|
|
|
122839
|
+
|
|
122855
122840
|
const STANDALONE_HTML_LINE_REGEX = /^(<[a-z][^<>]*>|<\/[a-z][^<>]*>)+\s*$/;
|
|
122856
122841
|
const HTML_LINE_WITH_CONTENT_REGEX = /^<[a-z][^<>]*>.*<\/[a-z][^<>]*>(?:[^<]*)$/;
|
|
122857
122842
|
// A line that is exactly one lowercase opening (or self-closing) tag — the shape
|
|
@@ -122877,11 +122862,6 @@ function countRawContentTags(line) {
|
|
|
122877
122862
|
closes: (line.match(close) ?? []).length,
|
|
122878
122863
|
}));
|
|
122879
122864
|
}
|
|
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
122865
|
/**
|
|
122886
122866
|
* Decides whether a blank line belongs between `line` and `next` so the HTML
|
|
122887
122867
|
* flow block opened on `line` terminates and `next` parses as markdown.
|
|
@@ -122953,6 +122933,7 @@ function terminateHtmlFlowBlocks(content) {
|
|
|
122953
122933
|
|
|
122954
122934
|
|
|
122955
122935
|
|
|
122936
|
+
|
|
122956
122937
|
// Matches a JSX attribute expression (e.g. `key={i}`) anywhere in a string. */
|
|
122957
122938
|
const NESTED_ATTR_EXPRESSION_RE = /[\w-]+\s*=\s*\{/;
|
|
122958
122939
|
// Name shape mirrors `componentTagPattern`; the lookbehind skips the inner tag
|
|
@@ -122963,25 +122944,33 @@ const NESTED_COMPONENT_TAG_RE = /(?<!<)<([A-Z][A-Za-z0-9_]*)[\s/>]/g;
|
|
|
122963
122944
|
const hasNestedGenericComponentTag = (content) => [...content.matchAll(NESTED_COMPONENT_TAG_RE)].some(match => !GENERIC_MDX_COMPONENT_EXCLUDED_TAGS.has(match[1]));
|
|
122964
122945
|
/**
|
|
122965
122946
|
* Strip the shared leading indentation from a component body so readability indentation
|
|
122966
|
-
* isn't parsed as indented code (4+
|
|
122947
|
+
* isn't parsed as indented code (4+ columns), e.g. ` <p>` / ` text` -> `<p>` / ` text`.
|
|
122967
122948
|
* Relative indentation is kept, so content genuinely 4+ columns deeper stays code. We
|
|
122968
122949
|
* only strip when a line actually reaches 4 columns; otherwise the body is left as-is so
|
|
122969
122950
|
* its leading whitespace survives as text nodes (mixed component + HTML content needs it).
|
|
122951
|
+
*
|
|
122952
|
+
* Indentation is measured in CommonMark columns (tab = up to 4), matching how the parser
|
|
122953
|
+
* decides indented code. A char count (tab = 1) under-measures tab-indented bodies, so
|
|
122954
|
+
* they slip past the 4-column gate and their nested content fragments into code blocks.
|
|
122970
122955
|
*/
|
|
122971
122956
|
function safeDeindent(text) {
|
|
122972
122957
|
const lines = text.split('\n');
|
|
122973
122958
|
const nonEmptyLines = lines.filter(line => line.trim().length > 0);
|
|
122974
122959
|
if (nonEmptyLines.length === 0)
|
|
122975
122960
|
return text;
|
|
122976
|
-
|
|
122977
|
-
// (tab = 4) in terminate-html-flow-blocks.
|
|
122978
|
-
const indents = nonEmptyLines.map(line => line.match(/^(\s*)/)?.[1].length ?? 0);
|
|
122961
|
+
const indents = nonEmptyLines.map(line => expandIndentToColumns(leadingIndent(line)).length);
|
|
122979
122962
|
const minIndent = Math.min(...indents);
|
|
122980
122963
|
const maxIndent = Math.max(...indents);
|
|
122981
|
-
|
|
122982
|
-
if (stripAmount === 0)
|
|
122964
|
+
if (maxIndent < 4 || minIndent === 0)
|
|
122983
122965
|
return text;
|
|
122984
|
-
|
|
122966
|
+
// Expand each line's leading run to spaces before slicing so a shared indent of mixed
|
|
122967
|
+
// tabs/spaces (and partial-tab remainders) strips cleanly while relative depth survives.
|
|
122968
|
+
return lines
|
|
122969
|
+
.map(line => {
|
|
122970
|
+
const indent = leadingIndent(line);
|
|
122971
|
+
return expandIndentToColumns(indent).slice(minIndent) + line.slice(indent.length);
|
|
122972
|
+
})
|
|
122973
|
+
.join('\n');
|
|
122985
122974
|
}
|
|
122986
122975
|
/**
|
|
122987
122976
|
* Parse component-body markdown into mdast children. Dedenting shifts columns and
|
|
@@ -124158,7 +124147,7 @@ const textToBlock = (text) => [{ children: textToInline(text), type: 'paragraph'
|
|
|
124158
124147
|
/**
|
|
124159
124148
|
* Converts leading newlines in magic block content to `<br>` tags.
|
|
124160
124149
|
* Leading newlines are stripped by remark-parse before they become soft break nodes,
|
|
124161
|
-
* so
|
|
124150
|
+
* so the hard-breaks plugin cannot handle them. We convert them to HTML `<br>` tags instead.
|
|
124162
124151
|
*/
|
|
124163
124152
|
const ensureLeadingBreaks = (text) => text.replace(/^\n+/, match => '<br>'.repeat(match.length));
|
|
124164
124153
|
/** Preprocesses magic block body content before parsing. */
|
|
@@ -124170,7 +124159,7 @@ const contentParser = unified()
|
|
|
124170
124159
|
.data('micromarkExtensions', [syntax_gemoji(), legacyVariable(), looseHtmlEntity()])
|
|
124171
124160
|
.data('fromMarkdownExtensions', [gemojiFromMarkdown(), legacyVariableFromMarkdown(), emptyTaskListItemFromMarkdown(), looseHtmlEntityFromMarkdown()])
|
|
124172
124161
|
.use(remarkParse)
|
|
124173
|
-
.use(
|
|
124162
|
+
.use(hard_breaks)
|
|
124174
124163
|
.use(remarkGfm)
|
|
124175
124164
|
.use(normalize_malformed_md_syntax);
|
|
124176
124165
|
/**
|
|
@@ -126954,7 +126943,7 @@ function mdxish(mdContent, opts = {}) {
|
|
|
126954
126943
|
const { processor, parserReadyContent } = mdxishAstProcessor(contentWithoutComments, opts);
|
|
126955
126944
|
processor
|
|
126956
126945
|
.use(safeMode ? undefined : evaluate_exports) // Evaluate `export const/function` and stash scope on file.data.mdxishScope
|
|
126957
|
-
.use(
|
|
126946
|
+
.use(hard_breaks) // Must precede evaluateExpressions to avoid splitting the \n in an evaluated template literal into a <br> node
|
|
126958
126947
|
.use(safeMode ? undefined : evaluate_expressions) // Evaluate self-contained MDX expressions (e.g. `{1+1}`)
|
|
126959
126948
|
.use(safeMode ? undefined : evaluate_style_block_expressions) // Evaluate `<style>{`...`}</style>` template literals into plain CSS
|
|
126960
126949
|
.use(variables_code, { variables }) // Resolve <<...>> and {user.*} inside code and inline code nodes
|