You could allow MathJax to process <pre>
tags by removing them from the skipTags
array in the text2jax
block of your configuration. See the documentation for more details.
Post a text which will be handled by MathJax
سؤال
I have a problem posting text in a html form. The text (from a textarea) to be posted to a new page to show may have the following properties:
- including latex code to be handled by MathJax between two dollar sign
- needs to preserve the line break
- may including html code such as a input tag
I have tried the following methods:
replace "\r\n" sub-strings to html "br" tag and then post the text to innerHTML of a div or span to keep line breaks. But then I need remove the html part in the text beforehand, otherwise, if the text include a "input" tag, I will then have a input box in the resulted page!
What's more, if I remove html tags, then I will accidently remove the sub string like a < b, b > c, (if '<' and 'b', 'b' and '>' are adjacent, seems StackOverFlow can't deal with it, too!)
- using a pre tag to keep line breaks, then MathJax doesn't work!
So, can anyone save me for this problem? Thanks in advance! By the way, I use ruby on rails on my project.
المحلول
نصائح أخرى
At last, I use skipTags as Mr Cervone mentioned above and put the text into the pre tag. To convert(and preserve) the HTML tag into plaintext format, I use a method provided by ruby called CGI.escapeHTML.