Skip to content

Commit 41e8126

Browse files
committed
log an error in case of rendering issues
1 parent 5f8f4c9 commit 41e8126

1 file changed

Lines changed: 11 additions & 15 deletions

File tree

src/shared/markdown-it/tag-link.ts

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -58,21 +58,17 @@ function parse_tag_link(
5858
if (options.renderer) {
5959
const rendered = options.renderer(tagName, isMeta);
6060

61-
// the renderer failed to return the bare minimum necessary to link the tag
62-
// log an error to the console, but don't crash the user input
63-
// if (!rendered || !rendered?.link) {
64-
// error(
65-
// "TagLink NodeView",
66-
// "Unable to render taglink due to invalid response from options.renderer: ",
67-
// rendered
68-
// );
69-
// return;
70-
// }
71-
72-
const additionalClasses = rendered.additionalClasses || [];
73-
token.attrSet("href", rendered.link);
74-
token.attrSet("title", rendered.linkTitle);
75-
token.attrSet("additionalClasses", additionalClasses.join(" "));
61+
if (rendered && rendered.link) {
62+
const additionalClasses = rendered.additionalClasses || [];
63+
token.attrSet("href", rendered.link);
64+
token.attrSet("title", rendered.linkTitle);
65+
token.attrSet("additionalClasses", additionalClasses.join(" "));
66+
}
67+
else {
68+
// We don't want to crash the parsing process here since we can still display a passable version of the tag link.
69+
// However, we should at least log a console error.
70+
console.error(`Unable to fully render taglink for [${tagName}] due to invalid response from options.renderer.`);
71+
}
7672
}
7773

7874
token = state.push("text", "", 0);

0 commit comments

Comments
 (0)