Forgot password?
 Create new account
View 172|Reply 5

[MathJax]tex2mml和unicode variant selector

[Copy link]

3151

Threads

8498

Posts

610K

Credits

Credits
66208
QQ

Show all posts

hbghlyj Posted at 2022-5-7 02:16:08 |Read mode
Last edited by hbghlyj at 2022-5-7 09:00:00MathJax.tex2mml('a+b')
输出:
"<math xmlns=\"http://www.w3.org/1998/Math/MathML\" display=\"block\">
  <mi>a</mi>
  <mo>+</mo>
  <mi>b</mi>
</math>"



MathJax.tex2mml('≥')
输出:
"<math xmlns=\"http://www.w3.org/1998/Math/MathML\" display=\"block\">
  <mo>≥</mo>
</math>"



MathJax.tex2mml('⩾︎')
输出:
"<math xmlns=\"http://www.w3.org/1998/Math/MathML\" display=\"block\">
  <mo>⩾</mo>
  <mrow data-mjx-texclass=\"ORD\">
    <mo>︎</mo>
  </mrow>
</math>"

3151

Threads

8498

Posts

610K

Credits

Credits
66208
QQ

Show all posts

 Author| hbghlyj Posted at 2022-5-7 02:16:44
我这里无法上传附件了

附件上传完成!成功 0 个,失败 1 个:
1 (2).jpg: 非法操作

3151

Threads

8498

Posts

610K

Credits

Credits
66208
QQ

Show all posts

 Author| hbghlyj Posted at 2022-5-7 05:20:13
编辑帖子怎么没有删除的选项了?

原来.....不是MathJax的问题.......原来是我输入了不可见字符(unicode variant selector,用来区分一个字符的不同写法的),然后MathJax把这个不可见字符也当作常规字符处理了........把它放到了一个mo里面......在Latin Modern Math字体里显示为1个字宽的空白.....

以下各类字符都有standardized variation sequences :
CJK(用来区分异体字,使得同一个字的不同写法不占用多余的码点)
数学字母数字符号(Mathematical Alphanumeric Symbols)
数学运算符(Mathematical Operators)
...

这里有一个数学运算符和当它添加了variant selector后对比的表格:en.wikipedia.org/wiki/Mathematical_Operators_ … #Variation_sequences
但是我看不到有什么区别...可能是浏览器不完全支持这些Unicode标准吧

另外,一个emoji显示为彩色还是黑白轮廓也与这些variant selector有关呢!

3151

Threads

8498

Posts

610K

Credits

Credits
66208
QQ

Show all posts

 Author| hbghlyj Posted at 2022-5-7 05:30:12
$\mathbf{n} · \mathbf{e}_{3} ⩾︎ 0$
$\mathbf{n} · \mathbf{e}_{3} ⩾ 0$
  1. $\mathbf{n} · \mathbf{e}_{3} ⩾︎ 0$
  2. $\mathbf{n} · \mathbf{e}_{3} ⩾ 0$
Copy the Code
对比一下:
第一行的⩾后面有一个不可见的variant selector,第二行⩾后面没有variant selector.

在JS控制台测试一下字符串是否相同
  1. '$\mathbf{n} · \mathbf{e}_{3} ⩾︎ 0$'=='$\mathbf{n} · \mathbf{e}_{3} ⩾ 0$'
Copy the Code
输出:
false
  1. strlen('$\mathbf{n} · \mathbf{e}_{3} ⩾︎ 0$')-strlen('$\mathbf{n} · \mathbf{e}_{3} ⩾ 0$')
Copy the Code

输出:
1

3151

Threads

8498

Posts

610K

Credits

Credits
66208
QQ

Show all posts

 Author| hbghlyj Posted at 2022-5-7 05:48:19
MySQL将Discuz的帖子的内容中的selector替换掉:
  1. UPDATE forum_post SET message=REPLACE(message,'⩾︎','⩾');
Copy the Code

3151

Threads

8498

Posts

610K

Credits

Credits
66208
QQ

Show all posts

 Author| hbghlyj Posted at 2022-5-7 05:53:50
回复 3# hbghlyj
我当时应该是从网上复制的,把不可见字符也复制上了,擦擦
下次需要谨慎一些,用strlen检查一下

手机版Mobile version|Leisure Math Forum

2025-4-21 14:18 GMT+8

Powered by Discuz!

× Quick Reply To Top Return to the list