While working on the bevy book, we write a lot of code blocks. We also want to validate those code blocks which means we need to add code to make it a valid block, but we don’t want to show that code to our readers.
I am aware of the hide_lines annotation, but it’s easy to forget to change it when editing the code block since it requires specifying line numbers.
I would like to suggest a different approach to do this.
In doc comments in rust it’s possible to add a
# symbol at the start of a line to hide that line. Obviously this won’t work with every language supported by zola. My suggestion would be to make this symbol configurable and also make this feature toggleable. This would make it possible for rust code block to hide lines easily without breaking other languages.
Ideally this would be a global config so we don’t need to configure it on every block, but even if it’s a special annotation it will at least mean we can just add it everywhere and not have to remember to update it.
Look for a comment that indicates a start and an end. Something like
<insert code that need to be hidden> // ZOLA_BEGIN_CODE_BLOCK <insert code that needs to be visible> // ZOLA_END_CODE_BLOCK
and use those tags to hide the lines that are not between these.
If there’s an interest for that feature, I would be interested in implementing that feature, but I have no idea where to start and would need a bit of guidance. (@mockersf is the one that implemented the original hide_lines annotation and would also be willing to implement this if it gets approved.)