htmlToMarkdown: forgot headers
This commit is contained in:
parent
ad3237ab94
commit
2ba24d01aa
1 changed files with 10 additions and 6 deletions
|
@ -65,8 +65,8 @@ function whenYouWalking(tree, images = true, embed = true) {
|
||||||
alt != null ? ` "${alt}"` : ""
|
alt != null ? ` "${alt}"` : ""
|
||||||
})`;
|
})`;
|
||||||
}
|
}
|
||||||
} else if (elem.b) {
|
} else if (elem.b || elem.h4 || elem.h5 || elem.h6) {
|
||||||
str += `**${whenYouWalking(elem.b, images, embed)}**`;
|
str += `**${whenYouWalking(elem.b ?? elem.h4 ?? elem.h5 ?? elem.h6, images, embed)}**`;
|
||||||
} else if (elem.blockquote) {
|
} else if (elem.blockquote) {
|
||||||
str += `> ${whenYouWalking(elem.blockquote, images, embed).replaceAll(/\n/g, "\n> ")}`;
|
str += `> ${whenYouWalking(elem.blockquote, images, embed).replaceAll(/\n/g, "\n> ")}`;
|
||||||
} else if (elem.br) {
|
} else if (elem.br) {
|
||||||
|
@ -75,10 +75,14 @@ function whenYouWalking(tree, images = true, embed = true) {
|
||||||
str += `\`${whenYouWalking(elem.code, images, embed)}\``;
|
str += `\`${whenYouWalking(elem.code, images, embed)}\``;
|
||||||
} else if (elem.dd) {
|
} else if (elem.dd) {
|
||||||
str += `\u3000\u3000${whenYouWalking(elem.dd, images, embed).replaceAll(/\n/g, "\n\u3000\u3000")}`;
|
str += `\u3000\u3000${whenYouWalking(elem.dd, images, embed).replaceAll(/\n/g, "\n\u3000\u3000")}`;
|
||||||
} else if (elem.em) {
|
} else if (elem.em || elem.i) {
|
||||||
str += `_${whenYouWalking(elem.em, images, embed)}_`;
|
str += `_${whenYouWalking(elem.em ?? elem.i, images, embed)}_`;
|
||||||
} else if (elem.i) {
|
} else if (elem.h1) {
|
||||||
str += `_${whenYouWalking(elem.i, images, embed)}_`;
|
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) {
|
} else if (elem.img && images) {
|
||||||
const link = elem.$src ?? elem[":@"]?.$src;
|
const link = elem.$src ?? elem[":@"]?.$src;
|
||||||
const alt = elem.$alt ?? elem.$title ?? elem[":@"]?.$alt ?? elem[":@"]?.$title;
|
const alt = elem.$alt ?? elem.$title ?? elem[":@"]?.$alt ?? elem[":@"]?.$title;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue