gomarkdown / markdown

markdown parser and HTML renderer for Go
Other
1.36k stars 171 forks source link

No way to escape `$` MathJax blocks #282

Closed alexwennerberg closed 8 months ago

alexwennerberg commented 1 year ago

It appears $ is not part of escapeChars here: https://github.com/gomarkdown/markdown/blob/c84983bdbf2a36039ec74759e1fbcddc667d801d/parser/inline.go#L739

This means there appears to be no way to escape $ blocks that I don't want to turn into math blocks with backslashes, unless there is some other way to escape $ that I'm not aware of, For example:

Sally wanted to charge $12 for apples, but Bob thought $10 was a fairer price

Thanks!

dawidl022 commented 8 months ago

Would the fix be as simple as adding the $ character to the escapeChars slice? Or would that conflict with something else?

I tried making the change and running the tests, which passed fine, but the test coverage is not very high, from what I can see.

miekg commented 8 months ago

[ Quoting @.***> in "Re: [gomarkdown/markdown] No way to..." ]

Would the fix be as simple as adding the $ character to the escapeChars slice? Or would that conflict with something else?

I tried making the change and running the tests, which passed fine, but the test coverage is not very high, from what I can see.

the mmark test-suite also passes with '$' added to escapeChars, so sounds good to me.

/Miek

-- Miek Gieben