htmlToMarkdown: forgot headers

This commit is contained in:
Cynthia Foxwell 2025-04-05 10:51:17 -06:00
parent ad3237ab94
commit 2ba24d01aa
Signed by: Cynosphere
SSH key fingerprint: SHA256:H3SM8ufP/uxqLwKSH7xY89TDnbR9uOHzjLoBr0tlajk

View file

@ -65,8 +65,8 @@ function whenYouWalking(tree, images = true, embed = true) {
alt != null ? ` "${alt}"` : ""
})`;
}
} else if (elem.b) {
str += `**${whenYouWalking(elem.b, images, embed)}**`;
} else if (elem.b || elem.h4 || elem.h5 || elem.h6) {
str += `**${whenYouWalking(elem.b ?? elem.h4 ?? elem.h5 ?? elem.h6, images, embed)}**`;
} else if (elem.blockquote) {
str += `> ${whenYouWalking(elem.blockquote, images, embed).replaceAll(/\n/g, "\n> ")}`;
} else if (elem.br) {
@ -75,10 +75,14 @@ function whenYouWalking(tree, images = true, embed = true) {
str += `\`${whenYouWalking(elem.code, images, embed)}\``;
} else if (elem.dd) {
str += `\u3000\u3000${whenYouWalking(elem.dd, images, embed).replaceAll(/\n/g, "\n\u3000\u3000")}`;
} else if (elem.em) {
str += `_${whenYouWalking(elem.em, images, embed)}_`;
} else if (elem.i) {
str += `_${whenYouWalking(elem.i, images, embed)}_`;
} else if (elem.em || elem.i) {
str += `_${whenYouWalking(elem.em ?? elem.i, images, embed)}_`;
} else if (elem.h1) {
str += `# ${whenYouWalking(elem.h1, images, embed)}`;
} else if (elem.h2) {
str += `## ${whenYouWalking(elem.h2, images, embed)}`;
} else if (elem.h3) {
str += `### ${whenYouWalking(elem.h3, images, embed)}`;
} else if (elem.img && images) {
const link = elem.$src ?? elem[":@"]?.$src;
const alt = elem.$alt ?? elem.$title ?? elem[":@"]?.$alt ?? elem[":@"]?.$title;