muhammara 5.0.0 → 5.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -3
- package/README.md +3 -0
- package/lib/recipe/htmlToTextObjects.js +7 -4
- package/lib/recipe/text.js +2 -1
- package/muhammara.d.ts +1 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,13 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [5.0.1] - 2024-09-28
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- Tests for bold, italic, underline, strikethrough, and highlights in textboxes
|
|
15
|
+
- Add missing node v21 and v22 to the build matrix (#417)
|
|
16
|
+
|
|
10
17
|
## [5.0.0] - 2024-09-08
|
|
11
18
|
|
|
12
19
|
### Added
|
|
@@ -50,15 +57,15 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
|
|
50
57
|
|
|
51
58
|
### Fixed
|
|
52
59
|
|
|
53
|
-
- Underline in text object
|
|
54
60
|
- Recipe type / arg documentation
|
|
55
61
|
- Add missing type `userPassword` to `EncryptOptions`
|
|
62
|
+
- Underline in text object
|
|
56
63
|
|
|
57
64
|
### Added
|
|
58
65
|
|
|
59
|
-
- Strikethrough implementation in text object
|
|
60
66
|
- Add electron 23.2., 23.3
|
|
61
67
|
- Recipe infos to readme
|
|
68
|
+
- Strikethrough implementation in text object
|
|
62
69
|
- Electron v24.1, 24.2, 24.3, 24.4, 24.5, 24.6
|
|
63
70
|
- Add node 20.x
|
|
64
71
|
- Add electron v25.0, 25.1, 25.2, 25.3
|
|
@@ -438,7 +445,8 @@ with the following changes.
|
|
|
438
445
|
|
|
439
446
|
- Initial release
|
|
440
447
|
|
|
441
|
-
[unreleased]: https://github.com/julianhille/MuhammaraJS/compare/5.0.
|
|
448
|
+
:[unreleased]: https://github.com/julianhille/MuhammaraJS/compare/5.0.1...HEAD
|
|
449
|
+
[5.0.1]: https://github.com/julianhille/MuhammaraJS/compare/5.0.0...5.0.1
|
|
442
450
|
[5.0.0]: https://github.com/julianhille/MuhammaraJS/compare/4.1.0...5.0.0
|
|
443
451
|
[4.1.0]: https://github.com/julianhille/MuhammaraJS/compare/4.0.0...4.1.0
|
|
444
452
|
[4.0.0]: https://github.com/julianhille/MuhammaraJS/compare/3.8.0...4.0.0
|
package/README.md
CHANGED
|
@@ -51,6 +51,9 @@ This won't affect a lot of you but still.
|
|
|
51
51
|
|
|
52
52
|
### Version 5.x
|
|
53
53
|
|
|
54
|
+
- You may need to update your base linux distro where you use this as muhammara now needs GLIBCXX_3.4.31
|
|
55
|
+
Github removed ubuntu 18.04 runners and so we build on 20.04 now.
|
|
56
|
+
Ubuntu 20.04 comes with newer libstdc++6 and this brings newer glibc with it.
|
|
54
57
|
- Node <= 16 pre-builts have been removed
|
|
55
58
|
- Electron <= 23 pre-builts have been removed
|
|
56
59
|
- GCC 13 needed / std ++ 20 (only needed if you compile yourself)
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
const DOMParser = require("@xmldom/xmldom").DOMParser;
|
|
2
2
|
|
|
3
|
-
exports.htmlToTextObjects = function (htmlCodes) {
|
|
3
|
+
exports.htmlToTextObjects = function (htmlCodes, options = {}) {
|
|
4
4
|
htmlCodes = htmlCodes.replace(/<br\/?>/g, "<p>[@@DONOT_RENDER_THIS@@]</p>");
|
|
5
5
|
const nodes = new DOMParser().parseFromString(
|
|
6
6
|
`<html>${htmlCodes}</html>`,
|
|
7
7
|
"text/html",
|
|
8
8
|
);
|
|
9
|
-
const textObjects = parseNode(nodes).childs[0].childs;
|
|
9
|
+
const textObjects = parseNode(nodes, options).childs[0].childs;
|
|
10
10
|
return textObjects;
|
|
11
11
|
};
|
|
12
12
|
|
|
@@ -40,7 +40,7 @@ function isItalicTag(tagName = "") {
|
|
|
40
40
|
return italicTags.includes(tagName);
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
function parseNode(node) {
|
|
43
|
+
function parseNode(node, options) {
|
|
44
44
|
const attributes = [];
|
|
45
45
|
const styles = {};
|
|
46
46
|
for (let i in node.attributes) {
|
|
@@ -82,6 +82,7 @@ function parseNode(node) {
|
|
|
82
82
|
const parsedData = {
|
|
83
83
|
value,
|
|
84
84
|
tag: node.tagName,
|
|
85
|
+
font: options.font,
|
|
85
86
|
isBold: isBoldTag(node.tagName),
|
|
86
87
|
isItalic: isItalicTag(node.tagName),
|
|
87
88
|
underline: node.tagName == "u",
|
|
@@ -89,12 +90,14 @@ function parseNode(node) {
|
|
|
89
90
|
attributes,
|
|
90
91
|
styles,
|
|
91
92
|
needsLineBreaker: needsLineBreaker(node.tagName),
|
|
93
|
+
size: options.size,
|
|
92
94
|
sizeRatio: getFontSizeRatio(node.tagName),
|
|
95
|
+
sizeRatios: [getFontSizeRatio(node.tagName)],
|
|
93
96
|
link: node.tagName == "a" ? node.attributes[0].value : null,
|
|
94
97
|
childs: [],
|
|
95
98
|
};
|
|
96
99
|
for (let num in node.childNodes) {
|
|
97
|
-
parsedData.childs.push(parseNode(node.childNodes[num]));
|
|
100
|
+
parsedData.childs.push(parseNode(node.childNodes[num], options));
|
|
98
101
|
}
|
|
99
102
|
const ignoreValue = ["\n", "\n\n"];
|
|
100
103
|
parsedData.childs = parsedData.childs.filter((item) => {
|
package/lib/recipe/text.js
CHANGED
|
@@ -208,6 +208,7 @@ exports._makeTextBox = function _makeTextBox(options) {
|
|
|
208
208
|
* @param {Object|Boolean} [options.highlight] - Text markup annotation.
|
|
209
209
|
* @param {Object|Boolean} [options.underline] - Text markup annotation.
|
|
210
210
|
* @param {Object|Boolean} [options.strikeOut] - Text markup annotation.
|
|
211
|
+
* @param {Boolean} [options.html] - Interpret text as html
|
|
211
212
|
* @param {Boolean} [options.flow=false] - Used to activate/deactivate text flow which is the
|
|
212
213
|
* ability to use multiple calls to 'text' to create an overall text box.
|
|
213
214
|
* @param {number|string} [options.layout] - An identifier of the layout to be associated with given text.
|
|
@@ -274,7 +275,7 @@ exports.text = function text(text = "", x, y, options = {}) {
|
|
|
274
275
|
this._textOptions = this._flow ? options : { textBox: {} };
|
|
275
276
|
|
|
276
277
|
const textObjects = options.html
|
|
277
|
-
? htmlToTextObjects(text)
|
|
278
|
+
? htmlToTextObjects(text, options)
|
|
278
279
|
: this._makeTextObject(text, pathOptions.size, options);
|
|
279
280
|
const textBox = this._makeTextBox(options);
|
|
280
281
|
|
package/muhammara.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "muhammara",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.1",
|
|
4
4
|
"description": "Create, read and modify PDF files and streams. A drop in replacement for hummusjs PDF library",
|
|
5
5
|
"homepage": "https://github.com/julianhille/Muhammarajs",
|
|
6
6
|
"license": "Apache-2.0",
|