@vxrn/mdx 2.6.5 → 2.6.7
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/index.js +10 -1
- package/dist/index.js.map +1 -1
- package/package.json +5 -3
- package/src/getHeadings.test.ts +22 -0
- package/src/getHeadings.ts +11 -1
- package/types/getHeadings.d.ts.map +1 -1
package/dist/index.js
CHANGED
|
@@ -16340,7 +16340,16 @@ function slug(value, maintainCase) {
|
|
|
16340
16340
|
var getTitle = (source) => source.replace(/^#+\s+/, "").replace(/<.*>/, " ");
|
|
16341
16341
|
var getHeadings = (source) => {
|
|
16342
16342
|
const slugger = new BananaSlug();
|
|
16343
|
-
|
|
16343
|
+
let fence = "";
|
|
16344
|
+
return source.split("\n").filter((x) => {
|
|
16345
|
+
const marker = x.trimStart().match(/^(`{3,}|~{3,})/)?.[1];
|
|
16346
|
+
if (marker) {
|
|
16347
|
+
if (!fence) fence = marker;
|
|
16348
|
+
else if (marker[0] === fence[0] && marker.length >= fence.length) fence = "";
|
|
16349
|
+
return false;
|
|
16350
|
+
}
|
|
16351
|
+
return !fence && /^#{1,6}\s/.test(x);
|
|
16352
|
+
}).map((x) => ({
|
|
16344
16353
|
title: getTitle(x),
|
|
16345
16354
|
priority: x.trim().split(" ")[0].length,
|
|
16346
16355
|
id: slugger.slug(getTitle(x))
|