Fix markdown to HTML conversion with inline maths

The mistune 'text' regex was capturing into math expressions in some  cases. The fix was to modify it to stop at a $ sign, giving the inline math regex a chance to capture that.

Closes #6724