Syntax highlighting for fenced code blocks #185
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/creating-and-highlighting-code-blocks#syntax-highlighting
Is it possible to preserve the language for fenced code blocks so the show notes would have syntax highlighting
This is a nice feature, however it is implemented (or was last time I looked) by lots of
<span>and<div>tags. When the show arrives on the Internet Archive (IA) these are all stripped out.In short, I disabled this feature because at the time the IA stripped all but the most basic HTML. I'd be happy to review it; the IA code is changed silently over time, so this might no longer be the case.
There are 2 ways that I know how to show syntax highlighting.
JavaScript reads the code block and wraps tokens in SPANS with classes, or wraps them in
<b>, <em>, <i>, <strong>etc, which have special styles because they are in a classed<pre>block.The newish way is to use the custom highlighting API. So instead of splitting into tokens the JavaScript just need to know the character positions to set Ranges of text that get a highlight name that then is associated to a style. See https://developer.mozilla.org/en-US/docs/Web/API/CSS_Custom_Highlight_API