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

Docx reader: bookmark in header not working when last parPart was a bookmark #9626

Closed
mbrackeantidot opened this issue Apr 3, 2024 · 3 comments
Labels

Comments

@mbrackeantidot
Copy link
Contributor

Explain the problem.
When transforming this document: bookmark_simplified.docx with pandoc using pandoc bookmark_simplified.docx, the link at the start of the file is not correctly transformed.

Expected ouptut:

<p><a href="#referenced-title">A link to the bookmark</a></p>
<p><strong>Accomplices:</strong></p>
<p>There are bookmarks around here.</p>
<h1 id="referenced-title">Referenced title</h1>
<p>Content</p>

Actual output:

<p><a href="#_APPENDIX_5:_FINANCIAL">A link to the bookmark</a></p>
<p><strong>Accomplices:</strong></p>
<p>There are bookmarks around here.</p>
<h1 id="referenced-title">Referenced title</h1>
<p>Content</p>

I found out that this is because the last paragraph part before the header is a bookmark. In this case, parPartToInlines' doesn't create a span for the bookmark because there is a bookmark immediately before the header (represented by docxImmedPrevAnchor) and doesn't add the bookmark to the anchor map docxAnchorMap because it's in a header, which is handled by makeHeaderAnchor'. But makeHeaderAnchor' assumes that a span with an anchor was added by parPartToInlines'.

To verify my understanding of the problem, I implemented a fix and tested it manually. If you're curious, the code can be found here: 09fc204

I would like to create a proper commit containing that fix and make a pull request. Do I have your blessing?

Pandoc version?
Latest development version, compiled from source on macOS. Older versions on Linux and macOS had the same bug.

@jgm
Copy link
Owner

jgm commented Apr 3, 2024

I would like to create a proper commit containing that fix and make a pull request. Do I have your blessing?

Go for it!

@mbrackeantidot
Copy link
Contributor Author

Thanks!

mbrackeantidot added a commit to mbrackeantidot/pandoc that referenced this issue Apr 4, 2024
When the last parPart before a header was a bookmark, no span with an
anchor was added for a bookmark in the header. But the function that
adds header anchors to the anchor map, needs a span with an anchor.
So this commit adds that span.
mbrackeantidot added a commit to mbrackeantidot/pandoc that referenced this issue Apr 4, 2024
When the last parPart before a header was a bookmark, no span with an
anchor was added for a bookmark in the header. But the function that
adds header anchors to the anchor map, needs a span with an anchor.
So this commit adds that span.
jgm pushed a commit that referenced this issue Apr 18, 2024
When the last parPart before a header was a bookmark, no span with an
anchor was added for a bookmark in the header. But the function that
adds header anchors to the anchor map, needs a span with an anchor.
So this commit adds that span.
@tarleb
Copy link
Collaborator

tarleb commented Apr 18, 2024

I believe that the merged PR #9626 fixed this.

@tarleb tarleb closed this as completed Apr 18, 2024
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

3 participants