+1 I would recommend using KaTeX for this. Another thing would be to embed CodeMirror within ProseMirror (https://prosemirror.net/examples/codemirror/) instead of just using monospace font. The additional benefit of that is free syntax-highlighting.
I've played with ProseMirror and math support before, so this is what it about looks like.
[1] https://imgur.com/a/rV2AATD
bhl|6 years ago
I've played with ProseMirror and math support before, so this is what it about looks like. [1] https://imgur.com/a/rV2AATD