Fixed edit for markdown images

Signed-off-by: Jaiwanth <jaiwanth2011@gmail.com>
pull/21833/head
Jaiwanth 2021-03-01 22:44:48 +05:30
parent d248a5fa5d
commit d731e82fba
1 changed files with 7 additions and 0 deletions

View File

@ -60,6 +60,11 @@ function parseLink(a: HTMLAnchorElement, partCreator: PartCreator) {
} }
} }
function parseImage(img: HTMLImageElement, partCreator: PartCreator) {
const { src } = img;
return partCreator.plain(`![${img.alt.replace(/[[\\\]]/g, c => "\\" + c)}](${src})`);
}
function parseCodeBlock(n: HTMLElement, partCreator: PartCreator) { function parseCodeBlock(n: HTMLElement, partCreator: PartCreator) {
const parts = []; const parts = [];
let language = ""; let language = "";
@ -102,6 +107,8 @@ function parseElement(n: HTMLElement, partCreator: PartCreator, lastNode: HTMLEl
return parseHeader(n, partCreator); return parseHeader(n, partCreator);
case "A": case "A":
return parseLink(<HTMLAnchorElement>n, partCreator); return parseLink(<HTMLAnchorElement>n, partCreator);
case "IMG":
return parseImage(<HTMLImageElement>n, partCreator);
case "BR": case "BR":
return partCreator.newline(); return partCreator.newline();
case "EM": case "EM":