Fix markdown rendering for links with markup

pull/674/head
Zef Hemel 2024-01-28 16:14:05 +01:00
parent 58ea651668
commit e2aa869660
1 changed files with 2 additions and 3 deletions

View File

@ -201,7 +201,7 @@ function render(
body: "", body: "",
}; };
case "Link": { case "Link": {
const linkText = t.children![1].text!; const linkTextChildren = t.children!.slice(1, -4);
const urlNode = findNodeOfType(t, "URL"); const urlNode = findNodeOfType(t, "URL");
if (!urlNode) { if (!urlNode) {
return renderToText(t); return renderToText(t);
@ -215,7 +215,7 @@ function render(
attrs: { attrs: {
href: url, href: url,
}, },
body: linkText, body: cleanTags(mapRender(linkTextChildren)),
}; };
} }
case "Image": { case "Image": {
@ -240,7 +240,6 @@ function render(
// Custom stuff // Custom stuff
case "WikiLink": { case "WikiLink": {
// console.log("WikiLink", JSON.stringify(t, null, 2));
const ref = findNodeOfType(t, "WikiLinkPage")!.children![0].text!; const ref = findNodeOfType(t, "WikiLinkPage")!.children![0].text!;
let linkText = ref.split("/").pop()!; let linkText = ref.split("/").pop()!;
const aliasNode = findNodeOfType(t, "WikiLinkAlias"); const aliasNode = findNodeOfType(t, "WikiLinkAlias");