Skip to content

Commit

Permalink
v2.2.5
Browse files Browse the repository at this point in the history
  • Loading branch information
Aymkdn committed Jun 23, 2021
1 parent 341f6e8 commit e553a2d
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion browser.js

Large diffs are not rendered by default.

Binary file modified example.pdf
Binary file not shown.
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -394,10 +394,10 @@ function htmlToPdfMake(htmlText, options) {
// the link must be applied to the deeper `text`
var setLink = function(pointer, href) {
if (Array.isArray(pointer.text)) {
pointer.text = setLink(pointer.text[0], href);
return pointer;
return setLink(pointer.text[0], href);
}
pointer.link = href;
pointer.nodeName = "A";
return pointer;
}
ret = setLink(ret, element.getAttribute("href"));
Expand Down
14 changes: 7 additions & 7 deletions test/unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ test("u",function(t) {
ret = ret[0];
t.check(
ret.text === "underline word" &&
Array.isArray(ret.decoration) &&ret.decoration.length === 1 && ret.decoration[0] &&
Array.isArray(ret.decoration) && ret.decoration.length === 1 && ret.decoration[0] &&
Array.isArray(ret.style) &&
ret.style[0] === 'html-u',
"<u>");
Expand Down Expand Up @@ -189,7 +189,7 @@ test("a",function(t) {
ret = ret[0];
t.check(ret.text === "link", "text");
t.check(ret.color === "blue", "color");
t.check(Array.isArray(ret.decoration) &&ret.decoration.length === 1 && ret.decoration[0] === "underline", "decoration");
t.check(Array.isArray(ret.decoration) && ret.decoration.length === 1 && ret.decoration[0] === "underline", "decoration");
t.check(ret.link === "https://www.somewhere.com", "href");
t.check(Array.isArray(ret.style), "style is array");
t.check(ret.style[0] === 'html-a', "class");
Expand All @@ -204,7 +204,7 @@ test("strike",function(t) {
ret = ret[0];
t.check(
ret.text === "strike" &&
Array.isArray(ret.decoration) &&ret.decoration.length === 1 && ret.decoration[0] === "lineThrough" &&
Array.isArray(ret.decoration) && ret.decoration.length === 1 && ret.decoration[0] === "lineThrough" &&
Array.isArray(ret.style) &&
ret.style[0] === 'html-strike',
"<strike>");
Expand Down Expand Up @@ -795,7 +795,7 @@ test("'decoration' style", function(t) {
var ret = htmlToPdfMake(html, {window:window});
if (debug) console.log(JSON.stringify(ret));
t.check(Array.isArray(ret) && ret.length===1, "return is OK");
t.check(Array.isArray(ret[0].text) && ret[0].text.length===1 &&Array.isArray(ret[0].text[0].text) && ret[0].text[0].text.length===1, "structure is OK");
t.check(Array.isArray(ret[0].text) && ret[0].text.length===1 && Array.isArray(ret[0].text[0].text) && ret[0].text[0].text.length===1, "structure is OK");
ret = ret[0].text[0].text[0];
t.check(ret.text === "Test", "text is 'Test'");
t.check(ret.nodeName === "S", "nodeName is 'S'");
Expand All @@ -810,7 +810,7 @@ test("'decoration' style 2", function(t) {
var ret = htmlToPdfMake(html, {window:window});
if (debug) console.log(JSON.stringify(ret));
t.check(Array.isArray(ret) && ret.length===1, "return is OK");
t.check(Array.isArray(ret[0].text) && ret[0].text.length===1 &&Array.isArray(ret[0].text[0].text) && ret[0].text[0].text.length===1, "structure is OK");
t.check(Array.isArray(ret[0].text) && ret[0].text.length===1 && Array.isArray(ret[0].text[0].text) && ret[0].text[0].text.length===1, "structure is OK");
ret = ret[0].text[0].text[0];
t.check(ret.text === "Test", "text is 'Test'");
t.check(ret.nodeName === "SPAN", "nodeName is 'SPAN'");
Expand All @@ -836,7 +836,7 @@ test("sup", function (t) {
if (debug) console.log(JSON.stringify(ret));
t.check(Array.isArray(ret) && ret.length === 1, "return is OK");
ret = ret[0];
t.check(ret.text === "sup" && ret.sup &&ret.sup.offset && ret.sup.fontSize, "<sup>");
t.check(ret.text === "sup" && ret.sup && ret.sup.offset && ret.sup.fontSize, "<sup>");
t.finish();
});

Expand All @@ -846,6 +846,6 @@ test("sub", function (t) {
if (debug) console.log(JSON.stringify(ret));
t.check(Array.isArray(ret) && ret.length === 1, "return is OK");
ret = ret[0];
t.check(ret.text === "sub" && ret.sub &&ret.sub.offset && ret.sub.fontSize, "<sub>");
t.check(ret.text === "sub" && ret.sub && ret.sub.offset && ret.sub.fontSize, "<sub>");
t.finish();
});

0 comments on commit e553a2d

Please sign in to comment.