@vxrn/mdx-rust 2.6.3 → 2.6.5
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/getHeadings.mjs +9 -6
- package/dist/getHeadings.mjs.map +1 -1
- package/package.json +2 -2
- package/src/getHeadings.ts +16 -6
- package/types/getHeadings.d.ts.map +1 -1
package/dist/getHeadings.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import GithubSlugger from "github-slugger";
|
|
2
2
|
|
|
3
|
-
const getTitle = (source) => source.replace(/^#+\s+/, "").replace(
|
|
3
|
+
const getTitle = (source) => source.replace(/^#+\s+/, "").split("`").map((part, i) => i % 2 ? part : part.replace(/<[^>]*>/g, "")).join("");
|
|
4
4
|
const getHeadings = (source) => {
|
|
5
5
|
const slugger = new GithubSlugger();
|
|
6
6
|
let fence = "";
|
|
@@ -12,11 +12,14 @@ const getHeadings = (source) => {
|
|
|
12
12
|
return false;
|
|
13
13
|
}
|
|
14
14
|
return !fence && /^#{1,6}\s/.test(x);
|
|
15
|
-
}).map((x) =>
|
|
16
|
-
title
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
}).map((x) => {
|
|
16
|
+
const title = getTitle(x);
|
|
17
|
+
return {
|
|
18
|
+
title: title.trim(),
|
|
19
|
+
priority: x.trim().split(" ")[0].length,
|
|
20
|
+
id: slugger.slug(title)
|
|
21
|
+
};
|
|
22
|
+
});
|
|
20
23
|
};
|
|
21
24
|
|
|
22
25
|
export { getHeadings };
|
package/dist/getHeadings.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getHeadings.js","names":[],"sources":["getHeadings.js"],"sourcesContent":["import GithubSlugger from \"github-slugger\";\nconst getTitle = (source) => source.replace(/^#+\\s+/, \"\").replace(
|
|
1
|
+
{"version":3,"file":"getHeadings.js","names":[],"sources":["getHeadings.js"],"sourcesContent":["import GithubSlugger from \"github-slugger\";\nconst getTitle = (source) => source.replace(/^#+\\s+/, \"\").split(\"`\").map((part, i) => i % 2 ? part : part.replace(/<[^>]*>/g, \"\")).join(\"\");\nconst getHeadings = (source) => {\n const slugger = new GithubSlugger();\n let fence = \"\";\n return source.split(\"\\n\").filter((x) => {\n const marker = x.trimStart().match(/^(`{3,}|~{3,})/)?.[1];\n if (marker) {\n if (!fence) fence = marker;\n else if (marker[0] === fence[0] && marker.length >= fence.length) fence = \"\";\n return false;\n }\n return !fence && /^#{1,6}\\s/.test(x);\n }).map((x) => {\n const title = getTitle(x);\n return {\n title: title.trim(),\n priority: x.trim().split(\" \")[0].length,\n id: slugger.slug(title)\n };\n });\n};\nexport {\n getHeadings\n};\n//# sourceMappingURL=getHeadings.js.map\n"],"mappings":";;;AACA,MAAM,YAAY,WAAW,OAAO,QAAQ,UAAU,EAAE,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,KAAK,MAAM,MAAM,IAAI,IAAI,OAAO,KAAK,QAAQ,YAAY,EAAE,CAAC,CAAC,CAAC,KAAK,EAAE;AAC1I,MAAM,eAAe,WAAW;CAC9B,MAAM,UAAU,IAAI,cAAc;CAClC,IAAI,QAAQ;CACZ,OAAO,OAAO,MAAM,IAAI,CAAC,CAAC,QAAQ,MAAM;EACtC,MAAM,SAAS,EAAE,UAAU,CAAC,CAAC,MAAM,gBAAgB,CAAC,GAAG;EACvD,IAAI,QAAQ;GACV,IAAI,CAAC,OAAO,QAAQ;QACf,IAAI,OAAO,OAAO,MAAM,MAAM,OAAO,UAAU,MAAM,QAAQ,QAAQ;GAC1E,OAAO;EACT;EACA,OAAO,CAAC,SAAS,YAAY,KAAK,CAAC;CACrC,CAAC,CAAC,CAAC,KAAK,MAAM;EACZ,MAAM,QAAQ,SAAS,CAAC;EACxB,OAAO;GACL,OAAO,MAAM,KAAK;GAClB,UAAU,EAAE,KAAK,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE,CAAC;GACjC,IAAI,QAAQ,KAAK,KAAK;EACxB;CACF,CAAC;AACH"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vxrn/mdx-rust",
|
|
3
|
-
"version": "2.6.
|
|
3
|
+
"version": "2.6.5",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"module": "dist",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"publishConfig": {
|
|
55
55
|
"access": "public"
|
|
56
56
|
},
|
|
57
|
-
"releaseSourceCommit": "
|
|
57
|
+
"releaseSourceCommit": "97c5295fca304e7fc443ed228f087c51dc63bc69",
|
|
58
58
|
"repository": {
|
|
59
59
|
"type": "git",
|
|
60
60
|
"url": "git+https://github.com/onejs/one.git",
|
package/src/getHeadings.ts
CHANGED
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
import GithubSlugger from 'github-slugger'
|
|
2
2
|
import type { Heading } from './types'
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
// heading text as it renders: jsx elements dropped, inline code kept without
|
|
5
|
+
// backticks. matches the text slugPlugin slugs, so ids line up.
|
|
6
|
+
const getTitle = (source: string) =>
|
|
7
|
+
source
|
|
8
|
+
.replace(/^#+\s+/, '')
|
|
9
|
+
.split('`')
|
|
10
|
+
.map((part, i) => (i % 2 ? part : part.replace(/<[^>]*>/g, '')))
|
|
11
|
+
.join('')
|
|
5
12
|
|
|
6
13
|
// extract headings for a table of contents. ids match the slugs added by
|
|
7
14
|
// slugPlugin during compilation, so anchor links resolve.
|
|
@@ -20,9 +27,12 @@ export const getHeadings = (source: string): Heading[] => {
|
|
|
20
27
|
}
|
|
21
28
|
return !fence && /^#{1,6}\s/.test(x)
|
|
22
29
|
})
|
|
23
|
-
.map((x) =>
|
|
24
|
-
title
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
30
|
+
.map((x) => {
|
|
31
|
+
const title = getTitle(x)
|
|
32
|
+
return {
|
|
33
|
+
title: title.trim(),
|
|
34
|
+
priority: x.trim().split(' ')[0].length,
|
|
35
|
+
id: slugger.slug(title),
|
|
36
|
+
}
|
|
37
|
+
})
|
|
28
38
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getHeadings.d.ts","sourceRoot":"","sources":["../src/getHeadings.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"getHeadings.d.ts","sourceRoot":"","sources":["../src/getHeadings.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAatC,eAAO,MAAM,WAAW,WAAY,MAAM,KAAG,OAAO,EAuBnD,CAAA"}
|