gohugoio / hugo

The world’s fastest framework for building websites.
https://gohugo.io
Apache License 2.0
75.4k stars 7.49k forks source link

Add .Position to the context of heading and image render hooks #11325

Open bowman2001 opened 1 year ago

bowman2001 commented 1 year ago

The codeblock render hook context includes the .Position of the current codeblock in a local Markdown file.

It would be nice to have this information also for heading and image render hooks. This would allow to include links to the source in local server mode.

bep commented 1 year ago

I agree that this would be nice to have, but it's non-trivial to implement. The implementation we have for code blocks is expensive/slow. The main challenge is the shortcodes with {{< delimiters; the position you get when parsing the Markdown (Goldmark, assuming that info is there) does not take the shortcodes into account. And if you think about the new {https://github.com/gohugoio/hugo/pull/11320 ... there's lots to think about, as Position may well point to a different Markdown file.

bowman2001 commented 1 year ago

I’ve hoped this would be relatively easy. So it can wait, it’s certainly not a priority.