Highlight specific lines with code fences

I write a lot of blog posts with code so I love the code fences feature! ```js ...

For highlighting specific lines, I still do {{< highlight js "hl_lines=8 13" >}}

Is it possible to do the same with code fences? Or is it a planned feature? It would be very convenient.

Code fencing is a function of the markdown parser, so probably a no go. You can search the forums, there was talk of replacing BlackFriday with a new parser, and maybe it has other options. :slight_smile:

1 Like

Okay thanks. Too bad. I’m going to create snippets in my text editor then

This is implemented as a rendering hook in Hugo, so It should be possible to make up some syntax, e.g. “```js/hl_lines=8-13”. But it’s not a “planned feature”, but it would be useful.

Note that it is on the TODO list to add support for Goldmark, which may or may not make this simpler. It’s probably at least worth looking at that before implementing above so we’re not getting shot in the foot.

Could you create a GitHub issue?

1 Like

Thanks. https://github.com/gohugoio/hugo/issues/6355