www: fix slug (#3287)
Fixes https://github.com/denoland/fresh/issues/3254
This commit is contained in:
@@ -96,6 +96,7 @@
|
||||
"npm:ts-morph@26": "26.0.0",
|
||||
"npm:vite-plugin-inspect@^11.3.2": "11.3.3_vite@7.1.3__@types+node@24.3.0__picomatch@4.0.3_@types+node@24.3.0",
|
||||
"npm:vite@*": "7.1.3_@types+node@24.3.0_picomatch@4.0.3",
|
||||
"npm:vite@7.1.3": "7.1.3_@types+node@24.3.0_picomatch@4.0.3",
|
||||
"npm:vite@^7.1.3": "7.1.3_@types+node@24.3.0_picomatch@4.0.3"
|
||||
},
|
||||
"jsr": {
|
||||
|
||||
+18
-6
@@ -111,13 +111,25 @@ class DefaultRenderer extends Marked.Renderer {
|
||||
override heading({ tokens, depth }: Marked.Tokens.Heading): string {
|
||||
this.#assert(tokens.length > 0, "Markdown heading tokens unexpected value");
|
||||
|
||||
const content = tokens[0];
|
||||
this.#assert(
|
||||
content.type === "text" || content.type === "codespan",
|
||||
"Markdown heading tokens unexpected value",
|
||||
);
|
||||
let content = "";
|
||||
for (let i = 0; i < tokens.length; i++) {
|
||||
const token = tokens[i];
|
||||
switch (token.type) {
|
||||
case "text":
|
||||
content += token.text;
|
||||
continue;
|
||||
case "codespan":
|
||||
content += token.text.replaceAll(/[<>]/g, "");
|
||||
continue;
|
||||
default:
|
||||
this.#assert(
|
||||
false,
|
||||
"Markdown heading tokens unexpected value",
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
let slugInput = content.text;
|
||||
let slugInput = content;
|
||||
|
||||
// Rewrites e.g. `.get()` to `get`
|
||||
if (/^\..*\(\)$/.test(slugInput)) {
|
||||
|
||||
Reference in New Issue
Block a user