From f706f4e7da0c4bfffc8dcc08c116c178e1955a38 Mon Sep 17 00:00:00 2001 From: sorlov Date: Fri, 10 Dec 2021 12:36:18 +0300 Subject: [PATCH] [+] convertFromHtml span with whitespace [*] span with inlineStyle and once whitespace --- src/convertFromHTML.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/convertFromHTML.js b/src/convertFromHTML.js index 55a8f84..50b19f1 100644 --- a/src/convertFromHTML.js +++ b/src/convertFromHTML.js @@ -371,6 +371,17 @@ function genFragment( inlineStyle = processInlineTag(nodeName, node, inlineStyle); inlineStyle = processCustomInlineStyles(nodeName, node, inlineStyle); + if (nodeName === 'span' && (node.textContent === SPACE || node.textContent === NBSP || node.textContent === '\s')) { + // When tag with only whitespace + let text = node.textContent + return { + text, + inlines: Array(text.length).fill(inlineStyle), + entities: [], + blocks: [], + } + } + // Handle lists if (nodeName === 'ul' || nodeName === 'ol') { if (lastList) {