mathjax commas in digits

﹥>﹥吖頭↗ 提交于 2019-12-11 09:14:18

问题


This is a TeX legacy issue---it would have made more sense to require a whitespace when a whitespace is desired: 12,123 is probably a number, while 12, 123 is probably a list. Alas, it is what it is.

Related to MathJax rendering of commas in numbers, where the solution is suppression of spaces via {,}. Works, but inconvenient. Is there a way to make this automatic?

The hack in https://github.com/mathjax/MathJax/issues/169#issuecomment-2040235 is concerned with European vs Anglo. The equivalent hack,

<script type="text/x-mathjax-config">
  MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
    MathJax.InputJax.TeX.Definitions.number =
      /^(?:[0-9]+(?:\,[0-9]{3})*(?:\{\.\}[0-9]*)*|\{\.\}[0-9]+)/
  });
</script>

solves the comma problem in 1,234.56 but now there is a space after the period (i.e., before 5). I am not sure how the regex above works. can someone help?


回答1:


Change the pattern to

/^(?:[0-9]+(?:,[0-9]{3})*(?:\.[0-9]*)*|\.[0-9]+)/

to allow 12,345.6 to be treated as a number, while 12, 345 is a list of two numbers. In the original pattern, the \{\.\} requires a literal {.} (braces included), not just a decimal.



来源:https://stackoverflow.com/questions/45173530/mathjax-commas-in-digits

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!