Skip to content

Commit

Permalink
Run prettier with node v20
Browse files Browse the repository at this point in the history
  • Loading branch information
joemoongit committed Sep 12, 2024
1 parent 65159af commit d216ae7
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 84 deletions.
2 changes: 1 addition & 1 deletion lib/recipe/htmlToTextObjects.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ exports.htmlToTextObjects = function (htmlCodes, options = {}) {
htmlCodes = htmlCodes.replace(/<br\/?>/g, "<p>[@@DONOT_RENDER_THIS@@]</p>");
const nodes = new DOMParser().parseFromString(
`<html>${htmlCodes}</html>`,
"text/html"
"text/html",
);
const textObjects = parseNode(nodes, options).childs[0].childs;
return textObjects;
Expand Down
53 changes: 26 additions & 27 deletions lib/recipe/text.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ function _initOptions(self, x = {}, y, options = {}) {
if (self._flow && mergedOpts.textBox.width === undefined) {
mergedOpts.textBox.width = Math.max(
0,
self.metadata[self.pageNumber].width - self.x - self._margin.right
self.metadata[self.pageNumber].width - self.x - self._margin.right,
);
}

Expand Down Expand Up @@ -261,12 +261,12 @@ exports.text = function text(text = "", x, y, options = {}) {
this.y,
0,
0,
this.pageNumber
this.pageNumber,
);
const pathOptions = this._getPathOptions(
options,
originCoord.nx,
originCoord.ny
originCoord.ny,
);
pathOptions.html = options.html;
pathOptions.hilite = options.hilite;
Expand All @@ -282,7 +282,7 @@ exports.text = function text(text = "", x, y, options = {}) {
let { toWriteTextObjects } = this._layoutText(
textObjects,
textBox,
pathOptions
pathOptions,
);

if (!textBox.width) {
Expand Down Expand Up @@ -495,7 +495,7 @@ exports.text = function text(text = "", x, y, options = {}) {
options,
(word, xx) => {
emitText(word.value, xx, y + baseline, context);
}
},
);
} else {
if (textBox.wrap !== "auto") {
Expand All @@ -521,7 +521,7 @@ exports.text = function text(text = "", x, y, options = {}) {
const xObject = new xObjectForm(
this.writer,
textBox.width,
lineHeight
lineHeight,
);
const xObjectCtx = xObject.getContentContext();
if (options.colorModel) {
Expand All @@ -541,7 +541,7 @@ exports.text = function text(text = "", x, y, options = {}) {
options,
(word, xx) => {
emitText(word.value, xx - nx, baseline, xObjectCtx, options);
}
},
);
} else {
emitTextObject(text, x - nx, baseline, xObjectCtx, options);
Expand Down Expand Up @@ -748,8 +748,8 @@ exports._layoutText = function _layoutText(textObjects, textBox, pathOptions) {
textBox.padding[3] !== undefined
? textBox.padding[3]
: textBox.padding[1] !== undefined
? textBox.padding[1]
: textBox.padding[0],
? textBox.padding[1]
: textBox.padding[0],
});

let firstLineHeight;
Expand Down Expand Up @@ -875,7 +875,7 @@ function getTextBoxPosition(self, textBox, pathOptions) {
self.x,
self.y,
offsetX,
offsetY
offsetY,
);
return [nx, ny];
}
Expand All @@ -897,7 +897,7 @@ function drawTextBox(self, nx, ny, textBox, pathOptions) {
rotation: pathOptions.rotation,
rotationOrigin: [pathOptions.originX, pathOptions.originY],
borderRadius: borderRadius,
})
}),
);
}

Expand Down Expand Up @@ -997,7 +997,7 @@ function elideNonFittingText(textBox, line, word, pathOptions) {
} else if (!usingPreviousWord) {
tooBig = new Word(
line.words.pop().value.slice(0, -1) + ellipsis,
pathOptions
pathOptions,
);
usingPreviousWord = true;
} else {
Expand Down Expand Up @@ -1095,7 +1095,7 @@ function makeTextObjects(self, textObject = {}, pathOptions, textBox = {}) {
// Need special characters '|}' because they have ascenders that go beyond upper case letters.
const textDimensions = pathOptions.font.calculateTextDimensions(
"ABCDEFGHIJKLMNOPQRSTUVWXYZgjpqy|}",
size
size,
);
const textHeight = textDimensions.height;

Expand Down Expand Up @@ -1218,7 +1218,7 @@ function makeTextObjects(self, textObject = {}, pathOptions, textBox = {}) {
newLine,
toWriteTextObjects,
wordCount,
totalTextWidth
totalTextWidth,
);

toWriteTextObjects.push(
Expand All @@ -1231,8 +1231,8 @@ function makeTextObjects(self, textObject = {}, pathOptions, textBox = {}) {
wordCount: wordCount,
totalTextWidth: totalTextWidth,
lineComplete: true,
})
)
}),
),
);
wordCount = 0;
totalTextWidth = 0;
Expand All @@ -1256,8 +1256,8 @@ function makeTextObjects(self, textObject = {}, pathOptions, textBox = {}) {
textBox,
Object.assign({}, lineOpts, {
lineComplete: true,
})
)
}),
),
);
}
} else {
Expand Down Expand Up @@ -1298,8 +1298,8 @@ function makeTextObjects(self, textObject = {}, pathOptions, textBox = {}) {
newLine,
lineID,
textBox,
Object.assign({ lineComplete: true, lastLine: true }, lineOpts)
)
Object.assign({ lineComplete: true, lastLine: true }, lineOpts),
),
);
markLineComplete(toWriteTextObjects);
newLine = new Line(lineMaxWidth, lineHeight, size, pathOptions);
Expand All @@ -1320,7 +1320,7 @@ function makeTextObjects(self, textObject = {}, pathOptions, textBox = {}) {
newLine,
toWriteTextObjects,
wordCount,
totalTextWidth
totalTextWidth,
);

toWriteTextObjects.push(
Expand All @@ -1333,8 +1333,8 @@ function makeTextObjects(self, textObject = {}, pathOptions, textBox = {}) {
wordCount: wordCount,
totalTextWidth: totalTextWidth,
lastLine: isLastLine,
})
)
}),
),
);
} else {
toWriteTextObjects[toWriteTextObjects.length - 1].lastLine = isLastLine;
Expand Down Expand Up @@ -1379,9 +1379,8 @@ exports.movedown = function movedown(lines = 1, returnCoords = false) {
} else {
// This handles continuous text positioning
markLineComplete(this._previousTextObjects, lines);
this._previousTextObjects[
this._previousTextObjects.length - 1
].lastLine = true;
this._previousTextObjects[this._previousTextObjects.length - 1].lastLine =
true;
}

return returnCoords ? [this.x, this.y] : this;
Expand Down Expand Up @@ -1459,7 +1458,7 @@ exports.layout = function layout(id, x, y, width, height, options = {}) {
height,
element.text,
element.name,
element
element,
);
this._layouts[id].push(column);
x += width;
Expand Down
Loading

0 comments on commit d216ae7

Please sign in to comment.