mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-24 20:40:11 +01:00
Setting "type" to bright red to make comparison obvious: (screenshots taken from VSCode) Before <img width="446" height="150" alt="Screenshot 2026-07-20 135558" src="https://github.com/user-attachments/assets/81249005-99f1-47bb-af4f-ad6e8f2404fb" /> After <img width="429" height="149" alt="Screenshot 2026-07-20 135738" src="https://github.com/user-attachments/assets/acc83086-fe19-4a18-a833-968daed56229" /> I'm not super familiar with textmate/highlightjs, but I think what was happening on line 5 is that the "type" scope is being extended to the `=` after `.y`. Adding `,` as an "end" token fixes this, and I think this is what highlightjs already does. I've also added "unused" as a keyword.
Highlighting utilities
This directory collects syntax highlighting utilities for use with Carbon code.
highlight.js
This JavaScript syntax highlighting system is used on webpages or in presentation software like reveal.js.
The code is in highlightjs_carbon_lang.js, and you can use it by registering it after you load highlight.js:
<script type="module">
import Carbon from './highlightjs_carbon_lang.js';
hljs.registerLanguage('Carbon', Carbon);
hljs.highlightAll();
</script>
See highlightjs_example.html for a more complete example.
It includes many Carbon-specific markup indicators that may be useful to customize display or highlighting of Carbon code.