@github/paste-markdown
Advanced tools
Comparing version 1.3.0 to 1.3.1
@@ -88,3 +88,3 @@ function insertText(textarea, text) { | ||
const doc = parser.parseFromString(textHTMLClean, 'text/html'); | ||
const walker = doc.createTreeWalker(doc.body, NodeFilter.SHOW_ELEMENT); | ||
const walker = doc.createTreeWalker(doc.body, NodeFilter.SHOW_ELEMENT, node => node.parentNode && isLink(node.parentNode) ? NodeFilter.FILTER_REJECT : NodeFilter.FILTER_ACCEPT); | ||
const markdown = convertToMarkdown(plaintext, walker); | ||
@@ -106,3 +106,5 @@ if (markdown === plaintext) | ||
index++; | ||
const text = isLink(currentNode) ? currentNode.textContent || '' : ((_a = currentNode.firstChild) === null || _a === void 0 ? void 0 : _a.wholeText) || ''; | ||
const text = isLink(currentNode) | ||
? (currentNode.textContent || '').replace(/[\t\n\r ]+/g, ' ') | ||
: ((_a = currentNode.firstChild) === null || _a === void 0 ? void 0 : _a.wholeText) || ''; | ||
if (isEmptyString(text)) { | ||
@@ -115,3 +117,3 @@ currentNode = walker.nextNode(); | ||
if (isLink(currentNode)) { | ||
const markdownLink = linkify$2(currentNode); | ||
const markdownLink = linkify$2(currentNode, text); | ||
markdown = | ||
@@ -139,4 +141,3 @@ markdown.slice(0, markdownFoundIndex) + markdownLink + markdown.slice(markdownFoundIndex + text.length); | ||
} | ||
function linkify$2(element) { | ||
const label = element.textContent || ''; | ||
function linkify$2(element, label) { | ||
const url = element.href || ''; | ||
@@ -143,0 +144,0 @@ let markdown = ''; |
@@ -94,3 +94,3 @@ (function (global, factory) { | ||
const doc = parser.parseFromString(textHTMLClean, 'text/html'); | ||
const walker = doc.createTreeWalker(doc.body, NodeFilter.SHOW_ELEMENT); | ||
const walker = doc.createTreeWalker(doc.body, NodeFilter.SHOW_ELEMENT, node => node.parentNode && isLink(node.parentNode) ? NodeFilter.FILTER_REJECT : NodeFilter.FILTER_ACCEPT); | ||
const markdown = convertToMarkdown(plaintext, walker); | ||
@@ -112,3 +112,5 @@ if (markdown === plaintext) | ||
index++; | ||
const text = isLink(currentNode) ? currentNode.textContent || '' : ((_a = currentNode.firstChild) === null || _a === void 0 ? void 0 : _a.wholeText) || ''; | ||
const text = isLink(currentNode) | ||
? (currentNode.textContent || '').replace(/[\t\n\r ]+/g, ' ') | ||
: ((_a = currentNode.firstChild) === null || _a === void 0 ? void 0 : _a.wholeText) || ''; | ||
if (isEmptyString(text)) { | ||
@@ -121,3 +123,3 @@ currentNode = walker.nextNode(); | ||
if (isLink(currentNode)) { | ||
const markdownLink = linkify$2(currentNode); | ||
const markdownLink = linkify$2(currentNode, text); | ||
markdown = | ||
@@ -145,4 +147,3 @@ markdown.slice(0, markdownFoundIndex) + markdownLink + markdown.slice(markdownFoundIndex + text.length); | ||
} | ||
function linkify$2(element) { | ||
const label = element.textContent || ''; | ||
function linkify$2(element, label) { | ||
const url = element.href || ''; | ||
@@ -149,0 +150,0 @@ let markdown = ''; |
{ | ||
"name": "@github/paste-markdown", | ||
"version": "1.3.0", | ||
"version": "1.3.1", | ||
"description": "Paste spreadsheet cells as a Markdown table.", | ||
@@ -5,0 +5,0 @@ "repository": "github/paste-markdown", |
35208
856