Closed ghost closed 6 years ago
This is expected behavior; this kind of configuration of tex2jax will be ignored as the input is passed without delimiters anyway.
You control inline vs block of TeX input via the format
key in the options
object you pass to typeset
, https://github.com/mathjax/MathJax-node#typesetoptions-callback (TeX vs inline-TeX).
Makes sense, however I want to pass input with delimiters ($ signs). Does MathJax parse the string for delimiters, typeset only what's inside, and return the result? Or does it just typeset everything?
I want to pass input with delimiters ($ signs).
You have to strip them yourself or use something like mathjax-node-page to do it for you.
Does MathJax parse the string for delimiters, typeset only what's inside, and return the result? Or does it just typeset everything?
On the one hand, strictly speaking, MathJax does none of this. MathJax "just" coordinates the various components, e.g., the tex2jax pre-processor (to find math in the text of a page and move it to custom script tags), the TeX input process (to convert the TeX in the script tags into the internal format), and the output process (to create HTML or SVG from the internal format and inject it in the page).
On the other hand, mathjax-node is quite different to (core) MathJax (in particular, pretty different APIs).
I see, So whatever string is passed to MathJax node, irrespective of any configuration options, is treated as math to be typeset. If I want to send a mixed string, like,
"This is an equation $x = 10$" and get back This is an equation <svg ...
I need to parse the text myself and Only pass the math portion to the API. Sound right?
I need to parse the text myself and Only pass the math portion to the API. Sound right?
Correct. You can, of course, re-use MathJax's tex2jax.js for this (the version in mathjax-node-page might be useful).
Beautiful, thanks!
I apologize, but I looked at the module you me tioned, and just to clarify, it requires a proper html string?
Simple "hello $x = 4$" won't do?
Yes. If you just have a string (not html), then a regexp should be sufficient (which you can find in tex2jax module). It depends a lot on your strings, I suppose.
My understanding is that the
math
attribute of the object passed totypeset
is expected to be of typeString
.Here is a setup I have on the server
And the appropriate
config
req.body.text
is a simple String, like, This is an equation $x=4$What I am trying to do is get a string from an input form, send to the MathJax, typeset only the math deilimited by parameters in
inlineMath
and sent back. Unfortunately, everything in the string is being typeset, so I get that Italic effect familiar to anyone who has used LaTeX and forgotten the closing$
.Any suggestions?