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

Hyperlink imports as strong tag instead of anchor tag #201

Open
winhamwr opened this issue Jan 19, 2016 · 1 comment
Open

Hyperlink imports as strong tag instead of anchor tag #201

winhamwr opened this issue Jan 19, 2016 · 1 comment
Labels

Comments

@winhamwr
Copy link
Contributor

I'm unsure of the exact cause, but attached .docx has a hyperlink around the text http://translate.google.com/#, but when run through pydocx, the resulting HTML is just surrounded in strong tags instead of an anchor tag.

Interestingly, if I open the file in Open Office and save it again, the internal structure changes and running the resulting file through pydocx results in correct behavior.
hyperlink_did_not_translate.docx

@winhamwr winhamwr added the bug label Jan 19, 2016
@kylegibson
Copy link
Contributor

Ugh. This is because the instrText is spread out over several nodes. I made the assumption that this would not happen, because it's silly:

      <w:r>
        <w:instrText xml:space="preserve"> HYPERLINK "</w:instrText>
      </w:r>
      <w:r w:rsidRPr="00710528">
        <w:instrText>http://translate.google.com/#</w:instrText>
      </w:r>
      <w:r>
        <w:instrText xml:space="preserve">" </w:instrText>
      </w:r>

PyDocX only handles the instrText HYPERLINK if it is formatted like this:

      <w:r>
        <w:instrText xml:space="preserve"> HYPERLINK "http://translate.google.com/#"</w:instrText>
      </w:r>

I suspect it's happening because of the # in the URL. Maybe word sees this as a special character.

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

No branches or pull requests

2 participants