Add failing test for issue #6724
Fix markdown rendering 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 gh-6724
Merge pull request #6727 from takluyver/i6724

Fix markdown to HTML conversion with inline maths