Language name in code blocks #7882
Answered
by
kamilkrzyskow
pushbroomsweep
asked this question in
Q&A
-
Is it possible to include the language name in one corner (say the bottom-right corner) of the code blocks? |
Beta Was this translation helpful? Give feedback.
Answered by
kamilkrzyskow
Jan 10, 2025
Replies: 1 comment 1 reply
-
This is currently not available out-of-the-box. What you can do, however, is to first enable code highlighting and add a title in the code block. Here is a sample of how you can easily add a Python label to Python code blocks using CSS:
So that you can use my CSS you have to make sure to define py in the code block in my example. This is what my example looks like:
References: |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nice solution, very ingenious 🤩
The highlight extension also has the
auto_title
option, which would use the title of the lexer as the title of the code block when none is given, simpler but also worse solution, still worth noting.Since you've gone the extra mile to try it out yourself, then I'd say it's worth adding the whole
example.zip
to the answer, as this could also clear up some misunderstandings. However, there are people that won't download zips, because it's too much work, which I've re-learned recently that the code block / screenshot is king.Since the CSS is additive, I tried a quick hack in the browser tools, one could define CSS variables for the exact language match, even …