@readme/markdown 14.11.1 → 14.11.3
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/TableOfContents/index.tsx +29 -1
- package/dist/339.node.js +2 -2
- package/dist/486.node.js +4 -4
- package/dist/lib/mdast-util/html-block-component/index.d.ts +2 -0
- package/dist/lib/micromark/html-block-component/index.d.ts +1 -0
- package/dist/lib/micromark/html-block-component/syntax.d.ts +8 -0
- package/dist/main.js +412 -7
- package/dist/main.node.js +412 -7
- package/dist/main.node.js.map +1 -1
- package/dist/processor/transform/mdxish/tables/escape-stray-less-than.d.ts +9 -0
- package/dist/render-fixture.node.js +595 -190
- package/dist/render-fixture.node.js.map +1 -1
- package/package.json +1 -1
|
@@ -83,6 +83,34 @@ function useScrollHighlight(navRef: React.RefObject<HTMLElement | null>) {
|
|
|
83
83
|
&& scrollParent.scrollTop + scrollParent.clientHeight >= scrollParent.scrollHeight - SCROLL_BOTTOM_TOLERANCE;
|
|
84
84
|
};
|
|
85
85
|
|
|
86
|
+
/**
|
|
87
|
+
* Keeps the active link visible within the TOC's own scroll container —
|
|
88
|
+
* the same result as `scrollIntoView({ block: 'nearest' })`, but scoped to
|
|
89
|
+
* a single scroller. `scrollIntoView` adjusts *every* scrollable ancestor,
|
|
90
|
+
* and starting a scroll on the page's content scroller cancels any
|
|
91
|
+
* in-flight smooth scroll there — e.g. the hub's scroll-to-top reset when
|
|
92
|
+
* navigating between pages (CX-3667).
|
|
93
|
+
*/
|
|
94
|
+
const scrollTOCLinkIntoView = (link: HTMLAnchorElement) => {
|
|
95
|
+
const tocScroller = getScrollParent(link);
|
|
96
|
+
// Without a TOC-local scroll area, the link's nearest scrollable
|
|
97
|
+
// ancestor is the window (`getScrollParent`'s fallback) or the scroller
|
|
98
|
+
// holding the page content — never auto-scroll those just to reveal a
|
|
99
|
+
// TOC link.
|
|
100
|
+
if (!(tocScroller instanceof HTMLElement) || tocScroller.contains(headings[0])) return;
|
|
101
|
+
|
|
102
|
+
const scrollerRect = tocScroller.getBoundingClientRect();
|
|
103
|
+
const linkRect = link.getBoundingClientRect();
|
|
104
|
+
if (linkRect.top < scrollerRect.top) {
|
|
105
|
+
tocScroller.scrollTo?.({ top: tocScroller.scrollTop + (linkRect.top - scrollerRect.top), behavior: 'smooth' });
|
|
106
|
+
} else if (linkRect.bottom > scrollerRect.bottom) {
|
|
107
|
+
tocScroller.scrollTo?.({
|
|
108
|
+
top: tocScroller.scrollTop + (linkRect.bottom - scrollerRect.bottom),
|
|
109
|
+
behavior: 'smooth',
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
|
|
86
114
|
const activate = (id: string | null) => {
|
|
87
115
|
if (id === activeId) return;
|
|
88
116
|
if (activeId) linkMap.get(activeId)?.forEach(a => a.classList.remove('active'));
|
|
@@ -100,7 +128,7 @@ function useScrollHighlight(navRef: React.RefObject<HTMLElement | null>) {
|
|
|
100
128
|
nav.style.setProperty('--ToC-border-active-height', `${linkRect.height}px`);
|
|
101
129
|
nav.style.setProperty('--ToC-border-active-top', `${linkRect.top - navRect.top}px`);
|
|
102
130
|
|
|
103
|
-
link
|
|
131
|
+
scrollTOCLinkIntoView(link);
|
|
104
132
|
}
|
|
105
133
|
}
|
|
106
134
|
};
|
package/dist/339.node.js
CHANGED
|
@@ -1012,7 +1012,7 @@ var _arrayPush = __webpack_require__(9);
|
|
|
1012
1012
|
// EXTERNAL MODULE: ./node_modules/lodash-es/_Symbol.js
|
|
1013
1013
|
var _Symbol = __webpack_require__(8066);
|
|
1014
1014
|
// EXTERNAL MODULE: ./node_modules/lodash-es/isArguments.js + 1 modules
|
|
1015
|
-
var isArguments = __webpack_require__(
|
|
1015
|
+
var isArguments = __webpack_require__(3800);
|
|
1016
1016
|
// EXTERNAL MODULE: ./node_modules/lodash-es/isArray.js
|
|
1017
1017
|
var isArray = __webpack_require__(9990);
|
|
1018
1018
|
;// ./node_modules/lodash-es/_isFlattenable.js
|
|
@@ -2482,7 +2482,7 @@ var getSymbolsIn = !nativeGetSymbols ? _stubArray_js__WEBPACK_IMPORTED_MODULE_0_
|
|
|
2482
2482
|
/* harmony export */ A: () => (__WEBPACK_DEFAULT_EXPORT__)
|
|
2483
2483
|
/* harmony export */ });
|
|
2484
2484
|
/* harmony import */ var _castPath_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2689);
|
|
2485
|
-
/* harmony import */ var _isArguments_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(
|
|
2485
|
+
/* harmony import */ var _isArguments_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(3800);
|
|
2486
2486
|
/* harmony import */ var _isArray_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(9990);
|
|
2487
2487
|
/* harmony import */ var _isIndex_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(8912);
|
|
2488
2488
|
/* harmony import */ var _isLength_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(3627);
|
package/dist/486.node.js
CHANGED
|
@@ -12552,7 +12552,7 @@ function baseTimes(n, iteratee) {
|
|
|
12552
12552
|
/* harmony default export */ const _baseTimes = (baseTimes);
|
|
12553
12553
|
|
|
12554
12554
|
// EXTERNAL MODULE: ./node_modules/lodash-es/isArguments.js + 1 modules
|
|
12555
|
-
var isArguments = __webpack_require__(
|
|
12555
|
+
var isArguments = __webpack_require__(3800);
|
|
12556
12556
|
// EXTERNAL MODULE: ./node_modules/lodash-es/isArray.js
|
|
12557
12557
|
var isArray = __webpack_require__(9990);
|
|
12558
12558
|
// EXTERNAL MODULE: ./node_modules/lodash-es/isBuffer.js + 1 modules
|
|
@@ -14118,7 +14118,7 @@ function identity(value) {
|
|
|
14118
14118
|
|
|
14119
14119
|
/***/ }),
|
|
14120
14120
|
|
|
14121
|
-
/***/
|
|
14121
|
+
/***/ 3800:
|
|
14122
14122
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
14123
14123
|
|
|
14124
14124
|
"use strict";
|
|
@@ -14407,7 +14407,7 @@ var isBuffer = nativeIsBuffer || lodash_es_stubFalse;
|
|
|
14407
14407
|
/* harmony export */ });
|
|
14408
14408
|
/* harmony import */ var _baseKeys_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(6279);
|
|
14409
14409
|
/* harmony import */ var _getTag_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(1424);
|
|
14410
|
-
/* harmony import */ var _isArguments_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(
|
|
14410
|
+
/* harmony import */ var _isArguments_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(3800);
|
|
14411
14411
|
/* harmony import */ var _isArray_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(9990);
|
|
14412
14412
|
/* harmony import */ var _isArrayLike_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1585);
|
|
14413
14413
|
/* harmony import */ var _isBuffer_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(1719);
|
|
@@ -15032,7 +15032,7 @@ var _copyArray = __webpack_require__(1810);
|
|
|
15032
15032
|
// EXTERNAL MODULE: ./node_modules/lodash-es/_initCloneObject.js + 1 modules
|
|
15033
15033
|
var _initCloneObject = __webpack_require__(2247);
|
|
15034
15034
|
// EXTERNAL MODULE: ./node_modules/lodash-es/isArguments.js + 1 modules
|
|
15035
|
-
var isArguments = __webpack_require__(
|
|
15035
|
+
var isArguments = __webpack_require__(3800);
|
|
15036
15036
|
// EXTERNAL MODULE: ./node_modules/lodash-es/isArray.js
|
|
15037
15037
|
var isArray = __webpack_require__(9990);
|
|
15038
15038
|
// EXTERNAL MODULE: ./node_modules/lodash-es/isArrayLikeObject.js
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { htmlBlockComponent } from './syntax';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Extension } from 'micromark-util-types';
|
|
2
|
+
declare module 'micromark-util-types' {
|
|
3
|
+
interface TokenTypeMap {
|
|
4
|
+
htmlBlockComponent: 'htmlBlockComponent';
|
|
5
|
+
htmlBlockComponentData: 'htmlBlockComponentData';
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
export declare function htmlBlockComponent(): Extension;
|
package/dist/main.js
CHANGED
|
@@ -12484,6 +12484,34 @@ function useScrollHighlight(navRef) {
|
|
|
12484
12484
|
return scrollParent.scrollHeight > scrollParent.clientHeight
|
|
12485
12485
|
&& scrollParent.scrollTop + scrollParent.clientHeight >= scrollParent.scrollHeight - SCROLL_BOTTOM_TOLERANCE;
|
|
12486
12486
|
};
|
|
12487
|
+
/**
|
|
12488
|
+
* Keeps the active link visible within the TOC's own scroll container —
|
|
12489
|
+
* the same result as `scrollIntoView({ block: 'nearest' })`, but scoped to
|
|
12490
|
+
* a single scroller. `scrollIntoView` adjusts *every* scrollable ancestor,
|
|
12491
|
+
* and starting a scroll on the page's content scroller cancels any
|
|
12492
|
+
* in-flight smooth scroll there — e.g. the hub's scroll-to-top reset when
|
|
12493
|
+
* navigating between pages (CX-3667).
|
|
12494
|
+
*/
|
|
12495
|
+
const scrollTOCLinkIntoView = (link) => {
|
|
12496
|
+
const tocScroller = getScrollParent(link);
|
|
12497
|
+
// Without a TOC-local scroll area, the link's nearest scrollable
|
|
12498
|
+
// ancestor is the window (`getScrollParent`'s fallback) or the scroller
|
|
12499
|
+
// holding the page content — never auto-scroll those just to reveal a
|
|
12500
|
+
// TOC link.
|
|
12501
|
+
if (!(tocScroller instanceof HTMLElement) || tocScroller.contains(headings[0]))
|
|
12502
|
+
return;
|
|
12503
|
+
const scrollerRect = tocScroller.getBoundingClientRect();
|
|
12504
|
+
const linkRect = link.getBoundingClientRect();
|
|
12505
|
+
if (linkRect.top < scrollerRect.top) {
|
|
12506
|
+
tocScroller.scrollTo?.({ top: tocScroller.scrollTop + (linkRect.top - scrollerRect.top), behavior: 'smooth' });
|
|
12507
|
+
}
|
|
12508
|
+
else if (linkRect.bottom > scrollerRect.bottom) {
|
|
12509
|
+
tocScroller.scrollTo?.({
|
|
12510
|
+
top: tocScroller.scrollTop + (linkRect.bottom - scrollerRect.bottom),
|
|
12511
|
+
behavior: 'smooth',
|
|
12512
|
+
});
|
|
12513
|
+
}
|
|
12514
|
+
};
|
|
12487
12515
|
const activate = (id) => {
|
|
12488
12516
|
if (id === activeId)
|
|
12489
12517
|
return;
|
|
@@ -12500,7 +12528,7 @@ function useScrollHighlight(navRef) {
|
|
|
12500
12528
|
const linkRect = link.getBoundingClientRect();
|
|
12501
12529
|
nav.style.setProperty('--ToC-border-active-height', `${linkRect.height}px`);
|
|
12502
12530
|
nav.style.setProperty('--ToC-border-active-top', `${linkRect.top - navRect.top}px`);
|
|
12503
|
-
link
|
|
12531
|
+
scrollTOCLinkIntoView(link);
|
|
12504
12532
|
}
|
|
12505
12533
|
}
|
|
12506
12534
|
};
|
|
@@ -75767,6 +75795,32 @@ const applyInserts = (html, inserts) => {
|
|
|
75767
75795
|
return { value: out + html.slice(cursor), inserts: sorted };
|
|
75768
75796
|
};
|
|
75769
75797
|
|
|
75798
|
+
;// ./processor/transform/mdxish/tables/escape-stray-less-than.ts
|
|
75799
|
+
|
|
75800
|
+
|
|
75801
|
+
// A `<` only starts a JSX/HTML construct when followed by a tag-name start
|
|
75802
|
+
// (letter, `_`, `$`), a closer `/`, a fragment `>`, or a comment/declaration
|
|
75803
|
+
// `!`. Anything else (whitespace, EOL, a digit, …) is a literal `<` that acorn
|
|
75804
|
+
// rejects with "before name, expected a character that can start a name".
|
|
75805
|
+
const STRAY_LESS_THAN_RE = /<(?![a-zA-Z_$/>!])/g;
|
|
75806
|
+
/**
|
|
75807
|
+
* Escapes stray `<` characters that don't begin a valid tag so the strict mdxjs
|
|
75808
|
+
* parse treats them as literal text instead of throwing (`word <`, `a <1>`).
|
|
75809
|
+
*
|
|
75810
|
+
* Runs against the masked source so `<` inside code spans, legacy `<<var>>`
|
|
75811
|
+
* syntax, or already-escaped `\<` are left untouched.
|
|
75812
|
+
*/
|
|
75813
|
+
const escapeStrayLessThan = (html) => {
|
|
75814
|
+
const masked = maskNonTagRegions(html);
|
|
75815
|
+
const inserts = [];
|
|
75816
|
+
STRAY_LESS_THAN_RE.lastIndex = 0;
|
|
75817
|
+
let match;
|
|
75818
|
+
while ((match = STRAY_LESS_THAN_RE.exec(masked)) !== null) {
|
|
75819
|
+
inserts.push({ offset: match.index, text: '\\' });
|
|
75820
|
+
}
|
|
75821
|
+
return applyInserts(html, inserts);
|
|
75822
|
+
};
|
|
75823
|
+
|
|
75770
75824
|
;// ./processor/transform/mdxish/tables/normalize-tag-spacing.ts
|
|
75771
75825
|
|
|
75772
75826
|
|
|
@@ -76266,6 +76320,7 @@ const repairUnclosedTags = (html) => {
|
|
|
76266
76320
|
|
|
76267
76321
|
|
|
76268
76322
|
|
|
76323
|
+
|
|
76269
76324
|
|
|
76270
76325
|
|
|
76271
76326
|
const isTableCell = (node) => isMDXElement(node) && ['th', 'td'].includes(node.name);
|
|
@@ -76552,11 +76607,14 @@ const mdxishTables = () => tree => {
|
|
|
76552
76607
|
// - normalizeTagSpacing: a line mixing text and an opening tag
|
|
76553
76608
|
// (e.g. `text <div> \n <div> text`)
|
|
76554
76609
|
// - repairExpressionEscapes: backslash escapes inside a `{…}` expression
|
|
76610
|
+
// - escapeStrayLessThan: a `<` that doesn't begin a valid tag
|
|
76611
|
+
// (e.g. `word <`, `a <1>`)
|
|
76555
76612
|
// These repairs are created after seeing real customer content that has failed to parse
|
|
76556
76613
|
const repairs = [
|
|
76557
76614
|
repairUnclosedTags,
|
|
76558
76615
|
normalizeTagSpacing,
|
|
76559
76616
|
repairExpressionEscapes,
|
|
76617
|
+
escapeStrayLessThan,
|
|
76560
76618
|
];
|
|
76561
76619
|
// Stops at the first repair that yields a parseable tree
|
|
76562
76620
|
repairs.some(repair => {
|
|
@@ -98715,6 +98773,21 @@ function isActualHtmlTag(tagName, originalExcerpt) {
|
|
|
98715
98773
|
return true;
|
|
98716
98774
|
return false;
|
|
98717
98775
|
}
|
|
98776
|
+
/**
|
|
98777
|
+
* Re-parsing a component's text child treats it as a standalone document, so
|
|
98778
|
+
* content that happens to start with the literal word `export`/`import`
|
|
98779
|
+
* (e.g. link text like "export Lorem Ipsum") sits at true column 1 and
|
|
98780
|
+
* gets mistaken for an MDX ESM statement, which then fails to parse as JS.
|
|
98781
|
+
* Fall back to `undefined` rather than letting one such child crash the page.
|
|
98782
|
+
*/
|
|
98783
|
+
function tryProcessMarkdown(processMarkdown, content) {
|
|
98784
|
+
try {
|
|
98785
|
+
return processMarkdown(content);
|
|
98786
|
+
}
|
|
98787
|
+
catch {
|
|
98788
|
+
return undefined;
|
|
98789
|
+
}
|
|
98790
|
+
}
|
|
98718
98791
|
/** Parse and replace text children with processed markdown */
|
|
98719
98792
|
function parseTextChildren(node, processMarkdown, components) {
|
|
98720
98793
|
if (!node.children?.length)
|
|
@@ -98729,7 +98802,9 @@ function parseTextChildren(node, processMarkdown, components) {
|
|
|
98729
98802
|
node.properties = { ...node.properties, children: child.value };
|
|
98730
98803
|
return [];
|
|
98731
98804
|
}
|
|
98732
|
-
const hast = processMarkdown
|
|
98805
|
+
const hast = tryProcessMarkdown(processMarkdown, child.value.trim());
|
|
98806
|
+
if (!hast)
|
|
98807
|
+
return [child];
|
|
98733
98808
|
const children = (hast.children ?? []).filter(isElementContentNode);
|
|
98734
98809
|
// For inline components, preserve plain text instead of wrapping in <p>
|
|
98735
98810
|
if (INLINE_COMPONENT_TAGS_LOWER.has(node.tagName.toLowerCase()) && isSingleParagraphTextNode(children)) {
|
|
@@ -98803,8 +98878,9 @@ const rehypeMdxishComponents = ({ components, processMarkdown }) => {
|
|
|
98803
98878
|
// rehypeRaw strips children from <img> (void element), so we must
|
|
98804
98879
|
// re-process the caption here, after rehypeRaw.
|
|
98805
98880
|
if (node.tagName === 'img' && typeof node.properties?.caption === 'string' && !node.children?.length) {
|
|
98806
|
-
const
|
|
98807
|
-
|
|
98881
|
+
const caption = node.properties.caption;
|
|
98882
|
+
const captionHast = tryProcessMarkdown(processMarkdown, caption);
|
|
98883
|
+
node.children = captionHast ? (captionHast.children ?? []).filter(isElementContentNode) : [{ type: 'text', value: caption }];
|
|
98808
98884
|
}
|
|
98809
98885
|
// Skip runtime components and standard HTML tags
|
|
98810
98886
|
if (RUNTIME_COMPONENT_TAGS.has(node.tagName))
|
|
@@ -106355,6 +106431,332 @@ const mdxishTags_tags = (doc) => {
|
|
|
106355
106431
|
};
|
|
106356
106432
|
/* harmony default export */ const mdxishTags = (mdxishTags_tags);
|
|
106357
106433
|
|
|
106434
|
+
;// ./lib/mdast-util/html-block-component/index.ts
|
|
106435
|
+
const html_block_component_contextMap = new WeakMap();
|
|
106436
|
+
function findHtmlBlockComponentToken() {
|
|
106437
|
+
const events = this.tokenStack;
|
|
106438
|
+
for (let i = events.length - 1; i >= 0; i -= 1) {
|
|
106439
|
+
if (events[i][0].type === 'htmlBlockComponent')
|
|
106440
|
+
return events[i][0];
|
|
106441
|
+
}
|
|
106442
|
+
return undefined;
|
|
106443
|
+
}
|
|
106444
|
+
function enterHtmlBlockComponent(token) {
|
|
106445
|
+
html_block_component_contextMap.set(token, { chunks: [], lastEndLine: token.start.line });
|
|
106446
|
+
this.enter({ type: 'html', value: '' }, token);
|
|
106447
|
+
}
|
|
106448
|
+
function exitHtmlBlockComponentData(token) {
|
|
106449
|
+
const componentToken = findHtmlBlockComponentToken.call(this);
|
|
106450
|
+
if (!componentToken)
|
|
106451
|
+
return;
|
|
106452
|
+
const ctx = html_block_component_contextMap.get(componentToken);
|
|
106453
|
+
if (ctx) {
|
|
106454
|
+
const gap = token.start.line - ctx.lastEndLine;
|
|
106455
|
+
if (ctx.chunks.length > 0 && gap > 0) {
|
|
106456
|
+
ctx.chunks.push('\n'.repeat(gap));
|
|
106457
|
+
}
|
|
106458
|
+
ctx.chunks.push(this.sliceSerialize(token));
|
|
106459
|
+
ctx.lastEndLine = token.end.line;
|
|
106460
|
+
}
|
|
106461
|
+
}
|
|
106462
|
+
function exitHtmlBlockComponent(token) {
|
|
106463
|
+
const ctx = html_block_component_contextMap.get(token);
|
|
106464
|
+
const node = this.stack[this.stack.length - 1];
|
|
106465
|
+
if (ctx) {
|
|
106466
|
+
node.value = ctx.chunks.join('');
|
|
106467
|
+
html_block_component_contextMap.delete(token);
|
|
106468
|
+
}
|
|
106469
|
+
this.exit(token);
|
|
106470
|
+
}
|
|
106471
|
+
function htmlBlockComponentFromMarkdown() {
|
|
106472
|
+
return {
|
|
106473
|
+
enter: {
|
|
106474
|
+
htmlBlockComponent: enterHtmlBlockComponent,
|
|
106475
|
+
},
|
|
106476
|
+
exit: {
|
|
106477
|
+
htmlBlockComponentData: exitHtmlBlockComponentData,
|
|
106478
|
+
htmlBlockComponent: exitHtmlBlockComponent,
|
|
106479
|
+
},
|
|
106480
|
+
};
|
|
106481
|
+
}
|
|
106482
|
+
|
|
106483
|
+
;// ./lib/micromark/html-block-component/syntax.ts
|
|
106484
|
+
|
|
106485
|
+
|
|
106486
|
+
const TAG_SUFFIX = [
|
|
106487
|
+
codes.uppercaseT,
|
|
106488
|
+
codes.uppercaseM,
|
|
106489
|
+
codes.uppercaseL,
|
|
106490
|
+
codes.uppercaseB,
|
|
106491
|
+
codes.lowercaseL,
|
|
106492
|
+
codes.lowercaseO,
|
|
106493
|
+
codes.lowercaseC,
|
|
106494
|
+
codes.lowercaseK,
|
|
106495
|
+
];
|
|
106496
|
+
// ---------------------------------------------------------------------------
|
|
106497
|
+
// Shared tokenizer factory
|
|
106498
|
+
// ---------------------------------------------------------------------------
|
|
106499
|
+
/**
|
|
106500
|
+
* Creates a tokenize function for `<HTMLBlock>...</HTMLBlock>`.
|
|
106501
|
+
*
|
|
106502
|
+
* - **flow** (block-level): supports multiline content via line continuations,
|
|
106503
|
+
* consumes trailing whitespace after the closing tag.
|
|
106504
|
+
* - **text** (inline): single-line only, exits immediately after the closing tag.
|
|
106505
|
+
*/
|
|
106506
|
+
function syntax_createTokenize(mode) {
|
|
106507
|
+
return function tokenize(effects, ok, nok) {
|
|
106508
|
+
let depth = 1;
|
|
106509
|
+
function matchChars(chars, onMatch, onFail) {
|
|
106510
|
+
if (chars.length === 0)
|
|
106511
|
+
return onMatch;
|
|
106512
|
+
const next = (code) => {
|
|
106513
|
+
if (code === chars[0]) {
|
|
106514
|
+
effects.consume(code);
|
|
106515
|
+
return matchChars(chars.slice(1), onMatch, onFail);
|
|
106516
|
+
}
|
|
106517
|
+
return onFail(code);
|
|
106518
|
+
};
|
|
106519
|
+
return next;
|
|
106520
|
+
}
|
|
106521
|
+
function matchTagName(onMatch, onFail) {
|
|
106522
|
+
const next = (code) => {
|
|
106523
|
+
if (code === codes.uppercaseH) {
|
|
106524
|
+
effects.consume(code);
|
|
106525
|
+
return matchChars(TAG_SUFFIX, onMatch, onFail);
|
|
106526
|
+
}
|
|
106527
|
+
return onFail(code);
|
|
106528
|
+
};
|
|
106529
|
+
return next;
|
|
106530
|
+
}
|
|
106531
|
+
return start;
|
|
106532
|
+
function start(code) {
|
|
106533
|
+
if (code !== codes.lessThan)
|
|
106534
|
+
return nok(code);
|
|
106535
|
+
effects.enter('htmlBlockComponent');
|
|
106536
|
+
effects.enter('htmlBlockComponentData');
|
|
106537
|
+
effects.consume(code);
|
|
106538
|
+
return matchTagName(afterTagName, nok);
|
|
106539
|
+
}
|
|
106540
|
+
function afterTagName(code) {
|
|
106541
|
+
if (code === codes.greaterThan) {
|
|
106542
|
+
effects.consume(code);
|
|
106543
|
+
return body;
|
|
106544
|
+
}
|
|
106545
|
+
if (code === codes.space || code === codes.horizontalTab) {
|
|
106546
|
+
effects.consume(code);
|
|
106547
|
+
return inAttributes;
|
|
106548
|
+
}
|
|
106549
|
+
if (mode === 'flow' && markdownLineEnding(code)) {
|
|
106550
|
+
effects.exit('htmlBlockComponentData');
|
|
106551
|
+
return attributeContinuationStart(code);
|
|
106552
|
+
}
|
|
106553
|
+
if (code === codes.slash) {
|
|
106554
|
+
effects.consume(code);
|
|
106555
|
+
return selfClose;
|
|
106556
|
+
}
|
|
106557
|
+
return nok(code);
|
|
106558
|
+
}
|
|
106559
|
+
function inAttributes(code) {
|
|
106560
|
+
if (code === codes.greaterThan) {
|
|
106561
|
+
effects.consume(code);
|
|
106562
|
+
return body;
|
|
106563
|
+
}
|
|
106564
|
+
if (code === null) {
|
|
106565
|
+
return nok(code);
|
|
106566
|
+
}
|
|
106567
|
+
if (markdownLineEnding(code)) {
|
|
106568
|
+
if (mode === 'text')
|
|
106569
|
+
return nok(code);
|
|
106570
|
+
effects.exit('htmlBlockComponentData');
|
|
106571
|
+
return attributeContinuationStart(code);
|
|
106572
|
+
}
|
|
106573
|
+
effects.consume(code);
|
|
106574
|
+
return inAttributes;
|
|
106575
|
+
}
|
|
106576
|
+
function attributeContinuationStart(code) {
|
|
106577
|
+
return effects.check(html_block_component_syntax_nonLazyContinuationStart, attributeContinuationNonLazy, continuationAfter)(code);
|
|
106578
|
+
}
|
|
106579
|
+
function attributeContinuationNonLazy(code) {
|
|
106580
|
+
effects.enter(types_types.lineEnding);
|
|
106581
|
+
effects.consume(code);
|
|
106582
|
+
effects.exit(types_types.lineEnding);
|
|
106583
|
+
return attributeContinuationBefore;
|
|
106584
|
+
}
|
|
106585
|
+
function attributeContinuationBefore(code) {
|
|
106586
|
+
if (code === null || markdownLineEnding(code)) {
|
|
106587
|
+
return attributeContinuationStart(code);
|
|
106588
|
+
}
|
|
106589
|
+
effects.enter('htmlBlockComponentData');
|
|
106590
|
+
return inAttributes(code);
|
|
106591
|
+
}
|
|
106592
|
+
function selfClose(code) {
|
|
106593
|
+
if (code === codes.greaterThan) {
|
|
106594
|
+
effects.consume(code);
|
|
106595
|
+
return mode === 'flow' ? afterClose : done(code);
|
|
106596
|
+
}
|
|
106597
|
+
return nok(code);
|
|
106598
|
+
}
|
|
106599
|
+
function body(code) {
|
|
106600
|
+
if (code === null)
|
|
106601
|
+
return nok(code);
|
|
106602
|
+
if (markdownLineEnding(code)) {
|
|
106603
|
+
if (mode === 'text') {
|
|
106604
|
+
// Text constructs operate on paragraph content which spans lines
|
|
106605
|
+
effects.consume(code);
|
|
106606
|
+
return body;
|
|
106607
|
+
}
|
|
106608
|
+
effects.exit('htmlBlockComponentData');
|
|
106609
|
+
return continuationStart(code);
|
|
106610
|
+
}
|
|
106611
|
+
if (code === codes.lessThan) {
|
|
106612
|
+
effects.consume(code);
|
|
106613
|
+
return closeSlash;
|
|
106614
|
+
}
|
|
106615
|
+
effects.consume(code);
|
|
106616
|
+
return body;
|
|
106617
|
+
}
|
|
106618
|
+
function closeSlash(code) {
|
|
106619
|
+
if (code === codes.slash) {
|
|
106620
|
+
effects.consume(code);
|
|
106621
|
+
return matchTagName(closeGt, body);
|
|
106622
|
+
}
|
|
106623
|
+
return matchTagName(openAfterTagName, body)(code);
|
|
106624
|
+
}
|
|
106625
|
+
function openAfterTagName(code) {
|
|
106626
|
+
if (code === codes.greaterThan || code === codes.space || code === codes.horizontalTab) {
|
|
106627
|
+
depth += 1;
|
|
106628
|
+
effects.consume(code);
|
|
106629
|
+
return body;
|
|
106630
|
+
}
|
|
106631
|
+
return body(code);
|
|
106632
|
+
}
|
|
106633
|
+
function closeGt(code) {
|
|
106634
|
+
if (code === codes.greaterThan) {
|
|
106635
|
+
depth -= 1;
|
|
106636
|
+
effects.consume(code);
|
|
106637
|
+
if (depth === 0) {
|
|
106638
|
+
return mode === 'flow' ? afterClose : done(code);
|
|
106639
|
+
}
|
|
106640
|
+
return body;
|
|
106641
|
+
}
|
|
106642
|
+
return body(code);
|
|
106643
|
+
}
|
|
106644
|
+
// -- flow-only states ---------------------------------------------------
|
|
106645
|
+
function afterClose(code) {
|
|
106646
|
+
if (code === null || markdownLineEnding(code)) {
|
|
106647
|
+
return done(code);
|
|
106648
|
+
}
|
|
106649
|
+
if (code === codes.space || code === codes.horizontalTab) {
|
|
106650
|
+
effects.consume(code);
|
|
106651
|
+
return afterClose;
|
|
106652
|
+
}
|
|
106653
|
+
// Reject so the block re-parses as a paragraph, deferring to the
|
|
106654
|
+
// text tokenizer which preserves trailing content in the same line.
|
|
106655
|
+
return nok(code);
|
|
106656
|
+
}
|
|
106657
|
+
// -- flow-only: line continuation ---------------------------------------
|
|
106658
|
+
function continuationStart(code) {
|
|
106659
|
+
return effects.check(html_block_component_syntax_nonLazyContinuationStart, continuationStartNonLazy, continuationAfter)(code);
|
|
106660
|
+
}
|
|
106661
|
+
function continuationStartNonLazy(code) {
|
|
106662
|
+
effects.enter(types_types.lineEnding);
|
|
106663
|
+
effects.consume(code);
|
|
106664
|
+
effects.exit(types_types.lineEnding);
|
|
106665
|
+
return continuationBefore;
|
|
106666
|
+
}
|
|
106667
|
+
function continuationBefore(code) {
|
|
106668
|
+
if (code === null || markdownLineEnding(code)) {
|
|
106669
|
+
return continuationStart(code);
|
|
106670
|
+
}
|
|
106671
|
+
effects.enter('htmlBlockComponentData');
|
|
106672
|
+
return body(code);
|
|
106673
|
+
}
|
|
106674
|
+
function continuationAfter(code) {
|
|
106675
|
+
if (code === null)
|
|
106676
|
+
return nok(code);
|
|
106677
|
+
effects.exit('htmlBlockComponent');
|
|
106678
|
+
return ok(code);
|
|
106679
|
+
}
|
|
106680
|
+
// -- shared exit --------------------------------------------------------
|
|
106681
|
+
function done(_code) {
|
|
106682
|
+
effects.exit('htmlBlockComponentData');
|
|
106683
|
+
effects.exit('htmlBlockComponent');
|
|
106684
|
+
return ok(_code);
|
|
106685
|
+
}
|
|
106686
|
+
};
|
|
106687
|
+
}
|
|
106688
|
+
// ---------------------------------------------------------------------------
|
|
106689
|
+
// Flow construct (block-level)
|
|
106690
|
+
// ---------------------------------------------------------------------------
|
|
106691
|
+
const html_block_component_syntax_nonLazyContinuationStart = {
|
|
106692
|
+
tokenize: html_block_component_syntax_tokenizeNonLazyContinuationStart,
|
|
106693
|
+
partial: true,
|
|
106694
|
+
};
|
|
106695
|
+
function resolveToHtmlBlockComponent(events) {
|
|
106696
|
+
let index = events.length;
|
|
106697
|
+
while (index > 0) {
|
|
106698
|
+
index -= 1;
|
|
106699
|
+
if (events[index][0] === 'enter' && events[index][1].type === 'htmlBlockComponent') {
|
|
106700
|
+
break;
|
|
106701
|
+
}
|
|
106702
|
+
}
|
|
106703
|
+
if (index > 1 && events[index - 2][1].type === types_types.linePrefix) {
|
|
106704
|
+
events[index][1].start = events[index - 2][1].start;
|
|
106705
|
+
events[index + 1][1].start = events[index - 2][1].start;
|
|
106706
|
+
events.splice(index - 2, 2);
|
|
106707
|
+
}
|
|
106708
|
+
return events;
|
|
106709
|
+
}
|
|
106710
|
+
const htmlBlockComponentFlowConstruct = {
|
|
106711
|
+
name: 'htmlBlockComponent',
|
|
106712
|
+
tokenize: syntax_createTokenize('flow'),
|
|
106713
|
+
resolveTo: resolveToHtmlBlockComponent,
|
|
106714
|
+
concrete: true,
|
|
106715
|
+
};
|
|
106716
|
+
function html_block_component_syntax_tokenizeNonLazyContinuationStart(effects, ok, nok) {
|
|
106717
|
+
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
106718
|
+
const self = this;
|
|
106719
|
+
return start;
|
|
106720
|
+
function start(code) {
|
|
106721
|
+
if (markdownLineEnding(code)) {
|
|
106722
|
+
effects.enter(types_types.lineEnding);
|
|
106723
|
+
effects.consume(code);
|
|
106724
|
+
effects.exit(types_types.lineEnding);
|
|
106725
|
+
return after;
|
|
106726
|
+
}
|
|
106727
|
+
return nok(code);
|
|
106728
|
+
}
|
|
106729
|
+
function after(code) {
|
|
106730
|
+
if (self.parser.lazy[self.now().line]) {
|
|
106731
|
+
return nok(code);
|
|
106732
|
+
}
|
|
106733
|
+
return ok(code);
|
|
106734
|
+
}
|
|
106735
|
+
}
|
|
106736
|
+
// ---------------------------------------------------------------------------
|
|
106737
|
+
// Text construct (inline)
|
|
106738
|
+
// ---------------------------------------------------------------------------
|
|
106739
|
+
const htmlBlockComponentTextConstruct = {
|
|
106740
|
+
name: 'htmlBlockComponent',
|
|
106741
|
+
tokenize: syntax_createTokenize('text'),
|
|
106742
|
+
};
|
|
106743
|
+
// ---------------------------------------------------------------------------
|
|
106744
|
+
// Extension
|
|
106745
|
+
// ---------------------------------------------------------------------------
|
|
106746
|
+
function htmlBlockComponent() {
|
|
106747
|
+
return {
|
|
106748
|
+
flow: {
|
|
106749
|
+
[codes.lessThan]: [htmlBlockComponentFlowConstruct],
|
|
106750
|
+
},
|
|
106751
|
+
text: {
|
|
106752
|
+
[codes.lessThan]: [htmlBlockComponentTextConstruct],
|
|
106753
|
+
},
|
|
106754
|
+
};
|
|
106755
|
+
}
|
|
106756
|
+
|
|
106757
|
+
;// ./lib/micromark/html-block-component/index.ts
|
|
106758
|
+
|
|
106759
|
+
|
|
106358
106760
|
;// ./lib/utils/extractMagicBlocks.ts
|
|
106359
106761
|
/**
|
|
106360
106762
|
* The content matching in this regex captures everything between `[block:TYPE]`
|
|
@@ -106421,19 +106823,22 @@ function restoreMagicBlocks(replaced, blocks) {
|
|
|
106421
106823
|
|
|
106422
106824
|
|
|
106423
106825
|
|
|
106826
|
+
|
|
106827
|
+
|
|
106424
106828
|
/**
|
|
106425
106829
|
* Removes Markdown and MDX comments.
|
|
106426
106830
|
*/
|
|
106427
106831
|
async function stripComments(doc, { mdx, mdxish } = {}) {
|
|
106428
106832
|
const { replaced, blocks } = extractMagicBlocks(doc);
|
|
106429
106833
|
const processor = unified();
|
|
106430
|
-
// we still require these
|
|
106834
|
+
// we still require these extensions because:
|
|
106431
106835
|
// 1. we can rely on remarkMdx to parse MDXish
|
|
106432
106836
|
// 2. we need to parse JSX comments into mdxTextExpression nodes so that the transformers can pick them up
|
|
106837
|
+
// 3. we need to claim <HTMLBlock> before htmlFlow intercepts its inner HTML tags
|
|
106433
106838
|
if (mdxish) {
|
|
106434
106839
|
processor
|
|
106435
|
-
.data('micromarkExtensions', [jsxTable(), mdxExpression({ allowEmpty: true })])
|
|
106436
|
-
.data('fromMarkdownExtensions', [jsxTableFromMarkdown(), mdxExpressionFromMarkdown()])
|
|
106840
|
+
.data('micromarkExtensions', [htmlBlockComponent(), jsxTable(), mdxExpression({ allowEmpty: true })])
|
|
106841
|
+
.data('fromMarkdownExtensions', [htmlBlockComponentFromMarkdown(), jsxTableFromMarkdown(), mdxExpressionFromMarkdown()])
|
|
106437
106842
|
.data('toMarkdownExtensions', [mdxExpressionToMarkdown()]);
|
|
106438
106843
|
}
|
|
106439
106844
|
processor
|