Skip to content

Conversation

@bdabelow
Copy link

@bdabelow bdabelow commented Mar 30, 2023

Replacements are being made in text and target of hyperlinks, including in header and footer.

Fixes #8

Replacements are being made in text and target of hyperlinks, including in header and footer.
@bdabelow bdabelow marked this pull request as ready for review March 30, 2023 21:36
if key in self.p.text:
self._complex_replace_key(key, value)
# Make replacements in hyperlink texts
for link in self.p._element.xpath(".//w:hyperlink"):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of having this code here, I think it'd be better to move it to a specific method, like self._replace_hyperlinks(key, value)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, makes sense. Done.

@ivanbicalho
Copy link
Owner

Hey @bdabelow, I was checking your code to merge it, but I found new issues with the current approach. I fixed one, but there are more, for example, this code is not right: inner_run = link.xpath("w:r", namespaces=link.nsmap)[0]. This can contain part of the text in a different index, so replacing only the 0 will not solve the problem. I'm going to fix it soon and then merge it!

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 this pull request may close these issues.

Replace in links

2 participants