html-to-pdfmake
Advanced tools
Comparing version 1.0.5 to 1.0.6
@@ -112,2 +112,4 @@ var pdfMake = require("pdfmake/build/pdfmake"); | ||
</div> | ||
<p style="text-align: center;"> <span style="font-size: 14px;"><em><strong>Bold italic centered text</strong></em></span> </p> | ||
`, window); | ||
@@ -114,0 +116,0 @@ |
@@ -94,3 +94,3 @@ // source: https://github.com/OpenSlides/OpenSlides/blob/f4f8b8422f9b3fbab58e35ac3f8f870d35813b7d/client/src/app/core/ui-services/html-to-pdf.service.ts | ||
if (element.textContent) { | ||
text = element.textContent.replace(/\n(\s+)?/g, ""); | ||
text = element.textContent.replace(/\n(\s+)?/g, "").trim(); | ||
if (text) { | ||
@@ -216,2 +216,8 @@ ret = {'text': text}; | ||
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]); | ||
@@ -218,0 +224,0 @@ // for TD and TH we want to include the style from TR |
{ | ||
"name": "html-to-pdfmake", | ||
"version": "1.0.5", | ||
"version": "1.0.6", | ||
"description": "Convert HTML code to PDFMake", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -340,1 +340,21 @@ var htmlToPdfMake = require('../index.js'); | ||
}) | ||
test("cascade_tags", function(t) { | ||
var ret = htmlToPdfMake('<p style="text-align: center;"> <span style="font-size: 14px;"><em><strong>test</strong></em></span> </p>', window); | ||
t.check(Array.isArray(ret) && ret.length===1, "return is OK"); | ||
ret = ret[0]; | ||
t.check( | ||
ret.text === "test" && | ||
ret.bold && | ||
ret.italics && | ||
ret.fontSize === 14 && | ||
ret.alignment === 'center' && | ||
Array.isArray(ret.style) && | ||
ret.style.includes('html-strong') && | ||
ret.style.includes('html-em') && | ||
ret.style.includes('html-span') && | ||
ret.style.includes('html-p'), | ||
"cascade_tags"); | ||
t.finish(); | ||
}) |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
91508
1201