simplemde-markdown-editor icon indicating copy to clipboard operation
simplemde-markdown-editor copied to clipboard

Please don't format text within $$ $$ delimiters which are used for math

Open irfanullahjan opened this issue 7 years ago • 2 comments

I use $$ as delimiters for math equations which are then processed by MathJax. But the underscores in LaTex confuse the editor to italicize parts of the equations. Please add a configuration to exclude the text within given delimiters from the rendering engine. Also any underscores within html tags should be ignored. Thanks

irfanullahjan avatar Jan 04 '18 03:01 irfanullahjan

So .... what's your solution, It seems that they don't care? I'm using markdown-it and markdown-it-katex for render math equations, but it's not working

luongs3 avatar Mar 05 '19 03:03 luongs3

It's almost one year later. Since I haven't found any workaround so far, I made myself one. I hope it will help who are still looking for a solution.

Wrap your math scripts with triple ticks and math right after first triple ticks. For example:

```math
$$
h_v^0 = x_v 
$$
``(one more tick)

Now after converting these to markdown: Use the following jQuery script to for replacing pre and code blocks with only p tag. For example, in my case I did the following-

var content = SimpleMDE.prototype.markdown($('#content').text());
$('#content').text('');
$('#content').html(content);

$("pre > code.lang-math" ).each(function( index ) {
    $(this).parent().replaceWith("<p>"+this.innerText+"</p>")
});

If you have code highlighting JS, please put that after this. It works flawless.

sayef avatar Apr 10 '20 06:04 sayef