diff --git a/docs/browser.js b/docs/browser.js index aa8a26d..77e4a6a 100644 --- a/docs/browser.js +++ b/docs/browser.js @@ -92,7 +92,7 @@ module.exports = function(htmlText, wndw) { switch(element.nodeType) { case 3: { // TEXT_NODE if (element.textContent) { - text = element.textContent.replace(/\n(\s+)?/g, ""); + text = element.textContent.replace(/\n(\s+)?/g, "").trim(); if (text) { ret = {'text': text}; if (parentNodeName) { @@ -213,6 +213,12 @@ module.exports = function(htmlText, wndw) { // "tr" elements should always contain an array if (ret.length === 1 && nodeName !== "tr") { ret=ret[0]; + // check if we have a default css style to apply when a text is inside several + // e.g. text + if (ret.text) { + applyDefaultStyle(ret, nodeName); + setComputedStyle(ret, element.getAttribute("style")); + } ret.style = (ret.style||[]).concat(['html-'+nodeName]); // for TD and TH we want to include the style from TR if (nodeName === "td" || nodeName === "th") ret.style.push('html-tr');