Syntax highlighting for LaTeX math is disabled due to selector specificity error

Steps to reproduce

  1. Open a vault and open a document
  2. Use the default theme (or most other themes as this bug effects all but two themes as far as I could find)
  3. Enter the following content;

or any other latex math.
5. Ensure you are in edit mode (reading/preview will hide the underlying syntax)
4. Ctrl+Shift+I > select element > any of the latex symbols
5. Scroll down the CSS rules until you see the following (source app.css:5707);

cm-s-obsidian .cm-inline-code, .cm-s-obsidian .cm-math {
    color: var(--code-normal);
  1. Disable the checkbox next to color
  2. Observe syntax highlighting suddenly be implemented

Expected result

This should be default behavior, it should not be hidden behind disabling a core CSS rule.

Actual result

The CSS rule mentioned acts as a permanent disable for latex syntax highlighting.


  • Operating system: Linux (PopOS, Ubuntu)
  • Debug info:
	Obsidian version: v1.1.9
	Installer version: v1.1.9
	Operating system: #202212290932~1673966427~22.04~e15d5b5 SMP PREEMPT_DYNAMIC Tue J 6.0.12-76060006-generic
	Login status: not logged in
	Insider build toggle: off
	Live preview: on
	Legacy editor: off
	Base theme: dark
	Community theme: none
	Snippets enabled: 0
	Restricted mode: off
	Plugins installed: 2
	Plugins enabled: 2
		1: Style Settings v0.4.12
		2: Sortable v0.3.0

	Community plugins: for bugs, please first try updating all your plugins to latest. If still not fixed, please try to make the issue happen in the Sandbox Vault or disable community plugins.

Additional information

The selector in question is the latter, .cm-s-obsidian .cm-math. The issue is a selector specificity issue, as the syntax highlighting is applied directly via selectors like .cm-tag which has 0,1,0 specificity, whereas this rule has 0,2,0 specificity.
This issue can be fixed with the following diff;

// app.css:5707
-cm-s-obsidian .cm-inline-code, .cm-s-obsidian .cm-math {
+cm-s-obsidian .cm-inline-code, .cm-math {
    color: var(--code-normal);

See Also

[[Latex syntax highlighting in v1.0?]]

[[LaTex Syntax-Highlighting not woking anymore]]


Manual Fix

Manually fixed by using a Hex editor to set the bytes of .cm-s-obsidian into 0x20 (space character) in /usr/lib/obsidian/obsidian.asar (Linux). If anyone wants to try this fix, Make a backup of the original file before editing.

(It’s an .asar file and I have no experience with it before. So I hex-edited it to be safe.)

OS and Environment

Arch Linux 5.15.87-1-lts
Obsidian 1.1.9-3

I have the same issue.


will be fixed 1.1.14

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.