@readme/markdown 15.7.0 → 15.7.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/example/components.d.ts +1 -0
- package/dist/lib/micromark/mdx-component/continuation-checks.d.ts +0 -1
- package/dist/main.js +43 -84
- package/dist/main.node.js +43 -84
- package/dist/main.node.js.map +1 -1
- package/dist/render-fixture.node.js +43 -84
- package/dist/render-fixture.node.js.map +1 -1
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -76043,31 +76043,11 @@ const HTML_VOID_ELEMENTS = new Set([
|
|
|
76043
76043
|
|
|
76044
76044
|
|
|
76045
76045
|
/**
|
|
76046
|
-
* Partial
|
|
76047
|
-
* decide whether the next line continues the block.
|
|
76048
|
-
* `syntax.ts`) because
|
|
76046
|
+
* Partial construct the `mdxComponent` tokenizer runs via `effects.check` to
|
|
76047
|
+
* decide whether the next line continues the block. It lives here (not in
|
|
76048
|
+
* `syntax.ts`) because it holds none of `createTokenize`'s closure state — it
|
|
76049
76049
|
* is a self-contained, single-line lookahead.
|
|
76050
76050
|
*/
|
|
76051
|
-
function continuation_checks_tokenizeNonLazyContinuationStart(effects, ok, nok) {
|
|
76052
|
-
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
76053
|
-
const self = this;
|
|
76054
|
-
return start;
|
|
76055
|
-
function start(code) {
|
|
76056
|
-
if (markdownLineEnding(code)) {
|
|
76057
|
-
effects.enter(types.lineEnding);
|
|
76058
|
-
effects.consume(code);
|
|
76059
|
-
effects.exit(types.lineEnding);
|
|
76060
|
-
return after;
|
|
76061
|
-
}
|
|
76062
|
-
return nok(code);
|
|
76063
|
-
}
|
|
76064
|
-
function after(code) {
|
|
76065
|
-
if (self.parser.lazy[self.now().line]) {
|
|
76066
|
-
return nok(code);
|
|
76067
|
-
}
|
|
76068
|
-
return ok(code);
|
|
76069
|
-
}
|
|
76070
|
-
}
|
|
76071
76051
|
// A markup-only line opens with a tag (`<x`/`</x`) and ends (ignoring trailing
|
|
76072
76052
|
// spaces) at a `>`. That distinguishes a structural continuation like
|
|
76073
76053
|
// `<span>b</span></div>` from a paragraph like `<b>Note:</b> read *this*`.
|
|
@@ -76108,12 +76088,6 @@ function tokenizeMarkupOnlyContinuation(effects, ok, nok) {
|
|
|
76108
76088
|
return scanToLineEnd;
|
|
76109
76089
|
}
|
|
76110
76090
|
}
|
|
76111
|
-
// A line ending whose next line isn't a lazy paragraph continuation. Checked so a
|
|
76112
|
-
// component body's blank/continuation lines aren't stolen by an interrupted paragraph.
|
|
76113
|
-
const continuation_checks_nonLazyContinuationStart = {
|
|
76114
|
-
tokenize: continuation_checks_tokenizeNonLazyContinuationStart,
|
|
76115
|
-
partial: true,
|
|
76116
|
-
};
|
|
76117
76091
|
// Lookahead for `plainClaimLineStart`: is this line markup-only, or a paragraph
|
|
76118
76092
|
// that merely starts with a tag? Run via `effects.check` so it never consumes.
|
|
76119
76093
|
const markupOnlyContinuation = {
|
|
@@ -76529,14 +76503,7 @@ function syntax_createTokenize(mode) {
|
|
|
76529
76503
|
}
|
|
76530
76504
|
// Continuation for multi-line opening tags
|
|
76531
76505
|
function openTagContinuationStart(code) {
|
|
76532
|
-
return
|
|
76533
|
-
}
|
|
76534
|
-
function openTagContinuationNonLazy(code) {
|
|
76535
|
-
sawLineEnding = true;
|
|
76536
|
-
effects.enter(types.lineEnding);
|
|
76537
|
-
effects.consume(code);
|
|
76538
|
-
effects.exit(types.lineEnding);
|
|
76539
|
-
return openTagContinuationBefore;
|
|
76506
|
+
return continueOnNextLine(code, openTagContinuationBefore);
|
|
76540
76507
|
}
|
|
76541
76508
|
function openTagContinuationBefore(code) {
|
|
76542
76509
|
if (code === null || markdownLineEnding(code)) {
|
|
@@ -76654,14 +76621,7 @@ function syntax_createTokenize(mode) {
|
|
|
76654
76621
|
return inFencedCode;
|
|
76655
76622
|
}
|
|
76656
76623
|
function fencedCodeContinuationStart(code) {
|
|
76657
|
-
return
|
|
76658
|
-
}
|
|
76659
|
-
function fencedCodeContinuationNonLazy(code) {
|
|
76660
|
-
sawLineEnding = true;
|
|
76661
|
-
effects.enter(types.lineEnding);
|
|
76662
|
-
effects.consume(code);
|
|
76663
|
-
effects.exit(types.lineEnding);
|
|
76664
|
-
return fencedCodeContinuationBefore;
|
|
76624
|
+
return continueOnNextLine(code, fencedCodeContinuationBefore);
|
|
76665
76625
|
}
|
|
76666
76626
|
function fencedCodeContinuationBefore(code) {
|
|
76667
76627
|
if (code === null || markdownLineEnding(code)) {
|
|
@@ -76878,14 +76838,7 @@ function syntax_createTokenize(mode) {
|
|
|
76878
76838
|
}
|
|
76879
76839
|
// ── Body continuation (line endings) ───────────────────────────────────
|
|
76880
76840
|
function bodyContinuationStart(code) {
|
|
76881
|
-
return
|
|
76882
|
-
}
|
|
76883
|
-
function bodyContinuationNonLazy(code) {
|
|
76884
|
-
sawLineEnding = true;
|
|
76885
|
-
effects.enter(types.lineEnding);
|
|
76886
|
-
effects.consume(code);
|
|
76887
|
-
effects.exit(types.lineEnding);
|
|
76888
|
-
return bodyContinuationBefore;
|
|
76841
|
+
return continueOnNextLine(code, bodyContinuationBefore);
|
|
76889
76842
|
}
|
|
76890
76843
|
function bodyContinuationBefore(code) {
|
|
76891
76844
|
if (code === null || markdownLineEnding(code)) {
|
|
@@ -76954,13 +76907,18 @@ function syntax_createTokenize(mode) {
|
|
|
76954
76907
|
pendingBlankLine = false;
|
|
76955
76908
|
return bodyLineStart(code);
|
|
76956
76909
|
}
|
|
76957
|
-
// ── Shared
|
|
76958
|
-
|
|
76959
|
-
|
|
76910
|
+
// ── Shared line-ending continuation ────────────────────────────────────
|
|
76911
|
+
// Consumes one line ending and resumes at `nextLine`. Lazy lines (under-indented
|
|
76912
|
+
// under a list item or blockquote) continue too: a claim only ends at its closing
|
|
76913
|
+
// tag, and an unclosed one fails whole at EOF instead of leaving a truncated opener (CX-3940).
|
|
76914
|
+
function continueOnNextLine(code, nextLine) {
|
|
76915
|
+
if (!markdownLineEnding(code))
|
|
76960
76916
|
return nok(code);
|
|
76961
|
-
|
|
76962
|
-
effects.
|
|
76963
|
-
|
|
76917
|
+
sawLineEnding = true;
|
|
76918
|
+
effects.enter(types.lineEnding);
|
|
76919
|
+
effects.consume(code);
|
|
76920
|
+
effects.exit(types.lineEnding);
|
|
76921
|
+
return nextLine;
|
|
76964
76922
|
}
|
|
76965
76923
|
};
|
|
76966
76924
|
}
|
|
@@ -104800,7 +104758,7 @@ const parseMdChildren = (value, safeMode) => {
|
|
|
104800
104758
|
// Promote nested wrappers bottom-up so an outer wrapper sees markdown buried in a
|
|
104801
104759
|
// child claimed whole (e.g. `<li>` in `<ol>`) before its containsMarkdownConstruct check (RM-17560).
|
|
104802
104760
|
// eslint-disable-next-line @typescript-eslint/no-use-before-define -- mutually recursive; hoisted decl, safe at runtime
|
|
104803
|
-
promoteComponentBlocks(parsed, safeMode,
|
|
104761
|
+
promoteComponentBlocks(parsed, safeMode, reparseSource);
|
|
104804
104762
|
const children = parsed.children || [];
|
|
104805
104763
|
// These children root a new coordinate space: their offsets index into `reparseSource`.
|
|
104806
104764
|
stampReparseSource(children, reparseSource);
|
|
@@ -104819,23 +104777,26 @@ const parseSibling = (parent, index, sibling, safeMode, promoted) => {
|
|
|
104819
104777
|
}
|
|
104820
104778
|
};
|
|
104821
104779
|
// Ends the position at `consumedLength` so the component doesn't claim trailing
|
|
104822
|
-
// content the tokenizer swallowed into the same html node.
|
|
104823
|
-
|
|
104780
|
+
// content the tokenizer swallowed into the same html node. Measured against the source
|
|
104781
|
+
// when available: each value line is its source line minus the container prefix
|
|
104782
|
+
// (list indent, `> `) micromark stripped, so those prefixes are counted back in.
|
|
104783
|
+
const positionEndingAtConsumed = (nodePosition, value, consumedLength, source) => {
|
|
104824
104784
|
if (!nodePosition?.start)
|
|
104825
104785
|
return nodePosition;
|
|
104826
|
-
|
|
104827
|
-
|
|
104828
|
-
|
|
104829
|
-
|
|
104830
|
-
|
|
104831
|
-
|
|
104832
|
-
|
|
104833
|
-
const
|
|
104834
|
-
const
|
|
104835
|
-
|
|
104836
|
-
|
|
104837
|
-
|
|
104838
|
-
|
|
104786
|
+
const consumedValue = value.slice(0, consumedLength);
|
|
104787
|
+
const sourceLines = source?.slice(nodePosition.start.offset, nodePosition.end?.offset).split('\n');
|
|
104788
|
+
const valueLines = value.split('\n');
|
|
104789
|
+
if (!sourceLines || sourceLines.length !== valueLines.length) {
|
|
104790
|
+
return { start: nodePosition.start, end: pointAfter(nodePosition.start, consumedValue) };
|
|
104791
|
+
}
|
|
104792
|
+
const consumedLines = consumedValue.split('\n');
|
|
104793
|
+
const lastLineIndex = consumedLines.length - 1;
|
|
104794
|
+
const prefixWidth = sourceLines[lastLineIndex].length - valueLines[lastLineIndex].length;
|
|
104795
|
+
const consumedSource = [
|
|
104796
|
+
...sourceLines.slice(0, lastLineIndex),
|
|
104797
|
+
sourceLines[lastLineIndex].slice(0, prefixWidth + consumedLines[lastLineIndex].length),
|
|
104798
|
+
].join('\n');
|
|
104799
|
+
return { start: nodePosition.start, end: pointAfter(nodePosition.start, consumedSource) };
|
|
104839
104800
|
};
|
|
104840
104801
|
const createComponentNode = ({ tag, attributes, children, startPosition, endPosition, }) => ({
|
|
104841
104802
|
type: 'mdxJsxFlowElement',
|
|
@@ -104942,16 +104903,18 @@ function promoteComponentBlocks(tree, safeMode, source) {
|
|
|
104942
104903
|
const closingTagStr = `</${tag}>`;
|
|
104943
104904
|
// Case 1: Self-closing tag
|
|
104944
104905
|
if (selfClosing) {
|
|
104906
|
+
const remainingContent = contentAfterTag.trim();
|
|
104945
104907
|
const componentNode = createComponentNode({
|
|
104946
104908
|
tag,
|
|
104947
104909
|
attributes,
|
|
104948
104910
|
children: [],
|
|
104949
104911
|
startPosition: node.position,
|
|
104950
|
-
//
|
|
104951
|
-
endPosition:
|
|
104912
|
+
// Without trailing content the whole node position is correct; with it, end at the tag.
|
|
104913
|
+
endPosition: remainingContent
|
|
104914
|
+
? positionEndingAtConsumed(node.position, value, leadingWhitespace + openingTagEnd, source)
|
|
104915
|
+
: node.position,
|
|
104952
104916
|
});
|
|
104953
104917
|
substituteNodeWithMdxNode(parent, index, componentNode);
|
|
104954
|
-
const remainingContent = contentAfterTag.trim();
|
|
104955
104918
|
if (remainingContent) {
|
|
104956
104919
|
parseSibling(parent, index, remainingContent, safeMode, promoted);
|
|
104957
104920
|
}
|
|
@@ -104990,14 +104953,10 @@ function promoteComponentBlocks(tree, safeMode, source) {
|
|
|
104990
104953
|
stampReparseSource(parsedChildren, soleParagraph.data.reparseSource);
|
|
104991
104954
|
unwrappedSoleParagraph = true;
|
|
104992
104955
|
}
|
|
104993
|
-
// Without trailing content the whole node position is correct
|
|
104994
|
-
// precisely at the closing tag — preferring source offsets when available (the
|
|
104995
|
-
// node's value strips blockquote/list prefixes), else the consumed span.
|
|
104956
|
+
// Without trailing content the whole node position is correct; with it, end at the closing tag.
|
|
104996
104957
|
let endPosition = node.position;
|
|
104997
104958
|
if (contentAfterClose) {
|
|
104998
|
-
endPosition = source
|
|
104999
|
-
? positionEndingAtClosingTagInSource(node.position, closingTagStr, source)
|
|
105000
|
-
: positionEndingAtConsumed(node.position, value, leadingWhitespace + openingTagEnd + closingTagIndex + closingTagStr.length);
|
|
104959
|
+
endPosition = positionEndingAtConsumed(node.position, value, leadingWhitespace + openingTagEnd + closingTagIndex + closingTagStr.length, source);
|
|
105001
104960
|
}
|
|
105002
104961
|
const componentNode = createComponentNode({
|
|
105003
104962
|
tag,
|
package/dist/main.node.js
CHANGED
|
@@ -96226,31 +96226,11 @@ const HTML_VOID_ELEMENTS = new Set([
|
|
|
96226
96226
|
|
|
96227
96227
|
|
|
96228
96228
|
/**
|
|
96229
|
-
* Partial
|
|
96230
|
-
* decide whether the next line continues the block.
|
|
96231
|
-
* `syntax.ts`) because
|
|
96229
|
+
* Partial construct the `mdxComponent` tokenizer runs via `effects.check` to
|
|
96230
|
+
* decide whether the next line continues the block. It lives here (not in
|
|
96231
|
+
* `syntax.ts`) because it holds none of `createTokenize`'s closure state — it
|
|
96232
96232
|
* is a self-contained, single-line lookahead.
|
|
96233
96233
|
*/
|
|
96234
|
-
function continuation_checks_tokenizeNonLazyContinuationStart(effects, ok, nok) {
|
|
96235
|
-
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
96236
|
-
const self = this;
|
|
96237
|
-
return start;
|
|
96238
|
-
function start(code) {
|
|
96239
|
-
if (markdownLineEnding(code)) {
|
|
96240
|
-
effects.enter(types_types.lineEnding);
|
|
96241
|
-
effects.consume(code);
|
|
96242
|
-
effects.exit(types_types.lineEnding);
|
|
96243
|
-
return after;
|
|
96244
|
-
}
|
|
96245
|
-
return nok(code);
|
|
96246
|
-
}
|
|
96247
|
-
function after(code) {
|
|
96248
|
-
if (self.parser.lazy[self.now().line]) {
|
|
96249
|
-
return nok(code);
|
|
96250
|
-
}
|
|
96251
|
-
return ok(code);
|
|
96252
|
-
}
|
|
96253
|
-
}
|
|
96254
96234
|
// A markup-only line opens with a tag (`<x`/`</x`) and ends (ignoring trailing
|
|
96255
96235
|
// spaces) at a `>`. That distinguishes a structural continuation like
|
|
96256
96236
|
// `<span>b</span></div>` from a paragraph like `<b>Note:</b> read *this*`.
|
|
@@ -96291,12 +96271,6 @@ function tokenizeMarkupOnlyContinuation(effects, ok, nok) {
|
|
|
96291
96271
|
return scanToLineEnd;
|
|
96292
96272
|
}
|
|
96293
96273
|
}
|
|
96294
|
-
// A line ending whose next line isn't a lazy paragraph continuation. Checked so a
|
|
96295
|
-
// component body's blank/continuation lines aren't stolen by an interrupted paragraph.
|
|
96296
|
-
const continuation_checks_nonLazyContinuationStart = {
|
|
96297
|
-
tokenize: continuation_checks_tokenizeNonLazyContinuationStart,
|
|
96298
|
-
partial: true,
|
|
96299
|
-
};
|
|
96300
96274
|
// Lookahead for `plainClaimLineStart`: is this line markup-only, or a paragraph
|
|
96301
96275
|
// that merely starts with a tag? Run via `effects.check` so it never consumes.
|
|
96302
96276
|
const markupOnlyContinuation = {
|
|
@@ -96712,14 +96686,7 @@ function syntax_createTokenize(mode) {
|
|
|
96712
96686
|
}
|
|
96713
96687
|
// Continuation for multi-line opening tags
|
|
96714
96688
|
function openTagContinuationStart(code) {
|
|
96715
|
-
return
|
|
96716
|
-
}
|
|
96717
|
-
function openTagContinuationNonLazy(code) {
|
|
96718
|
-
sawLineEnding = true;
|
|
96719
|
-
effects.enter(types_types.lineEnding);
|
|
96720
|
-
effects.consume(code);
|
|
96721
|
-
effects.exit(types_types.lineEnding);
|
|
96722
|
-
return openTagContinuationBefore;
|
|
96689
|
+
return continueOnNextLine(code, openTagContinuationBefore);
|
|
96723
96690
|
}
|
|
96724
96691
|
function openTagContinuationBefore(code) {
|
|
96725
96692
|
if (code === null || markdownLineEnding(code)) {
|
|
@@ -96837,14 +96804,7 @@ function syntax_createTokenize(mode) {
|
|
|
96837
96804
|
return inFencedCode;
|
|
96838
96805
|
}
|
|
96839
96806
|
function fencedCodeContinuationStart(code) {
|
|
96840
|
-
return
|
|
96841
|
-
}
|
|
96842
|
-
function fencedCodeContinuationNonLazy(code) {
|
|
96843
|
-
sawLineEnding = true;
|
|
96844
|
-
effects.enter(types_types.lineEnding);
|
|
96845
|
-
effects.consume(code);
|
|
96846
|
-
effects.exit(types_types.lineEnding);
|
|
96847
|
-
return fencedCodeContinuationBefore;
|
|
96807
|
+
return continueOnNextLine(code, fencedCodeContinuationBefore);
|
|
96848
96808
|
}
|
|
96849
96809
|
function fencedCodeContinuationBefore(code) {
|
|
96850
96810
|
if (code === null || markdownLineEnding(code)) {
|
|
@@ -97061,14 +97021,7 @@ function syntax_createTokenize(mode) {
|
|
|
97061
97021
|
}
|
|
97062
97022
|
// ── Body continuation (line endings) ───────────────────────────────────
|
|
97063
97023
|
function bodyContinuationStart(code) {
|
|
97064
|
-
return
|
|
97065
|
-
}
|
|
97066
|
-
function bodyContinuationNonLazy(code) {
|
|
97067
|
-
sawLineEnding = true;
|
|
97068
|
-
effects.enter(types_types.lineEnding);
|
|
97069
|
-
effects.consume(code);
|
|
97070
|
-
effects.exit(types_types.lineEnding);
|
|
97071
|
-
return bodyContinuationBefore;
|
|
97024
|
+
return continueOnNextLine(code, bodyContinuationBefore);
|
|
97072
97025
|
}
|
|
97073
97026
|
function bodyContinuationBefore(code) {
|
|
97074
97027
|
if (code === null || markdownLineEnding(code)) {
|
|
@@ -97137,13 +97090,18 @@ function syntax_createTokenize(mode) {
|
|
|
97137
97090
|
pendingBlankLine = false;
|
|
97138
97091
|
return bodyLineStart(code);
|
|
97139
97092
|
}
|
|
97140
|
-
// ── Shared
|
|
97141
|
-
|
|
97142
|
-
|
|
97093
|
+
// ── Shared line-ending continuation ────────────────────────────────────
|
|
97094
|
+
// Consumes one line ending and resumes at `nextLine`. Lazy lines (under-indented
|
|
97095
|
+
// under a list item or blockquote) continue too: a claim only ends at its closing
|
|
97096
|
+
// tag, and an unclosed one fails whole at EOF instead of leaving a truncated opener (CX-3940).
|
|
97097
|
+
function continueOnNextLine(code, nextLine) {
|
|
97098
|
+
if (!markdownLineEnding(code))
|
|
97143
97099
|
return nok(code);
|
|
97144
|
-
|
|
97145
|
-
effects.
|
|
97146
|
-
|
|
97100
|
+
sawLineEnding = true;
|
|
97101
|
+
effects.enter(types_types.lineEnding);
|
|
97102
|
+
effects.consume(code);
|
|
97103
|
+
effects.exit(types_types.lineEnding);
|
|
97104
|
+
return nextLine;
|
|
97147
97105
|
}
|
|
97148
97106
|
};
|
|
97149
97107
|
}
|
|
@@ -124983,7 +124941,7 @@ const parseMdChildren = (value, safeMode) => {
|
|
|
124983
124941
|
// Promote nested wrappers bottom-up so an outer wrapper sees markdown buried in a
|
|
124984
124942
|
// child claimed whole (e.g. `<li>` in `<ol>`) before its containsMarkdownConstruct check (RM-17560).
|
|
124985
124943
|
// eslint-disable-next-line @typescript-eslint/no-use-before-define -- mutually recursive; hoisted decl, safe at runtime
|
|
124986
|
-
promoteComponentBlocks(parsed, safeMode,
|
|
124944
|
+
promoteComponentBlocks(parsed, safeMode, reparseSource);
|
|
124987
124945
|
const children = parsed.children || [];
|
|
124988
124946
|
// These children root a new coordinate space: their offsets index into `reparseSource`.
|
|
124989
124947
|
stampReparseSource(children, reparseSource);
|
|
@@ -125002,23 +124960,26 @@ const parseSibling = (parent, index, sibling, safeMode, promoted) => {
|
|
|
125002
124960
|
}
|
|
125003
124961
|
};
|
|
125004
124962
|
// Ends the position at `consumedLength` so the component doesn't claim trailing
|
|
125005
|
-
// content the tokenizer swallowed into the same html node.
|
|
125006
|
-
|
|
124963
|
+
// content the tokenizer swallowed into the same html node. Measured against the source
|
|
124964
|
+
// when available: each value line is its source line minus the container prefix
|
|
124965
|
+
// (list indent, `> `) micromark stripped, so those prefixes are counted back in.
|
|
124966
|
+
const positionEndingAtConsumed = (nodePosition, value, consumedLength, source) => {
|
|
125007
124967
|
if (!nodePosition?.start)
|
|
125008
124968
|
return nodePosition;
|
|
125009
|
-
|
|
125010
|
-
|
|
125011
|
-
|
|
125012
|
-
|
|
125013
|
-
|
|
125014
|
-
|
|
125015
|
-
|
|
125016
|
-
const
|
|
125017
|
-
const
|
|
125018
|
-
|
|
125019
|
-
|
|
125020
|
-
|
|
125021
|
-
|
|
124969
|
+
const consumedValue = value.slice(0, consumedLength);
|
|
124970
|
+
const sourceLines = source?.slice(nodePosition.start.offset, nodePosition.end?.offset).split('\n');
|
|
124971
|
+
const valueLines = value.split('\n');
|
|
124972
|
+
if (!sourceLines || sourceLines.length !== valueLines.length) {
|
|
124973
|
+
return { start: nodePosition.start, end: pointAfter(nodePosition.start, consumedValue) };
|
|
124974
|
+
}
|
|
124975
|
+
const consumedLines = consumedValue.split('\n');
|
|
124976
|
+
const lastLineIndex = consumedLines.length - 1;
|
|
124977
|
+
const prefixWidth = sourceLines[lastLineIndex].length - valueLines[lastLineIndex].length;
|
|
124978
|
+
const consumedSource = [
|
|
124979
|
+
...sourceLines.slice(0, lastLineIndex),
|
|
124980
|
+
sourceLines[lastLineIndex].slice(0, prefixWidth + consumedLines[lastLineIndex].length),
|
|
124981
|
+
].join('\n');
|
|
124982
|
+
return { start: nodePosition.start, end: pointAfter(nodePosition.start, consumedSource) };
|
|
125022
124983
|
};
|
|
125023
124984
|
const createComponentNode = ({ tag, attributes, children, startPosition, endPosition, }) => ({
|
|
125024
124985
|
type: 'mdxJsxFlowElement',
|
|
@@ -125125,16 +125086,18 @@ function promoteComponentBlocks(tree, safeMode, source) {
|
|
|
125125
125086
|
const closingTagStr = `</${tag}>`;
|
|
125126
125087
|
// Case 1: Self-closing tag
|
|
125127
125088
|
if (selfClosing) {
|
|
125089
|
+
const remainingContent = contentAfterTag.trim();
|
|
125128
125090
|
const componentNode = createComponentNode({
|
|
125129
125091
|
tag,
|
|
125130
125092
|
attributes,
|
|
125131
125093
|
children: [],
|
|
125132
125094
|
startPosition: node.position,
|
|
125133
|
-
//
|
|
125134
|
-
endPosition:
|
|
125095
|
+
// Without trailing content the whole node position is correct; with it, end at the tag.
|
|
125096
|
+
endPosition: remainingContent
|
|
125097
|
+
? positionEndingAtConsumed(node.position, value, leadingWhitespace + openingTagEnd, source)
|
|
125098
|
+
: node.position,
|
|
125135
125099
|
});
|
|
125136
125100
|
substituteNodeWithMdxNode(parent, index, componentNode);
|
|
125137
|
-
const remainingContent = contentAfterTag.trim();
|
|
125138
125101
|
if (remainingContent) {
|
|
125139
125102
|
parseSibling(parent, index, remainingContent, safeMode, promoted);
|
|
125140
125103
|
}
|
|
@@ -125173,14 +125136,10 @@ function promoteComponentBlocks(tree, safeMode, source) {
|
|
|
125173
125136
|
stampReparseSource(parsedChildren, soleParagraph.data.reparseSource);
|
|
125174
125137
|
unwrappedSoleParagraph = true;
|
|
125175
125138
|
}
|
|
125176
|
-
// Without trailing content the whole node position is correct
|
|
125177
|
-
// precisely at the closing tag — preferring source offsets when available (the
|
|
125178
|
-
// node's value strips blockquote/list prefixes), else the consumed span.
|
|
125139
|
+
// Without trailing content the whole node position is correct; with it, end at the closing tag.
|
|
125179
125140
|
let endPosition = node.position;
|
|
125180
125141
|
if (contentAfterClose) {
|
|
125181
|
-
endPosition = source
|
|
125182
|
-
? positionEndingAtClosingTagInSource(node.position, closingTagStr, source)
|
|
125183
|
-
: positionEndingAtConsumed(node.position, value, leadingWhitespace + openingTagEnd + closingTagIndex + closingTagStr.length);
|
|
125142
|
+
endPosition = positionEndingAtConsumed(node.position, value, leadingWhitespace + openingTagEnd + closingTagIndex + closingTagStr.length, source);
|
|
125184
125143
|
}
|
|
125185
125144
|
const componentNode = createComponentNode({
|
|
125186
125145
|
tag,
|