Skip to content

Commit

Permalink
v2.4.21
Browse files Browse the repository at this point in the history
Support "PRE" tag
  • Loading branch information
Aymkdn committed Jun 8, 2023
1 parent 950b6c8 commit c10dd7c
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 5 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,7 @@ The below HTML tags are supported:
- `IMG`
- `SVG`
- `SUP` / `SUB`
- `PRE`

### CSS properties supported

Expand Down
2 changes: 1 addition & 1 deletion browser.js

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion docs/browser-2.4.20.js

This file was deleted.

1 change: 1 addition & 0 deletions docs/browser-2.4.21.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ <h1>HTML to PDFMake convertor</h1>
<div id="pdf_ie" style="display:none;padding:3em">The PDF file is sent to you for download. Use a modern browser (like Chrome or Firefox) to display the PDF in this page.</div>
</div>
</div>
<script src="browser-2.4.20.js"></script>
<script src="browser-2.4.21.js"></script>
<script src="https://cdn.jsdelivr.net/npm/pdfmake@latest/build/pdfmake.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/pdfmake@latest/build/vfs_fonts.js"></script>
<script>
Expand Down
Binary file modified example.pdf
Binary file not shown.
7 changes: 6 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,9 @@ function htmlToPdfMake(htmlText, options) {
if (element.textContent) {
text = element.textContent;
// check if we have 'white-space' in the parent's style
// or if the parent is a <PRE>
var styleParentTextNode = this.parseStyle(parents[parents.length-1], true);
var hasWhiteSpace = false;
var hasWhiteSpace = (parents[parents.length-1].nodeName === "PRE");
for (i=0; i<styleParentTextNode.length; i++) {
if (styleParentTextNode[i].key === "preserveLeadingSpaces") {
hasWhiteSpace=styleParentTextNode[i].value;
Expand Down Expand Up @@ -442,6 +443,10 @@ function htmlToPdfMake(htmlText, options) {
}
break;
}
case "PRE":{
ret.preserveLeadingSpaces = true;
break;
}
case "IMG": {
if (this.imagesByReference) {
var src = element.getAttribute("data-src") || element.getAttribute("src");
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "html-to-pdfmake",
"version": "2.4.20",
"version": "2.4.21",
"description": "Convert HTML code to PDFMake",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit c10dd7c

Please sign in to comment.