The LaTeX commands need to be seperated by whitespaces or linebreaks. But after the $ evironment delimiter they are not allowed. The function: - adds a whitespace at the end of every chunk except after chunks beginning or ending with $ - adds no whitespace at the end of chunks followed by a chunk onyl containing $
A cleaner approach would use objects that come along with the space to insert but that would mean reprogramming everything.
A textcode object with whitespace added where needed.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.