There’s a plugin for Obsidian to highlight code in the notes depending on which programming language is used - “Editor Syntax Highlight”.
https://github.com/deathau/cm-editor-syntax-highlight-obsidian
But I can’t get it working with hcl
(Terraform code).
As it turned out, repository is not maintained, and there were no new commits for almost 2 years.
Created my own fork and added hcl
highlighting myself.
The code was already implemented way back in 2018 for CodeMirror (https://github.com/codemirror/codemirror5/pull/5347/files, found the link to it in https://github.com/deathau/cm-editor-syntax-highlight-obsidian/issues/44), and I simply ported it: https://github.com/deathau/cm-editor-syntax-highlight-obsidian/commit/03ce5a38fd610cd5ffa637c7189f686a446d33e9
After that, I ran pnpm build
in my fork, copied main.js
, main.css
, and updated manifest.json
to ~/Documents/Obsidian Vault/.obsidian/plugins/
(can be found through Settings > Community Plugins > folder icon).
And now it somewhat works, and it’s much prettier than bland code or using the wrong language code for highlighting:
I think it can be improved, mb I’ll revisit it later.