Skip to content

Replace in links #8

Open
Open

Description

@bdabelow

Hi Ivan,
thank for this helpful tool. I have a requirement to make replacements in links (both text and target).

I have a quick proof of concept implementation:
bdabelow@440530b

Unfortunately accessing the link text requires accessing the XML directly as far as I could figure out, so it is slightly hacky. Would this be something you would consider for inclusion? If so I would try to prepare a proper PR for it.

Activity

  1. ivanbicalho commented on Jan 28, 2023

    @ivanbicalho
    Owner

    Hey Benjamin, sorry for the late reply! I was taking a look in you code but I haven't done any tests yet. As you said, can you create a PR? This way would be better for me to evaluate it. One of the highest concerns for me is to avoid internal erros when doing the replaces. Are you completely sure that this code will never raise an index exception? Take one more look there and put it together in a PR, make sense for you?

    inner_run = link.xpath("w:r", namespaces=link.nsmap)[0]

    Thank you for your contributions on this library! :)

  2. bdabelow commented on Jan 31, 2023

    @bdabelow
    Author

    Sure, will look into creating a PR with more polish as time permits.

    My code currently is only a proof of concept that was good enough to do what I needed right then. ;-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions