Merge pull request #5703 from jaiwanth-v/fix-edit-markdown-image

Fixed edit for markdown images
pull/21833/head
Travis Ralston 2021-03-01 16:57:08 -07:00 committed by GitHub
commit 178ae2f7bf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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) {
const parts = [];
let language = "";
@ -102,6 +107,8 @@ function parseElement(n: HTMLElement, partCreator: PartCreator, lastNode: HTMLEl
return parseHeader(n, partCreator);
case "A":
return parseLink(<HTMLAnchorElement>n, partCreator);
case "IMG":
return parseImage(<HTMLImageElement>n, partCreator);
case "BR":
return partCreator.newline();
case "EM":