Editor Syntax Highlight Obsidian Plugin
A plugin for Obsidian which allows syntax highlighting for code blocks in the editor.
Imports code from CodeMirror
Custom plugins are only available for Obsidian v0.9.7+.
The current API of this repo targets Obsidian v0.9.7.
This is all very expermental at the moment, so parts might not work, etc.
From within Obsidian
From Obsidian v0.9.8, you can activate this plugin within Obsidian by doing the following:
- Open Settings > Third-party plugin
- Make sure Safe mode is off
- Click Browse community plugins
- Search for "Syntax Highlight"
- Click Install
- Once installed, close the community plugins window and activate the newly installed plugin
You can follow the same procedure to update the plugin
- Download the Latest release
- Extract the
cm-editor-syntax-highlight-obsidianfolder from the zip to your vault's plugins folder:
Note: On some machines the
.obsidianfolder may be hidden. On MacOS you should be able to press
Command+Shift+Dotto show the folder in Finder.
- Reload Obsidian
- If prompted about Safe Mode, you can disable safe mode and enable the plugin. Otherwise head to Settings, third-party plugins, make sure safe mode is off and enable the plugin from there.
This project uses Typescript to provide type checking and documentation.
The repo depends on the latest plugin API in Typescript Definition format, which contains TSDoc comments describing what it does.
Note: The Obsidian API is still in early alpha and is subject to change at any time!
If you want to contribute to development and/or just customize it with your own tweaks, you can do the following:
- Clone this repo.
yarnto install dependencies
npm run buildto compile.
styles.cssto a subfolder of your plugins folder (e.g,
- Reload obsidian to see changes
Alternately, you can clone the repo directly into your plugins folder and once
dependencies are installed use
npm run dev to start compilation in watch mode.
You may have to reload obsidian (
ctrl+R) to see changes.
Huh? This is an open-source plugin I made for fun. It's completely free. However, if you absolutely have to send me money because you like it that much, feel free to throw some coins in my hat via PayPal or sponsor me via GitHub Sponsors
- Fixed elixir mode (sorry this took me so long to release, it was fixed AAAGES ago...)
dataviewjsblocks (thanks @dbarenholz)
- Added YAML syntax highlighting for
trackerblocks (thanks @KjellConnelly)
- Added elixir mode (thanks to James Dalton)
- Apply codemirror theme to latex math also
- Adjusted the dark codemirror theme to also apply to frontmatter
- Reload the editor modes on load, so syntax highlighting is shown on enable
- Delete editor modes on unload, so syntax highlighting is hidden on disable
Copy-pasted and imported editor modes from CodeMirror 5.58.2. Got compiler errors importing
gfm, so those aren't available for now.