-
Notifications
You must be signed in to change notification settings - Fork 43
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
[Question] Utility API for replacing latex expressions with generated content? #38
Comments
I wrote a quick one. I can contribute this / rewrite in Typescript if need be:
|
I'm glad you were able to work out your needed functions. MathJax doesn't currently have such a function. Currently, it only has function for handling an actual HTML DOM tree. The MathJax design does allow for other document types (we envisioned, for example, handling a Markdown document). The mechanism for this would be MathJax's A Markdown handler would have similar calls, their actions would be different. For example, your functions above would replace the DOM-based An alternative would be to have the Markdown handler be a subclass of the HTML handler, that starts with the document as a Markdown string, has the find-math function locate the math in the Markdown, and either remove it or isolate is to that Markdown won't modify the math; then have a renderAction that processes the markdown into HTML, and then use the rest of the HTML render actions on that DOM. In any case, that is the vision for how to do the kind of thing you are suggesting. |
That's exactly what I'm doing :). For example I may have a document like this:
And I'll read that in and split off the markdown so I end up with it in a variable like Then I run that string through the function, which replaces the latex with SVG, per your brilliant suggestion (Thanks again ... I'm just so happy about it). If you think this would help others with the same markdown scenarios I'll gladly contribute back the package utility I ( We ) built. |
This is the entire utility:
The package depends on:
|
I have that as a separate package locally. That way I can just |
Just a note ... One idea that could have also made this work is to use a Web Component / Custom Element to render the math. The reason I needed either this or that is because the content is selected dynamically. This is the app for browsing content: http://forecasting-help.fireflysemantics.com/ So since Angular renders the content inside the component, MathJax's web script does not get access to it, as with static web pages. So I still think prerendering for this is best, but a Custom Element / Web Component could have worked as well. The fs-link-preview custom element is an example of this approach: https://www.npmjs.com/package/@fireflysemantics/fs-link-preview It's built using lit element. |
Hi,
Per this question we obtain an array of
ProtoItem
instances.I take the latex in each instance and generate the corresponding SVG. So I end up with another array of SVG, where each SVG rendering matches the corresponding
MathItem
instance.I was wondering if MathJax has an API for merging the generated results into the original source string?
The text was updated successfully, but these errors were encountered: