Convert Mathjax ouptut in a readable format for jqmath - latex

On a project, I use ck editor with mathjax plugin in order to insert some formulas.
In a another part of this project, I would like to use jqmath. Cause it's faster and more integrated in wkhtmltopdf (I use those formulas in some docs produced by wkhtmltopdf, and some issues exist with mathjax, especialy over bar).
My problem: syntax is different between mathjax and jqmath. Of course, jqmath doesn't care about my formulas syntaxed under mathjax...
So my question is: does it exist a way to convert maths strings from mathjax to jqmath syntax?
Cheers

Both MathJax and jqmath use MathML internally and both understand it as an input format (jqmath added MathML input support a while back, see the copy-me.html in the distribution). So you can generate MathML from MathJax and feed that into jqmath.

Related

how can I parse json-ld to markdown

Is there an existing parser to parse json-ld to markdown? I want to generate documentation from my jsonld file. If such a thing doesn't exist, how should I go ahead writing one? or perhaps I could use a json to markdown converter? Any suggestions on how could do this?
I was just googling for such a program, and found your question.
The closest things I could find are: ocxmd, which is an extension to Markdown; and md-ld, which does not even use proper Markdown - instead, it apparently creates an incompatible version of the format which can be parsed to JSON-LD.
If I were writing such a converter in Python, I would use:
pyld to parse JSON-LD files and expand them using the #context;
And a template engine, likely Jinja2, to generate Markdown representation of every node of the JSON-LD document.
The program would be based on recursion. You might have separate functions to display:
URIs,
Numbers,
Images,
...
The program will recurse over the JSON-LD document and convert each of its sections into Markdown format.

Generating LaTeX Server Side

I'm trying to build a service that accepts some string with LaTeX formatting and then returns a string with the LaTeX bits as pngs, or whatever else.
So, the idea is:
client sends a request containing: the point is that $sum_{n=1}^5 f(x)$ is a good estimate
server sends back the string: the point is that FORMULAS_HERE is a good estimate
I really have no idea where to begin getting the LaTeX converted. Naively, I assume I would just parse out the LaTeX bits and then do something to get a png/jpeg/etc... and then insert that into the response.
Googling around really reveals minimal information.
Currently, my simple server is built on node, but that's not really important. I can change languages if there's some magic solution out there. I honestly wish I could magically transform LaTeX into unicode and have it be perfectly seamless.
Question: How do I handle LaTeX on the server side?
- The goal is to then spit it back to the client so the text can be inlined relatively naturally (i.e. I could text my buddy Hey, what if $\chi(n)$ was considered independently? and it would be received formatted on the other end without begin a weird big picture blob).
Any advice on just a direction or set of packages/technologies/etc.. would be useful here.
Prepare your latex document with math and convert it using the excellent open-source ImageMagick
pdflatex formula.tex
convert -density 300 formula.pdf -quality 90 formula.png
The convert command used above is one of the ImageMagick tools. See documentation and numerous online resources for many options. The software has versions for all major platforms.
The input latex file should be prepared so that there is no background, margins, etc. For discussion of how to do that, see this post, and the source for it. The example above ultimately comes from there.
This is one way to write the formula.tex file used above, from the linked source.
\ifdefined\formula
\else
\def\formula{E = m c^2}
\fi
\documentclass[border=2pt]{standalone}
\usepackage{amsmath}
\usepackage{varwidth}
\begin{document}
\begin{varwidth}{\linewidth}
\[ \formula \]
\end{varwidth}
\end{document}
There are other converters out there but you need not bother if you can use this.
I have to mention MathJax. It runs in a browser, via one-line JavaScript snippet. Should you ever migrate to a browser/mobile service this would be a perfect solution. Here is their one page tutorial.

Tools for converting LaTeX equations to Content MathML or OpenMath?

