Inline MathJax source is not formatted correctly when split onto multiple lines

Steps to reproduce

  1. Open a note in Source mode
  2. Type some MathJax with newlines splitting the code, but no empty lines. For example,
$M_2 (\mathbb{R}) = 
\left\{ \begin{bmatrix} a&b\\c&d \end{bmatrix} 
: a,b,c,d \in \mathbb{R} \right\}$

Expected result

In reading mode, the mathjax renders inline correctly.
In source mode the mathjax is formatted correctly ($ in accent color, code in grey italic monospace).

Actual result

Inline math does render correctly in reading mode.
But, in source mode, the mathjax is formatted as normal text (\ acts as an escape character, text is white)


  • Operating system: Windows 10 Home v22H2
  • Debug info:
    Obsidian version: v1.1.9
    Installer version: v1.1.9
    Operating system: Windows 10 Home 10.0.19045
    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: 5
    Plugins enabled: 5
    1: Advanced Tables v0.18.1
    2: TikZJax v0.5.1
    3: Excalidraw v1.8.12
    4: Pandoc Plugin v0.4.1
    5: Style Settings v0.4.12

Additional information

I don’t think you’re supposed to use inline MathJax if you’re splitting lines… Why not use the following?

M_2 (\mathbb{R}) = 
\left\{ \begin{bmatrix} a&b\\c&d \end{bmatrix} 
: a,b,c,d \in \mathbb{R} \right\}

I would like the math to be inline, but want to have the source on multiple lines for readability. And Obsidian already supports this functionality by compiling the math properly but still does not format the source properly.


I found another related bug that is more concerning.
When the following source is typed


The following mismatch between source and reading mode occurs.

Whether or not obsidian should support splitting inline math source onto multiple lines, I am most concerned with the consistency between what is presented to the user in source and what is compiled.

Here’s some more unintuitive interaction/disagreement with source and reading mode MathJax.