javascripthtmlmathquill

How to grab the MathQuill data once user types it in?


I am trying to set up a chat that can parse math text, and I think MathQuill does the visuals, but I need to parse what the user types in once they submit it.

I am using the MathQuill editor:

<p><span id="mathTextBox" class="mathquill-editor">\sqrt[3]{8}=\frac{\sqrt{16}}{2}</span></p>

shown here:

http://jenseng.github.io/mathquill/demo.html

And I want to grab "\sqrt[3]{8}=\frac{\sqrt{16}}{2}" to parse. I tried

document.getElementById("mathTextBox").innerText

but it includes the toolbar text so I get:

"+Basic πGreek ⊕Operators ≤Relationships ⇔Arrows {Delimiters ∞Misc ∧ ∨ ∪ ∩ ◇ △ ⊖ ⊎ ⊗ ⊕ ▽ ⊓ ⊲ ⊔ ⊳ ⊙ ◯ † ‡ ≀ ∐ 3√8= √16 2 "

Also, I would rather not deal with symbols (ie √) so I want it in the text format (ie \sqrt). The text is also missing a division sign after the sqrt(16).

Any ideas are greatly appreciated! Thanks!


Solution

  • They told me in mathquill chat (http://webchat.freenode.net/?channels=mathquill) it is:

    $(document.getElementById("mathTextBox")).mathquill('latex')