www: Fix block quotes not rendering links (#2712)
- Fixes a bug where block quotes were not able to properly render URLs in docs (e.g. Info section at https://fresh.deno.dev/docs/getting-started/create-a-route) - Replaces existing JSX docs url with the suggested, up-to-date docs url <img width="775" alt="image" src="https://github.com/user-attachments/assets/e2e83456-697b-47d5-b074-66e4f287f17a">
This commit is contained in:
@@ -52,7 +52,7 @@ The new page will be visible at `http://localhost:8000/about`.
|
|||||||
pages in the _Getting Started_ guide will also explain more features of routes. -->
|
pages in the _Getting Started_ guide will also explain more features of routes. -->
|
||||||
|
|
||||||
[concepts-routing]: /docs/concepts/routing
|
[concepts-routing]: /docs/concepts/routing
|
||||||
[jsx]: https://reactjs.org/docs/introducing-jsx.html
|
[jsx]:https://react.dev/learn/writing-markup-with-jsx
|
||||||
[preact]: https://preactjs.com/
|
[preact]: https://preactjs.com/
|
||||||
|
|
||||||
<!-- [concepts-routes]: /docs/concepts/routes -->
|
<!-- [concepts-routes]: /docs/concepts/routes -->
|
||||||
|
|||||||
@@ -113,22 +113,27 @@ class DefaultRenderer extends Marked.Renderer {
|
|||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
override blockquote({ text }: Marked.Tokens.Blockquote): string {
|
override blockquote({ text, tokens }: Marked.Tokens.Blockquote): string {
|
||||||
const match = text.match(ADMISSION_REG);
|
const match = text.match(ADMISSION_REG);
|
||||||
|
|
||||||
if (match) {
|
if (match) {
|
||||||
const label: Record<string, string> = {
|
const label: Record<string, string> = {
|
||||||
tip: "Tip",
|
tip: "Tip",
|
||||||
warn: "Warning",
|
warn: "Warning",
|
||||||
info: "Info",
|
info: "Info",
|
||||||
};
|
};
|
||||||
|
Marked.walkTokens(tokens, (token) => {
|
||||||
|
if (token.type === "text" && token.text.startsWith(match[0])) {
|
||||||
|
token.text = token.text.slice(match[0].length);
|
||||||
|
}
|
||||||
|
});
|
||||||
const type = match[1];
|
const type = match[1];
|
||||||
text = text.slice(match[0].length);
|
|
||||||
const icon = `<svg class="icon"><use href="/icons.svg#${type}" /></svg>`;
|
const icon = `<svg class="icon"><use href="/icons.svg#${type}" /></svg>`;
|
||||||
return `<blockquote class="admonition ${type}">\n<span class="admonition-header">${icon}${
|
return `<blockquote class="admonition ${type}">\n<span class="admonition-header">${icon}${
|
||||||
label[type]
|
label[type]
|
||||||
}</span>${Marked.parse(text)}</blockquote>\n`;
|
}</span>${Marked.parser(tokens)}</blockquote>\n`;
|
||||||
}
|
}
|
||||||
return `<blockquote>\n${Marked.parse(text)}</blockquote>\n`;
|
return `<blockquote>\n${Marked.parser(tokens)}</blockquote>\n`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user