Fix WYSIWYG text + image paste (#13542)

* Fix WYSIWYG text + image paste

* add test for a link and text
This commit is contained in:
Vasu Bhog
2020-11-25 12:42:07 -06:00
committed by GitHub
parent 1554e51932
commit 2a7b90fd70
2 changed files with 13 additions and 2 deletions

View File

@@ -101,10 +101,11 @@ export class HTMLMarkdownConverter {
const notebookFolder = this.notebookUri ? path.join(path.dirname(this.notebookUri.fsPath), path.sep) : '';
let relativePath = findPathRelativeToContent(notebookFolder, notebookLink);
node.innerText = escapeAngleBrackets(node.innerText);
content = escapeAngleBrackets(content);
if (relativePath) {
return `[${node.innerText}](${relativePath})`;
}
return `[${node.innerText}](${node.href})`;
return `[${content}](${node.href})`;
}
});
this.turndownService.addRule('listItem', {
@@ -137,14 +138,22 @@ export class HTMLMarkdownConverter {
this.turndownService.addRule('p', {
filter: 'p',
replacement: function (content, node) {
let isAnchorElement: boolean = false;
node.childNodes.forEach(c => {
if (c.nodeType === Node.TEXT_NODE) {
c.nodeValue = escapeAngleBrackets(c.textContent);
} else if (c.nodeType === Node.ELEMENT_NODE) {
c.innerText = escapeAngleBrackets(c.textContent);
if (c.nodeName === 'A') {
isAnchorElement = true;
}
}
});
return '\n\n' + node.innerHTML.replace(/&lt;/gi, '<').replace(/&gt;/gi, '>').replace(/&nbsp;/gi, '') + '\n\n';
if (isAnchorElement) {
return content;
} else {
return '\n\n' + node.innerHTML.replace(/&lt;/gi, '<').replace(/&gt;/gi, '>').replace(/&nbsp;/gi, '') + '\n\n';
}
}
});
this.turndownService.addRule('heading', {