Is it possible to customize code block with language title?

Hi all!

I just started using Zola today after being a bit frustrated with Hugo. I’m wondering if we could somehow customize the code block further, like giving it a title according to the language that is inside the pre tag? Like in the following image:

code_block_title

In Hugo, I could retrive a data-lang attribute but it doesn’t seem to be available in the syntax highlighting mechanism for Zola.

Would appreciate some help :slight_smile: Thanks!

Not yet. I think it would have to be done in the theme.

I’m actually writing my own theme. Does this have to do with the “syntax engine” of Zola being different from Hugo’s?

There will be a class with the language name in the next version (https://github.com/getzola/zola/pull/1189/commits/6ef81940b89cf52c9c5f9074adaa88d57f2b00d0) but adding something like data-lang makes sense as well. I’ll add that now.

Edit: https://github.com/getzola/zola/pull/1189/commits/b9b4ef9f04c704dd94d41fad051ec3957a880c9c

0.13 should be released soonish, just waiting for a few dependencies to publish new versions on crates.io

2 Likes

Merci Vincent! And thanks for commenting on my Rust subreddit post :slight_smile:

Isn’t the class unnecessary now?

The class is for CSS styling (even though you can do it with data as well). It is a bit redundant but I think there’s no harm in having both.

1 Like