Skip to content

Commit

Permalink
Fix duplicated br tags (#2717)
Browse files Browse the repository at this point in the history
* Adjust test to demo duplicated br tags

* Fix patchDocument duplicating br tags

* Only include w:Pr

* Fix tag condition

---------

Co-authored-by: Dolan <[email protected]>
  • Loading branch information
SebKranz and dolanmiu authored Nov 20, 2024
1 parent 7f3c561 commit dece0f5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/patcher/replacer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ export const MOCK_JSON = {
name: "w:t",
elements: [{ type: "text", text: "What a {{bold}} text!" }],
},
{
type: "element",
name: "w:br",
},
],
},
],
Expand Down Expand Up @@ -176,6 +180,10 @@ describe("replacer", () => {
name: "w:t",
elements: [{ type: "text", text: " text!" }],
},
{
name: "w:br",
type: "element",
},
],
},
]);
Expand Down
2 changes: 1 addition & 1 deletion src/patcher/replacer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export const replacer = ({

if (keepOriginalStyles) {
const runElementNonTextualElements = runElementToBeReplaced.elements!.filter(
(e) => e.type === "element" && e.name !== "w:t" && e.name !== "w:br" && e.name !== "w:tab",
(e) => e.type === "element" && e.name === "w:rPr",
);

newRunElements = textJson.map((e) => ({
Expand Down

0 comments on commit dece0f5

Please sign in to comment.