Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

www: Fix block quotes not rendering links #2712

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/latest/getting-started/create-a-route.md
Original file line number Diff line number Diff line change
Expand Up @@ -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. -->

[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/

<!-- [concepts-routes]: /docs/concepts/routes -->
13 changes: 9 additions & 4 deletions www/utils/markdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,22 +113,27 @@ class DefaultRenderer extends Marked.Renderer {
return out;
}

override blockquote({ text }: Marked.Tokens.Blockquote): string {
override blockquote({ text, tokens }: Marked.Tokens.Blockquote): string {
const match = text.match(ADMISSION_REG);

if (match) {
const label: Record<string, string> = {
tip: "Tip",
warn: "Warning",
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];
text = text.slice(match[0].length);
const icon = `<svg class="icon"><use href="/icons.svg#${type}" /></svg>`;
return `<blockquote class="admonition ${type}">\n<span class="admonition-header">${icon}${
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`;
}
}

Expand Down
Loading