lierdakil / pandoc-crossref

Pandoc filter for cross-references
https://lierdakil.github.io/pandoc-crossref/
GNU General Public License v2.0
936 stars 74 forks source link

Bug in DOCX: can not create hyperlink to figures correctly #374

Closed Astro-Aionia closed 3 weeks ago

Astro-Aionia commented 1 year ago

Hi, I found hyperlinks to figures actually located to word bookmarks with the same name as fig ids defined in markdown files. But in fact, these bookmarks were not exist in the output DOCX document, so when I used the hyperlinks with Ctrl+L Click, they always linked to the start of the document.

I have referred #147 and tried the lua script liedakil provided, but it didn't work. I'm wondering if there are some way ti fix the hyperlink for the latest pandoc-crossref.

lierdakil commented 1 year ago

Hi. Thanks for the report! Could you specify versions of pandoc-crossref and pandoc you're using, just to make sure we're on the same page?

I vaguely suspect this might be the same issue all over again, since Pandoc drastically changed how it represents figures in v3.0.

Astro-Aionia commented 1 year ago

I am using Pandoc 3.0 and pandoc-crossref 0.3.15.0. Sorry for forgetting to illustrate before.

lierdakil commented 1 year ago

Okay, so I've taken a quick look, and it seems Pandoc does create bookmarks for divs, spans, code blocks, tables and plain images but indeed not figures. I should be able to whip up a PR over the weekend.

As a stopgap measure, this lua filter should work (it just wraps all figures in divs with the same identifier):

function Figure(el)
  return pandoc.Div(el, pandoc.Attr(el.identifier))
end

P.S. as was the case the last time, filter order is important, you'll want to run this lua filter after pandoc-crossref.

Astro-Aionia commented 1 year ago

Thanks for your reply. I have just tried this script. It works well for me.

FeralFlora commented 4 months ago

@lierdakil The issue was just fixed upstream. Not released yet, though.

lierdakil commented 4 months ago

Thanks for the update. I guess I'll need to remember to close this when updating to the next pandoc release... which all things considered is somewhat improbable, but I'll try :sweat_smile:

FeralFlora commented 4 months ago

I'll try to post a reminder at that time ;)

lierdakil commented 3 weeks ago

Presumably was fixed in pandoc v3.2.1, so a couple releases ago.