简体   繁体   English

如何在jqMath的格式化表达式中保留空格

[英]How to keep spaces in the formatted expression in jqMath

I am using jqMath for Math equation formatter. 我正在将jqMath用于数学方程式格式化程序。 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. 我已经尝试了很多,但找不到任何解决方案。

from the author ... 来自作者...

In general, it's best to let html handle the text, and jqMath handle the math. 通常,最好让html处理文本,让jqMath处理数学。 For example, write " using $y = (x+1)/(x+2)$", or "<td>$x+y = 2$<td>(1)" inside an html table. 例如,在html表中编写“ using $ y =(x + 1)/(x + 2)$”或“ <td> $ x + y = 2 $ <td>(1)”。

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. 如果用户输入“ using y = x”,则不希望将“ using”解析为5个变量u,s,i,n和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. 同样,如果他输入了您想保留在数学之外的多余空间,则必须使用正则表达式或其他内容捕获它们,而不必将其传递给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. 如果您希望空格成为数学的一部分,则可以使用户输入\\ table或\\ sp或\\ text或其他内容,尽管大多数用户都不知道这样做。 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. 基本上,jqMath不够聪明,无法告诉您什么是数学,什么不是,没有$ $的帮助。

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. 大概0.2.0将在几个月后发布,或者至少我有一个可以在那时发送给您的版本。

Update : New version is out which support /text and /html 更新:支持/ text和/ html的新版本已经发布

Using \\text and "" is used to give space inside the formula 使用\\ text和“”可以在公式中提供空格

HTML source : [\\text"average speed" = \\text"distance traveled" / \\text"elapsed time"] HTML源: [\\ text“平均速度” = \\ text“行进的距离” / \\ text“经过的时间”]

Result : 结果 在此处输入图片说明

this example is available in http://mathscribe.com/author/jqmath.html 该示例可在http://mathscribe.com/author/jqmath.html中找到

Update: If you stumble on this, jqmath has added \\, \\: and \\; 更新:如果您迷失了方向,jqmath添加了\\, \\:\\; ;。 operaters that specify thin, mid, and thicker white spacing. 指定较薄,中等和较粗的白色间距的操作员。

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 空格,制表符和换行符将被忽略-jqMath格式化数学

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM