gohugoio / hugo

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

Combine anchorlinenos and hl_lines for dynamic highlighting #8503

Open edbighead opened 3 years ago

edbighead commented 3 years ago

It is possible to highlight some lines in Highlight Shortcode using hl_lines parameter and anchorlinenos can be used to reference some specific lines of code.

While having a documentation website with code examples, it would be handy to reference some lines of code and have a highlight on them, like it's done on Github

jmooring commented 3 years ago

I think this needs to happen first: https://github.com/alecthomas/chroma/issues/373.

Additionally, it would be easier to identify ranges of line numbers in the URL fragment if a hyphen was not appended to the string specified in lineanchors. If you have two code blocks on a page, and you set lineanchors for each block as A and B respectively, the fragment to specify lines 2-4 would look like #B-2-4 or #B-2-B-4. In GitHub it looks like #L4-L7 which is simpler to parse.