Skip to content

Commit 22af152

Browse files
authored
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">
1 parent bf45e86 commit 22af152

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

docs/latest/getting-started/create-a-route.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ The new page will be visible at `http://localhost:8000/about`.
5252
pages in the _Getting Started_ guide will also explain more features of routes. -->
5353

5454
[concepts-routing]: /docs/concepts/routing
55-
[jsx]: https://reactjs.org/docs/introducing-jsx.html
55+
[jsx]:https://react.dev/learn/writing-markup-with-jsx
5656
[preact]: https://preactjs.com/
5757

5858
<!-- [concepts-routes]: /docs/concepts/routes -->

www/utils/markdown.ts

+9-4
Original file line numberDiff line numberDiff line change
@@ -113,22 +113,27 @@ class DefaultRenderer extends Marked.Renderer {
113113
return out;
114114
}
115115

116-
override blockquote({ text }: Marked.Tokens.Blockquote): string {
116+
override blockquote({ text, tokens }: Marked.Tokens.Blockquote): string {
117117
const match = text.match(ADMISSION_REG);
118+
118119
if (match) {
119120
const label: Record<string, string> = {
120121
tip: "Tip",
121122
warn: "Warning",
122123
info: "Info",
123124
};
125+
Marked.walkTokens(tokens, (token) => {
126+
if (token.type === "text" && token.text.startsWith(match[0])) {
127+
token.text = token.text.slice(match[0].length);
128+
}
129+
});
124130
const type = match[1];
125-
text = text.slice(match[0].length);
126131
const icon = `<svg class="icon"><use href="/icons.svg#${type}" /></svg>`;
127132
return `<blockquote class="admonition ${type}">\n<span class="admonition-header">${icon}${
128133
label[type]
129-
}</span>${Marked.parse(text)}</blockquote>\n`;
134+
}</span>${Marked.parser(tokens)}</blockquote>\n`;
130135
}
131-
return `<blockquote>\n${Marked.parse(text)}</blockquote>\n`;
136+
return `<blockquote>\n${Marked.parser(tokens)}</blockquote>\n`;
132137
}
133138
}
134139

0 commit comments

Comments
 (0)