-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
(html) Input field in mathjax rendered equation ? #2210
Comments
Here is a quick and dirty example of a configuration that provides an input field in CommonHTML output (there is a bug in the SVG support for Of course, you would probably want to create a custom TeX extension rather than doing this in-line, as in this example, but this allows you to try it out without compiling or webpacking anything. The things referring to Anyway, perhaps that can get you started.
|
@dpvc Thanks for your answer. I didn't get the time to test it yet. |
There is an issue with using this server-side, which is that MathJax needs to be able to measure the HTML in order to tell how big it is, and that is done by asking the browser to measure the bounding box for the HTML. That works in the browser, but not on the server (the LiteDOM doesn't do any actual layout). The intended solution is to have you provide explicit size information in the On the other hand, the computation of the size of the |
Improve support for annotation-xml mathjax/MathJax#2210
@dpvc const xml = parser.create('node', 'XML');
xml.setXML(MathJax.startup.adaptor.node('input', {xmlns: 'http://www.w3.org/1999/xhtml'}));
parser.Push(
parser.create('node', 'TeXAtom', [
parser.create('node', 'semantics', [
parser.create('node', 'annotation-xml', [
xml
], {encoding: 'application/xhtml+xml'})
])
], {texClass: TEXCLASS.ORD})
); Unfortunetly I ve got "Cannot read property 'outerHTML' of null" when use xml node inside this parser. Could you provide me any tips how to resolve it? |
The update mentioned in the code turned out to require an additional parameter to the xml.setXML(MathJax.startup.adaptor.node('input', {xmlns: 'http://www.w3.org/1999/xhtml'})); to xml.setXML(MathJax.startup.adaptor.node('input', {xmlns: 'http://www.w3.org/1999/xhtml'}), MathJax.startup.adaptor); It turns out that the issue was arising because of the assistive MathML extension, which need to serialize the internal MathML in order to create the hidden MathML in the page for assistive technology to use. That also serializes the contents of the xml.setXML(MathJax.startup.adaptor.node('input', {xmlns: 'http://www.w3.org/1999/xhtml'}), MathJax.startup.adaptor);
xml.getSerializedXML = function () {return this.adaptor.outerHTML(this.xml) + '</input>'}; This is a hack to get the closing tag in this case, but a more general solution is needed to handle arbitrary annotation-xml content. That will be for a future update. |
Could you update the docs with an exact example and walkthrough? |
I'm currently trying to convert a piece of code (that I didn't write) from mathjax 2.7 tot mathjax 3.
At https://github.com/XimeraProject/server/blob/master/public/javascripts/main.js#L317 you will find code that (maybe in a hacky way?) makes it possible to add an
\answer
command which places an input field at that location.For example:
\frac {4}{(m+1)!}-\frac {1}{m!}=\frac {\answer {3-m}}{(m+1)!}
givesIt uses a lot of mathjax 2 specific things it seems, so I can't find how to port this to mathjax 3. I tried reading the mathjax 3 api documentation, but the documentation doesn't seem to be done yet.
My question actually is: 'Is it possible to easily let a custom tex command add an html input tag inside mathjax ? Or is it somehow possible to add an input field ?'
The text was updated successfully, but these errors were encountered: