用户输入后如何获取 MathQuill 数据?
How to grab the MathQuill data once user types it in?
我正在尝试建立一个可以解析数学文本的聊天,我认为 MathQuill 负责视觉效果,但我需要在用户提交后解析他们输入的内容。
我正在使用 MathQuill 编辑器:
<p><span id="mathTextBox" class="mathquill-editor">\sqrt[3]{8}=\frac{\sqrt{16}}{2}</span></p>
此处显示:
http://jenseng.github.io/mathquill/demo.html
我想抓取 "\sqrt[3]{8}=\frac{\sqrt{16}}{2}" 进行解析。我试过了
document.getElementById("mathTextBox").innerText
但它包含工具栏文本,所以我得到:
"+基本
π希腊语
⊕运营商
≤关系
⇔箭头
{分隔符
∞杂项
∧
∨
∪
∩
◇
△
⊖
⊎
⊗
⊕
▽
⊓
⊲
⊔
⊳
⊙
◯
†
‡
≀
∠
3√8=
√16
2
此外,我不想处理符号(即√),所以我希望它是文本格式(即\sqrt)。文本在 sqrt(16) 之后也缺少除号。
非常感谢任何想法!谢谢!
他们在 mathquill 聊天中告诉我 (http://webchat.freenode.net/?channels=mathquill) 是:
$(document.getElementById("mathTextBox")).mathquill('latex')
我正在尝试建立一个可以解析数学文本的聊天,我认为 MathQuill 负责视觉效果,但我需要在用户提交后解析他们输入的内容。
我正在使用 MathQuill 编辑器:
<p><span id="mathTextBox" class="mathquill-editor">\sqrt[3]{8}=\frac{\sqrt{16}}{2}</span></p>
此处显示:
http://jenseng.github.io/mathquill/demo.html
我想抓取 "\sqrt[3]{8}=\frac{\sqrt{16}}{2}" 进行解析。我试过了
document.getElementById("mathTextBox").innerText
但它包含工具栏文本,所以我得到:
"+基本 π希腊语 ⊕运营商 ≤关系 ⇔箭头 {分隔符 ∞杂项 ∧ ∨ ∪ ∩ ◇ △ ⊖ ⊎ ⊗ ⊕ ▽ ⊓ ⊲ ⊔ ⊳ ⊙ ◯ † ‡ ≀ ∠ 3√8= √16 2
此外,我不想处理符号(即√),所以我希望它是文本格式(即\sqrt)。文本在 sqrt(16) 之后也缺少除号。
非常感谢任何想法!谢谢!
他们在 mathquill 聊天中告诉我 (http://webchat.freenode.net/?channels=mathquill) 是:
$(document.getElementById("mathTextBox")).mathquill('latex')