Do you know any open source tools or libraries (preferably Java, but that's not a strict requirement) in the GNU/Linux world that convert mathematical equations in LaTeX syntax to Content MathML or OpenMath?
I need to convert tons of equations in batch mode, so I'm not looking for interactive apps.
EDIT My focus is on the equations' semantics, so I cannot use Presentation MathML (unless there's a converter from Presentation MathML to Content MathML).
Thanks in advance!
This might be what you are looking for: SnuggleTeX
From the site:
SnuggleTeX is a 100% Java library for converting (a reasonable subset of) LaTeX into XHTML + MathML.
SnuggleTeX can attempt to convert input LaTeX to Content MathML by first creating Enhanced Presentation MathML and then processing that. In many ways, this part of the process is relatively simple since most of the semantic structure has already been inferred (though might not necessarily make any sense).
You can also use an online equation editor WIRIS editor which is able to import MathML/Latex and export to MathML/Latex
Have a look over here, where you can find a perl version.
You may want to have a look at LaTeXML. It converts LaTeX to various XML formats, including OpenMath and content MathML.
But be warned, like all other tools, the conversion from (presentation-oriented) LaTeX to content markup (as in OpenMath and MathML) is heuristic. In particular, in ambiguous situations (e.g. $f(a+b)$, which can mean $f$ applied to $(a+b)$ or $f$ times $(a+b)$) LaTeXML chooses one (usually times).
There are two ways out:
1) use content markup already in the LaTeX source (see http://trac.kwarc.info/sTeX)
2) use a better post-processor for LaTeXML is working on this

Ruby on Rails: In there a way to convert word to html?

maybe a way to batch convert also?
You could use Google Docs API to upload and convert .doc's.
http://code.google.com/apis/documents/overview.html
Some samples and code: http://code.google.com/apis/documents/code.html
Ruby example and demo:
http://code.google.com/p/gdata-samples/source/browse/#svn/trunk/doclist/DocListManager
http://doclistmanager.googlecodesamples.com/
The short answer is no, but the long answer is sorta.
MS Word itself will save a file out as html - but it's a total friggin' mess. To an extent this is simply because the customer base that is converting word files to html directly are not concerned about it being sloppy, so Word hasn't worked hard on making a clean output. On the other hand, it's intrinsically difficult, because word is oriented to create fixed size, non-dynamic documents, like a paper-base book. So it's easy to convert to other static formats (say a PDF), but how do you convert to HTML? Do you just make the text flow across? Do you set a width that will hopefully make the layout stay the same? What if there is fonts or layout elements in the word doc that are not available in the HTML renderer?
The easiest thing to do is to do it project by project - you can create a DTD to convert an RTF file, for instance - but this involves you making programmer level decisions about how these will be converted.

Lighweight markup (wiki) language for documenting

When I write papers or documentation it makes think using LaTeX or OpenOffice is overkill as I usually only need some markup elements (bold, headlines, lists, ...) . I'd like to write my documents using a wiki style markup as this is very efficient.
For example:
= Introduction =
'''HTML''' is a markup language...
In the end I'd like to simply convert it to PDF. (Cross-platform was nice too.)
compiler.exe -pdf input.wiki output.pdf
Is there a tool (or simple tool chain) to do this job?
I'd personally like to not make use of LaTeX as a transformation step. There are tools doing this job transforming lightweight syntax to TeX and then to PDF/PS.
You might find that MarkDown gets pretty close to what you want.
MarkDown is a simple technique for marking up text files so that they can be post-processed into other forms. One of the nice things about MarkDown is their goal that a marked-up document should be simply readable as a straight text file:
The overriding design goal for
Markdown’s formatting syntax is to
make it as readable as possible. The
idea is that a Markdown-formatted
document should be publishable as-is,
as plain text, without looking like
it’s been marked up with tags or
formatting instructions.
PanDoc looks like it might be good companian tool to convert the MarkDown straight into PDF files. There may well be other choices - PanDoc is just the best tool I found with a quick Google search.
reStructuredText.
You can use Sphinx to generate HTML and LaTeX (and later PDF with pdflatex).
There is also rst2pdf, don't know if it's mature.
You could use Markdown (example) and then use Pandoc (which also works with reStructuredText and several other wiki-like syntaxes) to convert to PDF.

Resources