Dong Yang317 downloadsAdditional and configurable syntax highlighting for code block languages.
Extended Code Highlight adds broader, theme-compatible syntax highlighting for Obsidian code blocks in Reading view, Source mode, and Live Preview.
It supports all bundled PrismJS languages, bundled CodeMirror parser languages, and optional regex languages loaded from JSON files.
.token.* and .cm-* theme classes.Use the normal language name after a fenced code block, such as js, ts, python, json, css, html, glsl, svelte, vue, zig, nix, or wasm.
The plugin supports:
You can check the upstream language lists here:
Embedded fallback languages currently cover MLIR and Lean. Other bundled languages use PrismJS and/or CodeMirror support.
Highlighting priority depends on the Obsidian view:
.token.* spans, then regex fallback..cm-* classes, then regex fallback.If a language is not built in, add a JSON file for it.
```glsl
uniform sampler2D tex;
void main() {
vec4 color = texture2D(tex, vec2(0.5));
}
```
```svelte
<script lang="ts">
export let name = "world";
</script>
{#if name}
<h1>Hello {name}</h1>
{/if}
```
Create one JSON file per language in the plugin's languages folder:
<your-vault>/.obsidian/plugins/extended-code-highlight/languages/
Example:
{
"id": "mydsl",
"aliases": ["my-dsl"],
"tokens": [
{ "name": "comment", "pattern": ";.*", "flags": "m" },
{ "name": "keyword", "pattern": "\\b(foo|bar|baz)\\b" },
{ "name": "number", "pattern": "\\b\\d+(?:\\.\\d+)?\\b" },
{ "name": "string", "pattern": "\"(?:\\\\.|[^\"\\\\])*\"" }
]
}
Supported token names include comment, keyword, string, number, builtin, variable, function, property, and operator.
After editing a language JSON file, run the Reload extended highlight languages command or disable and re-enable the plugin.
The plugin uses Obsidian-compatible token classes so your current theme can style highlighted code.
Reading view uses Prism-style classes:
<span class="token keyword">...</span>
Editor views use CodeMirror-style classes:
cm-hmd-codeblock cm-keyword
Copy these files into your plugin folder:
<your-vault>/.obsidian/plugins/extended-code-highlight/
Required files:
manifest.json
main.js
Obsidian's community plugin installer only downloads main.js, manifest.json, and styles.css when present. Built-in language fallbacks are embedded into main.js; create custom JSON language files manually only if you need local additions.
Then enable Extended Code Highlight in Obsidian's Community plugins settings.