Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mathml to asciimath #8

Open
pkra opened this issue May 5, 2014 · 2 comments
Open

mathml to asciimath #8

pkra opened this issue May 5, 2014 · 2 comments

Comments

@pkra
Copy link
Contributor

pkra commented May 5, 2014

Another note. https://github.com/learningobjectsinc/mathml-to-asciimath follows an interesting idea -- converting (a subset of) MathML back to asciimath notation.

It reminds me of HTML to markdown converters (which work surprisingly well) and could prove very useful.

@Yaffle
Copy link

Yaffle commented Aug 29, 2015

Hi, I am using this conversion when user copies the seletion to the clipboard or starts dragging (by handling copy and dragstart events with js, and using event.dataTransfer.setData(...)):

text-selection

without js code web browsers will put "12πi" into clipboard (text/plain), and I want to have "12/(2*pi)".
Do you know about any other solutions for this issue?
If somebody is interested I can share my selection serialization code.

P.S.
Seems, https://github.com/learningobjectsinc/mathml-to-asciimath ignores operator precedence...

@pkra
Copy link
Contributor Author

pkra commented Aug 29, 2015

Your image seems to show a selection from an equation rendered on mathjax.org so this probably belongs on the MathJax issue tracker. In any case, this won't work for several reasons.

First, MathJax output does not consist of MathML markup (except for the NativeMML output) but renders MathML (which is used internally) into HTML/CSS (or SVG but you won't get selection with SVG content in browsers so I'm assuming you are using the HTML/CSS output).

That's why the user selection is selecting HTML fragments (lots of spans basically) and as plain text this will yield a bunch of Unicode characters.

To get what you want, you would first have to get the underlying MathML, then figure out which subexpression the user selection corresponds to. That's technically not impossible (since the output has a lot of structure relating to the underlying MathML and you could do more) but there's nothing built into MathJax to do so.

After that you would tackle the topic of this issues -- convert that subexpression to asciimath.

Seems, https://github.com/learningobjectsinc/mathml-to-asciimath ignores operator precedence...

Thanks. You might want to file a bug on the repo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants