@readme/markdown 13.8.3 → 13.8.4
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.
|
@@ -42,18 +42,23 @@ function getScrollParent(el: HTMLElement): HTMLElement | Window {
|
|
|
42
42
|
* corresponding TOC links so the reader always knows where they are.
|
|
43
43
|
*/
|
|
44
44
|
function useScrollHighlight(navRef: React.RefObject<HTMLElement | null>) {
|
|
45
|
-
const [
|
|
45
|
+
const [tocKey, setTocKey] = useState('');
|
|
46
46
|
|
|
47
|
+
// Re-check after every render so we detect when children change
|
|
48
|
+
// (e.g. after page navigation). Only triggers a re-render when the
|
|
49
|
+
// set of TOC link hrefs actually differs.
|
|
47
50
|
useEffect(() => {
|
|
48
51
|
const nav = navRef.current;
|
|
49
52
|
if (!nav) return;
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
|
|
53
|
+
const key = Array.from(nav.querySelectorAll<HTMLAnchorElement>('a[href^="#"]'))
|
|
54
|
+
.map(a => a.getAttribute('href'))
|
|
55
|
+
.join('\0');
|
|
56
|
+
setTocKey(key);
|
|
57
|
+
});
|
|
53
58
|
|
|
54
59
|
useEffect(() => {
|
|
55
60
|
const nav = navRef.current;
|
|
56
|
-
if (!nav || typeof IntersectionObserver === 'undefined' ||
|
|
61
|
+
if (!nav || typeof IntersectionObserver === 'undefined' || !tocKey) return undefined;
|
|
57
62
|
|
|
58
63
|
const linkMap = buildLinkMap(nav);
|
|
59
64
|
if (linkMap.size === 0) return undefined;
|
|
@@ -172,7 +177,7 @@ function useScrollHighlight(navRef: React.RefObject<HTMLElement | null>) {
|
|
|
172
177
|
scrollTarget.removeEventListener('scroll', onScroll);
|
|
173
178
|
nav.removeEventListener('click', onClick);
|
|
174
179
|
};
|
|
175
|
-
}, [navRef,
|
|
180
|
+
}, [navRef, tocKey]);
|
|
176
181
|
}
|
|
177
182
|
|
|
178
183
|
function TableOfContents({ children }: React.PropsWithChildren) {
|
package/dist/main.js
CHANGED
|
@@ -12110,17 +12110,22 @@ function getScrollParent(el) {
|
|
|
12110
12110
|
* corresponding TOC links so the reader always knows where they are.
|
|
12111
12111
|
*/
|
|
12112
12112
|
function useScrollHighlight(navRef) {
|
|
12113
|
-
const [
|
|
12113
|
+
const [tocKey, setTocKey] = (0,external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_.useState)('');
|
|
12114
|
+
// Re-check after every render so we detect when children change
|
|
12115
|
+
// (e.g. after page navigation). Only triggers a re-render when the
|
|
12116
|
+
// set of TOC link hrefs actually differs.
|
|
12114
12117
|
(0,external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_.useEffect)(() => {
|
|
12115
12118
|
const nav = navRef.current;
|
|
12116
12119
|
if (!nav)
|
|
12117
12120
|
return;
|
|
12118
|
-
const
|
|
12119
|
-
|
|
12120
|
-
|
|
12121
|
+
const key = Array.from(nav.querySelectorAll('a[href^="#"]'))
|
|
12122
|
+
.map(a => a.getAttribute('href'))
|
|
12123
|
+
.join('\0');
|
|
12124
|
+
setTocKey(key);
|
|
12125
|
+
});
|
|
12121
12126
|
(0,external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_.useEffect)(() => {
|
|
12122
12127
|
const nav = navRef.current;
|
|
12123
|
-
if (!nav || typeof IntersectionObserver === 'undefined' ||
|
|
12128
|
+
if (!nav || typeof IntersectionObserver === 'undefined' || !tocKey)
|
|
12124
12129
|
return undefined;
|
|
12125
12130
|
const linkMap = buildLinkMap(nav);
|
|
12126
12131
|
if (linkMap.size === 0)
|
|
@@ -12229,7 +12234,7 @@ function useScrollHighlight(navRef) {
|
|
|
12229
12234
|
scrollTarget.removeEventListener('scroll', onScroll);
|
|
12230
12235
|
nav.removeEventListener('click', onClick);
|
|
12231
12236
|
};
|
|
12232
|
-
}, [navRef,
|
|
12237
|
+
}, [navRef, tocKey]);
|
|
12233
12238
|
}
|
|
12234
12239
|
function TableOfContents({ children }) {
|
|
12235
12240
|
const navRef = (0,external_amd_react_commonjs_react_commonjs2_react_root_React_umd_react_.useRef)(null);
|
|
@@ -98509,6 +98514,40 @@ const mdxishTablesToJsx = () => tree => {
|
|
|
98509
98514
|
};
|
|
98510
98515
|
/* harmony default export */ const mdxish_tables_to_jsx = (mdxishTablesToJsx);
|
|
98511
98516
|
|
|
98517
|
+
;// ./processor/transform/mdxish/normalize-compact-headings.ts
|
|
98518
|
+
|
|
98519
|
+
/**
|
|
98520
|
+
* Preprocessor to normalize compact headings.
|
|
98521
|
+
*
|
|
98522
|
+
* CommonMark requires whitespace after # for headings, but users often omit it.
|
|
98523
|
+
* This preprocessor adds the space while being careful not to modify:
|
|
98524
|
+
* - Content inside fenced code blocks (protected via protectCodeBlocks)
|
|
98525
|
+
* - Escaped hashtags (\#)
|
|
98526
|
+
* - Mid-line hashtags (text #hashtag)
|
|
98527
|
+
*
|
|
98528
|
+
* Examples:
|
|
98529
|
+
* - `#Header` → `# Header`
|
|
98530
|
+
* - `##Title` → `## Title`
|
|
98531
|
+
* - `######H6` → `###### H6`
|
|
98532
|
+
*/
|
|
98533
|
+
function normalizeCompactHeadings(content) {
|
|
98534
|
+
const { protectedContent, protectedCode } = protectCodeBlocks(content);
|
|
98535
|
+
const normalizedLines = protectedContent.split('\n').map(line => {
|
|
98536
|
+
// Skip escaped hashtags
|
|
98537
|
+
if (line.startsWith('\\#')) {
|
|
98538
|
+
return line;
|
|
98539
|
+
}
|
|
98540
|
+
// Match compact heading: start of line, 1-6 #, followed by non-space/non-# character
|
|
98541
|
+
const headingMatch = line.match(/^(#{1,6})([^\s#])/);
|
|
98542
|
+
if (headingMatch) {
|
|
98543
|
+
// Insert space after hashtags: "##Header" → "## Header"
|
|
98544
|
+
return `${headingMatch[1]} ${line.slice(headingMatch[1].length)}`;
|
|
98545
|
+
}
|
|
98546
|
+
return line;
|
|
98547
|
+
});
|
|
98548
|
+
return restoreCodeBlocks(normalizedLines.join('\n'), protectedCode);
|
|
98549
|
+
}
|
|
98550
|
+
|
|
98512
98551
|
;// ./processor/transform/mdxish/normalize-table-separator.ts
|
|
98513
98552
|
/**
|
|
98514
98553
|
* Preprocessor to normalize malformed GFM table separator syntax.
|
|
@@ -100688,6 +100727,7 @@ function loadComponents() {
|
|
|
100688
100727
|
|
|
100689
100728
|
|
|
100690
100729
|
|
|
100730
|
+
|
|
100691
100731
|
|
|
100692
100732
|
|
|
100693
100733
|
const defaultTransformers = [
|
|
@@ -100711,6 +100751,7 @@ function preprocessContent(content, opts) {
|
|
|
100711
100751
|
let result = normalizeTableSeparator(content);
|
|
100712
100752
|
result = terminateHtmlFlowBlocks(result);
|
|
100713
100753
|
result = closeSelfClosingHtmlTags(result);
|
|
100754
|
+
result = normalizeCompactHeadings(result);
|
|
100714
100755
|
result = safeMode ? result : preprocessJSXExpressions(result, jsxContext);
|
|
100715
100756
|
return processSnakeCaseComponent(result, { knownComponents });
|
|
100716
100757
|
}
|
package/dist/main.node.js
CHANGED
|
@@ -24706,17 +24706,22 @@ function TableOfContents_getScrollParent(el) {
|
|
|
24706
24706
|
* corresponding TOC links so the reader always knows where they are.
|
|
24707
24707
|
*/
|
|
24708
24708
|
function useScrollHighlight(navRef) {
|
|
24709
|
-
const [
|
|
24709
|
+
const [tocKey, setTocKey] = (0,external_react_.useState)('');
|
|
24710
|
+
// Re-check after every render so we detect when children change
|
|
24711
|
+
// (e.g. after page navigation). Only triggers a re-render when the
|
|
24712
|
+
// set of TOC link hrefs actually differs.
|
|
24710
24713
|
(0,external_react_.useEffect)(() => {
|
|
24711
24714
|
const nav = navRef.current;
|
|
24712
24715
|
if (!nav)
|
|
24713
24716
|
return;
|
|
24714
|
-
const
|
|
24715
|
-
|
|
24716
|
-
|
|
24717
|
+
const key = Array.from(nav.querySelectorAll('a[href^="#"]'))
|
|
24718
|
+
.map(a => a.getAttribute('href'))
|
|
24719
|
+
.join('\0');
|
|
24720
|
+
setTocKey(key);
|
|
24721
|
+
});
|
|
24717
24722
|
(0,external_react_.useEffect)(() => {
|
|
24718
24723
|
const nav = navRef.current;
|
|
24719
|
-
if (!nav || typeof IntersectionObserver === 'undefined' ||
|
|
24724
|
+
if (!nav || typeof IntersectionObserver === 'undefined' || !tocKey)
|
|
24720
24725
|
return undefined;
|
|
24721
24726
|
const linkMap = buildLinkMap(nav);
|
|
24722
24727
|
if (linkMap.size === 0)
|
|
@@ -24825,7 +24830,7 @@ function useScrollHighlight(navRef) {
|
|
|
24825
24830
|
scrollTarget.removeEventListener('scroll', onScroll);
|
|
24826
24831
|
nav.removeEventListener('click', onClick);
|
|
24827
24832
|
};
|
|
24828
|
-
}, [navRef,
|
|
24833
|
+
}, [navRef, tocKey]);
|
|
24829
24834
|
}
|
|
24830
24835
|
function TableOfContents({ children }) {
|
|
24831
24836
|
const navRef = (0,external_react_.useRef)(null);
|
|
@@ -118703,6 +118708,40 @@ const mdxishTablesToJsx = () => tree => {
|
|
|
118703
118708
|
};
|
|
118704
118709
|
/* harmony default export */ const mdxish_tables_to_jsx = (mdxishTablesToJsx);
|
|
118705
118710
|
|
|
118711
|
+
;// ./processor/transform/mdxish/normalize-compact-headings.ts
|
|
118712
|
+
|
|
118713
|
+
/**
|
|
118714
|
+
* Preprocessor to normalize compact headings.
|
|
118715
|
+
*
|
|
118716
|
+
* CommonMark requires whitespace after # for headings, but users often omit it.
|
|
118717
|
+
* This preprocessor adds the space while being careful not to modify:
|
|
118718
|
+
* - Content inside fenced code blocks (protected via protectCodeBlocks)
|
|
118719
|
+
* - Escaped hashtags (\#)
|
|
118720
|
+
* - Mid-line hashtags (text #hashtag)
|
|
118721
|
+
*
|
|
118722
|
+
* Examples:
|
|
118723
|
+
* - `#Header` → `# Header`
|
|
118724
|
+
* - `##Title` → `## Title`
|
|
118725
|
+
* - `######H6` → `###### H6`
|
|
118726
|
+
*/
|
|
118727
|
+
function normalizeCompactHeadings(content) {
|
|
118728
|
+
const { protectedContent, protectedCode } = protectCodeBlocks(content);
|
|
118729
|
+
const normalizedLines = protectedContent.split('\n').map(line => {
|
|
118730
|
+
// Skip escaped hashtags
|
|
118731
|
+
if (line.startsWith('\\#')) {
|
|
118732
|
+
return line;
|
|
118733
|
+
}
|
|
118734
|
+
// Match compact heading: start of line, 1-6 #, followed by non-space/non-# character
|
|
118735
|
+
const headingMatch = line.match(/^(#{1,6})([^\s#])/);
|
|
118736
|
+
if (headingMatch) {
|
|
118737
|
+
// Insert space after hashtags: "##Header" → "## Header"
|
|
118738
|
+
return `${headingMatch[1]} ${line.slice(headingMatch[1].length)}`;
|
|
118739
|
+
}
|
|
118740
|
+
return line;
|
|
118741
|
+
});
|
|
118742
|
+
return restoreCodeBlocks(normalizedLines.join('\n'), protectedCode);
|
|
118743
|
+
}
|
|
118744
|
+
|
|
118706
118745
|
;// ./processor/transform/mdxish/normalize-table-separator.ts
|
|
118707
118746
|
/**
|
|
118708
118747
|
* Preprocessor to normalize malformed GFM table separator syntax.
|
|
@@ -120882,6 +120921,7 @@ function loadComponents() {
|
|
|
120882
120921
|
|
|
120883
120922
|
|
|
120884
120923
|
|
|
120924
|
+
|
|
120885
120925
|
|
|
120886
120926
|
|
|
120887
120927
|
const defaultTransformers = [
|
|
@@ -120905,6 +120945,7 @@ function preprocessContent(content, opts) {
|
|
|
120905
120945
|
let result = normalizeTableSeparator(content);
|
|
120906
120946
|
result = terminateHtmlFlowBlocks(result);
|
|
120907
120947
|
result = closeSelfClosingHtmlTags(result);
|
|
120948
|
+
result = normalizeCompactHeadings(result);
|
|
120908
120949
|
result = safeMode ? result : preprocessJSXExpressions(result, jsxContext);
|
|
120909
120950
|
return processSnakeCaseComponent(result, { knownComponents });
|
|
120910
120951
|
}
|