Skip to content

Commit

Permalink
Update browser.js
Browse files Browse the repository at this point in the history
  • Loading branch information
Aymkdn committed Aug 29, 2019
1 parent aeb3148 commit d93f638
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion docs/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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 <tag>
// e.g. <strong><em>text</em></strong>
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');
Expand Down

0 comments on commit d93f638

Please sign in to comment.