FIX: trim no-break space in to-markdown (#11130)
No-break spaces were the reason for double spaces when pasting text to the composer. https://meta.discourse.org/t/extra-spaces-added-to-markdown-with-rich-text-pasted/112769
This commit is contained in:
parent
1b52cdedb1
commit
9bfce1a8dd
|
@ -654,6 +654,7 @@ function trimUnwanted(html) {
|
|||
const body = html.match(/<body[^>]*>([\s\S]*?)<\/body>/);
|
||||
html = body ? body[1] : html;
|
||||
html = html.replace(/\r|\n| /g, " ");
|
||||
html = html.replace(/\u00A0/g, " "); // trim no-break space
|
||||
|
||||
let match;
|
||||
while ((match = html.match(/<[^\s>]+[^>]*>\s{2,}<[^\s>]+[^>]*>/))) {
|
||||
|
|
|
@ -21,6 +21,11 @@ module("Unit | Utility | to-markdown", function () {
|
|||
random</b> <s>bold</s> words.</i>`;
|
||||
markdown = `<i>Italicised line with <b>some\nrandom</b> ~~bold~~ words.</i>`;
|
||||
assert.equal(toMarkdown(html), markdown);
|
||||
|
||||
// eslint-disable-next-line no-irregular-whitespace
|
||||
html = `<span>this is<span> </span></span><strong>bold</strong><span><span> </span>statement</span>`;
|
||||
markdown = `this is **bold** statement`;
|
||||
assert.equal(toMarkdown(html), markdown);
|
||||
});
|
||||
|
||||
test("converts a link", function (assert) {
|
||||
|
|
Loading…
Reference in New Issue