HTML in code blocks

How can I e.g. use italics to mark up placeholders in code snippets (like in the arch linux wiki)?

I am not sure. You can disable syntax highlighting and write the code block by hand. I am guessing the Arch wiki has a WYSIWYG editor that does it for them.

I don’t care about having to write <pre> and </pre>, but I’d prefer not losing syntax highlighting. Could there be a {% code() %} shortcode for example? with an optional parameter to control how the syntax highlighter behaves with HTML tags, which e.g. can be set to "ignore" or "unwrap".

Another motivation for this feature is explaining code by parts. See this section in the nix manual for an example.

It would have to hook pretty deep in syntect I think, definitely not a trivial change.

There are some additional things that would be nice to have with regards to syntax highlighting: line numbers, line highlighted (Tis a draft · Keats/vincentprouillet@c5db5e8 · GitHub) and your suggestion could be another nice thing to add to the list. I won’t have time to implement those myself though :confused:

When I read this blog post from matklad I found that using annotations with numbers (in black circle), as well as highlighting part of the code (in yellow) in its code-block was very clever. Was there any progress in this regards? If not, do you know any static site generator that supports it?

1 Like