Skip to content

Commit 7229741

Browse files
fix(respec2html): update Renderer for marked v16 token-based API (#5140)
1 parent 5200725 commit 7229741

1 file changed

Lines changed: 16 additions & 13 deletions

File tree

tools/respec2html.js

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,25 +13,28 @@ import { toHTML } from "./respecDocWriter.js";
1313
const __dirname = path.dirname(fileURLToPath(import.meta.url));
1414

1515
class Renderer extends marked.Renderer {
16-
strong(text) {
17-
return colors.bold(text);
16+
strong(token) {
17+
return colors.bold(this.parser.parseInline(token.tokens));
1818
}
19-
em(text) {
20-
return colors.italic(text);
19+
em(token) {
20+
return colors.italic(this.parser.parseInline(token.tokens));
2121
}
22-
codespan(text) {
23-
return colors.underline(unescape(text));
22+
codespan(token) {
23+
return colors.underline(unescape(token.text));
2424
}
25-
paragraph(text) {
26-
return unescape(text);
25+
paragraph(token) {
26+
return unescape(this.parser.parseInline(token.tokens));
2727
}
28-
link(href, _title, text) {
29-
return `[${text}](${colors.blue.dim.underline(href)})`;
28+
link(token) {
29+
const text = this.parser.parseInline(token.tokens);
30+
return `[${text}](${colors.blue.dim.underline(token.href)})`;
3031
}
31-
list(body, _orderered) {
32+
list(token) {
33+
const body = token.items.map(item => this.listitem(item)).join("");
3234
return `\n${body}`;
3335
}
34-
listitem(text) {
36+
listitem(token) {
37+
const text = this.parser.parseInline(token.tokens);
3538
return `* ${text}\n`;
3639
}
3740
}
@@ -85,7 +88,7 @@ class Logger {
8588

8689
_formatMarkdown(str) {
8790
if (typeof str !== "string") return str;
88-
return marked(str, { smartypants: true, renderer: new Renderer() });
91+
return marked(str, { renderer: new Renderer() });
8992
}
9093

9194
/** @param {import("./respecDocWriter").ReSpecError} rsError */

0 commit comments

Comments
 (0)