Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replacer duplicates line breaks when keepOriginalStyles: true #2716

Open
SebKranz opened this issue Aug 20, 2024 · 1 comment · May be fixed by #2717
Open

replacer duplicates line breaks when keepOriginalStyles: true #2716

SebKranz opened this issue Aug 20, 2024 · 1 comment · May be fixed by #2717

Comments

@SebKranz
Copy link

SebKranz commented Aug 20, 2024

I presume that the following line duplicates non-textual elements in order to move w:Pr tags over to the inserted, and the right run.

if (keepOriginalStyles) {
const runElementNonTextualElements = runElementToBeReplaced.elements!.filter(
(e) => e.type === "element" && e.name !== "w:t",
);
newRunElements = textJson.map((e) => ({
...e,
elements: [...runElementNonTextualElements, ...e.elements!],
}));
patchedRightElement = {
...right,
elements: [...runElementNonTextualElements, ...right.elements!],
};
}

However, the function for filtering non-textual elements currently doesn't account for <w:br>.

As a result, the w:br tag is added to the inserted run and also the right.

@SebKranz SebKranz linked a pull request Aug 21, 2024 that will close this issue
@SebKranz
Copy link
Author

SebKranz commented Aug 21, 2024

I've added a PR that solves this for w:br tags.

However, looking at section 17.3.3 of the Office Open XML spec at https://ecma-international.org/publications-and-standards/standards/ecma-376/, there are many tags that can exist within a text run.
In fact, it looks to me like w:Pr is the only run-child that should be duplicated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant