How to keep spaces in the formatted expression in

2019-08-07 09:56发布

I am using jqMath for Math equation formatter. I don't want to remove spaces and newline character from the expression. How can I do that? I have tried a lot but I coudn't find any solution.

4条回答
爷、活的狠高调
2楼-- · 2019-08-07 10:38

It doesn't look like it can be done. To quote the page you provided:

spaces, tabs and newlines are ignored - jqMath formats the mathematics

查看更多
甜甜的少女心
3楼-- · 2019-08-07 10:50

from the author ...

In general, it's best to let html handle the text, and jqMath handle the math. For example, write " using $y = (x+1)/(x+2)$", or "<td>$x+y = 2$<td>(1)" inside an html table.

You have to be able to separate user input into mathematics and non-mathematics. If a user inputs "using y=x" you don't want "using" parsed as the product of 5 variables u, s, i, n, and g. Similarly, if he inputs extra spaces that you want to keep outside the mathematics, you have to capture them using regular expressions or something, and don't pass them to jqMath. If you want the spaces to be part of the mathematics, you could make the user input \table or \sp or \text or something, though most users won't know to do that. You could tell users that they need to put $ $ around their mathematics if they want it to format, and then you could search for that.

Basically, jqMath isn't smart enough to tell what's math and what isn't, without $ $ to help.

Probably 0.2.0 will be out in a couple months, or at least I'll have a version I could send you by then.

Update : New version is out which support /text and /html

查看更多
Anthone
4楼-- · 2019-08-07 10:53

Update: If you stumble on this, jqmath has added \, \: and \; operaters that specify thin, mid, and thicker white spacing.

查看更多
Luminary・发光体
5楼-- · 2019-08-07 10:55

Using \text and "" is used to give space inside the formula

HTML source : [\text"average speed" = \text"distance traveled" / \text"elapsed time"]

Result : enter image description here

this example is available in http://mathscribe.com/author/jqmath.html

查看更多
登录 后发表回答