Re: [docbook] LaTeX math inside docbook, on-the-fly MathML conversion?
On 29.1.2015 20:46, Marco Giebel wrote: Can this be done? Or do I have to parse my documents, find all latexmath elements, process their contents with LatexML and write the MathML output back into the document? Sure, you can invoke some conversion library like SmuggleTeX directly from XSLT code to do on-the-fly conversion. -- -- Jirka Kosek e-mail: ji...@kosek.cz http://xmlguru.cz -- Professional XML and Web consulting and training services DocBook/DITA customization, custom XSLT/XSL-FO document processing -- OASIS DocBook TC member, W3C Invited Expert, ISO JTC1/SC34 rep. -- Bringing you XML Prague conferencehttp://xmlprague.cz -- signature.asc Description: OpenPGP digital signature
Re: Aw: Re: Re: [docbook] LaTeX math inside docbook, on-the-fly MathML conversion?
Hi, On 01/29/2015 10:14 PM, Marco Giebel wrote: Because typing complicated math with MathML is too time-consuming, I want to include math as LaTeX formulas. This LaTeX needs to be converted to MathML, before I can apply my processing tools. My xslt knowledge is a bit lacking especially with external tools. Maybe it is possible to call external converter tools on special tags. I have built docbook-website translator in python. http://source.tree.se/treecutter/ the step Expand xinclude parse text method could work in this case as a preprocessor, but without using the xlinclude tag, but something like : equation role=latexaltCOMPLEX LATEX EQUATION/alt/equation You would have to write a small python program that does something like the routine prepare in https://source.tree.se/git/treecutter.git/blob/HEAD:/treecutter/page.py Where I find xinclude : code = self._doc.xpath(u//xi:include[@parse='text'],namespaces=const.XPATH) you would have to find u//equation[@role='latex'] Then take the text inside the alt tag as input for a Subprocess: exe in your case an external tool : xml = subprocess.Popen(exe,stdout=subprocess.PIPE, stderr=subprocess.PIPE) How you move the latex text to the tool of choise you have to think about. Either write a temp file with the content and supply that file in the exe command, or maybe stdin is possible. In my case I have just limited size of input. Then let the tool do the transform to stdout As for Latex to MathML I saw 4 tools here : http://www.w3.org/Math/wiki/Tools I can not make any recommendations regarding tools as I have not used math in docbook much. You can also use an external script as I use. You can see example of xinclude scripts here : https://source.tree.se/git/treecutter.git/tree/HEAD:/xinclude Ex. address.py. Given an address it generates an map and builds xml to present it. There you see how much control you have over generating/validating the mathml. Once the tool is done you take the stdout result, parse it and insert it in the tree again : xstr = etree.fromstring(stdout) # inserting the generated code and remove the xinclude reference idp = c.getparent() idp.insert(idp.index(c)+1,xstr) idp.remove(c) In your case not removing equation but the alt tag or keeping it inserting the mml: tree under equation. It can be that you need to add proper namespacing for python lxml. Now you just have to write the tree to disk, and continue to use your toolchain. vi/emacs docbook.latex.xml python convert.py docbook.latex.xml docbook.mathml.xml ./process docbook.mathml.xml This is the most flexible way to preprocess docbook I have found so far. Python have many libraries that you can use to treat special data. I process images, encrypt data, select data to include using python, but keeping the pure but somewhat expanded docbook at the end. If this method would suit you and if you need more information let me know. Sincerely, Fredrik Unger - To unsubscribe, e-mail: docbook-unsubscr...@lists.oasis-open.org For additional commands, e-mail: docbook-h...@lists.oasis-open.org
Re: Aw: Re: Re: [docbook] LaTeX math inside docbook, on-the-fly MathML conversion?
Because typing complicated math with MathML is too time-consuming, I want to include math as LaTeX formulas. This LaTeX needs to be converted to MathML, before I can apply my processing tools. This is the most flexible way to preprocess docbook I have found so far. Python have many libraries that you can use to treat special data. I created a small preprocessing tool and submitted it to docbook-apps https://lists.oasis-open.org/archives/docbook-apps/201501/msg00036.html I hope this solves your problem. Sincerely, Fredrik Unger - To unsubscribe, e-mail: docbook-unsubscr...@lists.oasis-open.org For additional commands, e-mail: docbook-h...@lists.oasis-open.org
Re: [docbook] LaTeX math inside docbook, on-the-fly MathML conversion?
On 29/01/15 03:25 PM, Warren Young wrote: On Jan 29, 2015, at 12:46 PM, Marco Giebel marco-gie...@gmx.de wrote: These formulas should be interpreted on the fly to MathML Are you sure you want to prevent the correct viewing of your document in stock versions of Chrome, IE, and Opera? http://caniuse.com/#search=mathml Yes, I know there are browser plugins and hacks like MathJax that can fix this, but…ech. If you’re also targeting PDF, most XSL-FO processors don’t support MathML, either. Last time I checked, only Antenna House did. I have been using FOP with the jeuclid plugin for a number of years and have been (mostly) satisfied with its support for MathML. FWIW, Stefan -- ...ich hab' noch einen Koffer in Berlin... - To unsubscribe, e-mail: docbook-unsubscr...@lists.oasis-open.org For additional commands, e-mail: docbook-h...@lists.oasis-open.org
Aw: Re: Re: [docbook] LaTeX math inside docbook, on-the-fly MathML conversion?
Please read my initial question. I write my documents using docbook. Because typing complicated math with MathML is too time-consuming, I want to include math as LaTeX formulas. This LaTeX needs to be converted to MathML, before I can apply my processing tools. Gesendet:Donnerstag, 29. Januar 2015 um 22:08 Uhr Von:maxwell maxw...@umiacs.umd.edu An:Marco Giebel marco-gie...@gmx.de Cc:docbook@lists.oasis-open.org Betreff:Re: Aw: Re: [docbook] LaTeX math inside docbook, on-the-fly MathML conversion? On 2015-01-29 16:02, Marco Giebel wrote: And what does dblatex have to do with converting latex to MathML? As you write it converts docbook to latex which is something like the opposite. If youre already using LaTeX, why would you need to convert it to MathML? - To unsubscribe, e-mail: docbook-unsubscr...@lists.oasis-open.org For additional commands, e-mail: docbook-h...@lists.oasis-open.org - To unsubscribe, e-mail: docbook-unsubscr...@lists.oasis-open.org For additional commands, e-mail: docbook-h...@lists.oasis-open.org
Re: [docbook] LaTeX math inside docbook, on-the-fly MathML conversion?
On 01/29/2015 12:25 PM, Warren Young wrote: On Jan 29, 2015, at 12:46 PM, Marco Giebel marco-gie...@gmx.de wrote: These formulas should be interpreted on the fly to MathML Are you sure you want to prevent the correct viewing of your document in stock versions of Chrome, IE, and Opera? http://caniuse.com/#search=mathml Yes, I know there are browser plugins and hacks like MathJax that can fix this, but…ech. If you’re also targeting PDF, most XSL-FO processors don’t support MathML, either. Last time I checked, only Antenna House did. I see that they have included it in the commercial version, but it’s still a paid add-on for the Lite version: http://www.antennahouse.com/product/mathml.htm I found this quite useful for PDF output: http://pmml2svg.sourceforge.net/ This XSL stylesheet converts MathML to SVG. SVG can be then inserted into the XSL-FO for PDF output or converted to PNG for HTML. If you want to use inline formulas, you'd need a small hack to pass the baseline shift generated by pMML2SVG (which is stored in the generated SVG) into the XSL-FO attribute. I have a patch for that somewhere; I'll dig it up if you're interested. Regards, Alexey. When I created the f/Calc manual, I built a bit of Makefile hackery to turn LaTeX fragments into PNG for the HTML version and PDF for insertion into the PDF version by the XSL-FO processor: http://fcalc.net/manual/ http://fcalc.net/manual.pdf I think the result is fairly seamless, and it works on all browsers, going back to ancient days. If you want, I can dig up the recipe. It’s simple enough to be quickly reinvented. I’d post it now, but I don’t have the code on hand where I am now. - To unsubscribe, e-mail: docbook-unsubscr...@lists.oasis-open.org For additional commands, e-mail: docbook-h...@lists.oasis-open.org - To unsubscribe, e-mail: docbook-unsubscr...@lists.oasis-open.org For additional commands, e-mail: docbook-h...@lists.oasis-open.org
Aw: Re: [docbook] LaTeX math inside docbook, on-the-fly MathML conversion?
I read about mathphrase. However, this element is only for a linear sequence of symbols. Not for sums, integrals, matrices or multiline equations. Gesendet:Donnerstag, 29. Januar 2015 um 21:29 Uhr Von:Thomas Schraitle tom_s...@web.de An:docbook@lists.oasis-open.org Betreff:Re: [docbook] LaTeX math inside docbook, on-the-fly MathML conversion? Hello Marco, Am Donnerstag, 29. Januar 2015, 20:46:30 schrieb Marco Giebel: [...] My idea is to include some latexmath element in a document like para latexmathsum_{n=1}^infty frac 1 n/latexmath is divergent. /para There is no latexmath element in DocBook. However, you can have the same functionality with equation (for block formulas) or inlineequation (inside a paragraph). For example, an inline equation of Einsteins famous formula could look like: inlineequation mathphrase role=latexE = mc^2/mathphrase /inlineequation This element should be translated to MathML during processing - either as a preprocessing step or using xslt commands if possible. Can this be done? Or do I have to parse my documents, find all latexmath elements, process their contents with LatexML and write the MathML output back into the document? Sure. In theorey, it needs a three step process: extract all LaTeX formulas, convert it to MathML (or maybe graphics?), and reinsert it -- or include a reference. How many formulas do you have? Do they change frequently? Well, maybe you dont need such a sophisticated convertion. Perhaps you could reference your MathML formulas with xi:include and do the convertion outside your workflow. Get some ideas by reading Bobs chapter about Math in DocBook at http://www.sagehill.net/docbookxsl/Math.html Hope this helps. :) -- Gru/Regards Thomas Schraitle - To unsubscribe, e-mail: docbook-unsubscr...@lists.oasis-open.org For additional commands, e-mail: docbook-h...@lists.oasis-open.org - To unsubscribe, e-mail: docbook-unsubscr...@lists.oasis-open.org For additional commands, e-mail: docbook-h...@lists.oasis-open.org
Aw: Re: [docbook] LaTeX math inside docbook, on-the-fly MathML conversion?
And what does dblatex have to do with converting latex to MathML? As you write it converts docbook to latex which is something like the opposite. Gesendet:Donnerstag, 29. Januar 2015 um 21:55 Uhr Von:maxwell maxw...@umiacs.umd.edu An:Marco Giebel marco-gie...@gmx.de Cc:docbook@lists.oasis-open.org Betreff:Re: [docbook] LaTeX math inside docbook, on-the-fly MathML conversion? On 2015-01-29 14:46, Marco Giebel wrote: I am looking for a possibility to include LaTeX formulas inside a docbook document. There is an open source piece of software called dblatex (NOT db2latex, which is much older). It converts DocBook XML to LaTeX (or XeLaTeX). We use it, but I dont know whether you can get it to pass LaTeX text verbatim--maybe you can if you use an xslt processing-instruction. (If you simply embed LaTeX commands as text, they get escaped, so they wont be processed.) Theres a sourceforge site for dblatex here: http://dblatex.sourceforge.net/ However, it doesnt seem to be up to date, as I know theyre up to version 0.3.5. Theres a download site for the newer version here: https://pypi.python.org/pypi/dblatex Actually, the latest is also available from sourceforge, here: http://sourceforge.net/projects/dblatex/ I think the discrepancy between the above link and this one has to do with migrating from git to mercurial. The developer is Benoit Guillon, and he can be reached through the dblatex mailing list: http://sourceforge.net/p/dblatex/mailman/dblatex-devel/ (with link to subscribe) He might be able to better answer the question about how to embed LaTeX code to be executed. Mike Maxwell University of Maryland - To unsubscribe, e-mail: docbook-unsubscr...@lists.oasis-open.org For additional commands, e-mail: docbook-h...@lists.oasis-open.org - To unsubscribe, e-mail: docbook-unsubscr...@lists.oasis-open.org For additional commands, e-mail: docbook-h...@lists.oasis-open.org
Re: [docbook] LaTeX math inside docbook, on-the-fly MathML conversion?
On Jan 29, 2015, at 2:20 PM, Stefan Seefeld ste...@seefeld.name wrote: On 29/01/15 03:25 PM, Warren Young wrote: ...most XSL-FO processors don’t support MathML, either. Last time I checked, only Antenna House did. I have been using FOP with the jeuclid plugin for a number of years and have been (mostly) satisfied with its support for MathML. Is the prerequisites section at the top of the following page correct in indicating that the plugin doesn’t support either FOP 1.0 or 1.1? http://jeuclid.sourceforge.net/jeuclid-fop/ - To unsubscribe, e-mail: docbook-unsubscr...@lists.oasis-open.org For additional commands, e-mail: docbook-h...@lists.oasis-open.org
Aw: Re: [docbook] LaTeX math inside docbook, on-the-fly MathML conversion?
Yes, I dont care if the MathML cannot be displayed in all browsers. My question is, how I can convert included LaTeX to MathML, not whether everybody thinks that this is useful. Gesendet:Donnerstag, 29. Januar 2015 um 21:25 Uhr Von:Warren Young w...@etr-usa.com An:docbook@lists.oasis-open.org Betreff:Re: [docbook] LaTeX math inside docbook, on-the-fly MathML conversion? On Jan 29, 2015, at 12:46 PM, Marco Giebel marco-gie...@gmx.de wrote: These formulas should be interpreted on the fly to MathML Are you sure you want to prevent the correct viewing of your document in stock versions of Chrome, IE, and Opera? http://caniuse.com/#search=mathml Yes, I know there are browser plugins and hacks like MathJax that can fix this, butech. If youre also targeting PDF, most XSL-FO processors dont support MathML, either. Last time I checked, only Antenna House did. I see that they have included it in the commercial version, but its still a paid add-on for the Lite version: http://www.antennahouse.com/product/mathml.htm When I created the f/Calc manual, I built a bit of Makefile hackery to turn LaTeX fragments into PNG for the HTML version and PDF for insertion into the PDF version by the XSL-FO processor: http://fcalc.net/manual/ http://fcalc.net/manual.pdf I think the result is fairly seamless, and it works on all browsers, going back to ancient days. If you want, I can dig up the recipe. Its simple enough to be quickly reinvented. Id post it now, but I dont have the code on hand where I am now. - To unsubscribe, e-mail: docbook-unsubscr...@lists.oasis-open.org For additional commands, e-mail: docbook-h...@lists.oasis-open.org - To unsubscribe, e-mail: docbook-unsubscr...@lists.oasis-open.org For additional commands, e-mail: docbook-h...@lists.oasis-open.org
Re: Aw: Re: [docbook] LaTeX math inside docbook, on-the-fly MathML conversion?
On 2015-01-29 16:02, Marco Giebel wrote: And what does dblatex have to do with converting latex to MathML? As you write it converts docbook to latex which is something like the opposite. If you're already using LaTeX, why would you need to convert it to MathML? - To unsubscribe, e-mail: docbook-unsubscr...@lists.oasis-open.org For additional commands, e-mail: docbook-h...@lists.oasis-open.org
Re: [docbook] LaTeX math inside docbook, on-the-fly MathML conversion?
On 2015-01-29 14:46, Marco Giebel wrote: I am looking for a possibility to include LaTeX formulas inside a docbook document. There is an open source piece of software called dblatex (NOT db2latex, which is much older). It converts DocBook XML to LaTeX (or XeLaTeX). We use it, but I don't know whether you can get it to pass LaTeX text verbatim--maybe you can if you use an xslt processing-instruction. (If you simply embed LaTeX commands as text, they get escaped, so they won't be processed.) There's a sourceforge site for dblatex here: http://dblatex.sourceforge.net/ However, it doesn't seem to be up to date, as I know they're up to version 0.3.5. There's a download site for the newer version here: https://pypi.python.org/pypi/dblatex Actually, the latest is also available from sourceforge, here: http://sourceforge.net/projects/dblatex/ I think the discrepancy between the above link and this one has to do with migrating from git to mercurial. The developer is Benoit Guillon, and he can be reached through the dblatex mailing list: http://sourceforge.net/p/dblatex/mailman/dblatex-devel/ (with link to subscribe) He might be able to better answer the question about how to embed LaTeX code to be executed. Mike Maxwell University of Maryland - To unsubscribe, e-mail: docbook-unsubscr...@lists.oasis-open.org For additional commands, e-mail: docbook-h...@lists.oasis-open.org
Re: [docbook] LaTeX math inside docbook, on-the-fly MathML conversion?
On 29/01/15 05:10 PM, Warren Young wrote: On Jan 29, 2015, at 2:20 PM, Stefan Seefeld ste...@seefeld.name wrote: On 29/01/15 03:25 PM, Warren Young wrote: ...most XSL-FO processors don’t support MathML, either. Last time I checked, only Antenna House did. I have been using FOP with the jeuclid plugin for a number of years and have been (mostly) satisfied with its support for MathML. Is the prerequisites section at the top of the following page correct in indicating that the plugin doesn’t support either FOP 1.0 or 1.1? http://jeuclid.sourceforge.net/jeuclid-fop/ I'm not sure why that page indicates that. While at some point I did have some difficulties to use jeuclid with FOP 1.0 an 1.1, I eventually got it working. However, I never used the version directly from sourceforge, but rather the one that is distributed by debian. Perhaps support for newer FOP versions was added there and never merged upstream ? I'm not sure... Still, I have been using FOP 1.1 for quite a while now with jeuclid, and never run into major issues. (I'm a very happy XMLMind user, by the way, including and especially with its MathML editing support. I understand the OP's desire to type math in latex, though. That may be faster for someone already familiar with LaTeX. FWIW.) Stefan -- ...ich hab' noch einen Koffer in Berlin... - To unsubscribe, e-mail: docbook-unsubscr...@lists.oasis-open.org For additional commands, e-mail: docbook-h...@lists.oasis-open.org
Re: [docbook] LaTeX math inside docbook, on-the-fly MathML conversion?
Alexey Neyman sti...@att.net wrote on Thu, 29 Jan 2015 12:34:05 -0800: I found this quite useful for PDF output: http://pmml2svg.sourceforge.net/ This XSL stylesheet converts MathML to SVG. SVG can be then inserted into the XSL-FO for PDF output or converted to PNG for HTML. I'm the person behind pmml2svg. I think its output is clearly superior to JEuclid in most cases, mostly because JEclid literally handles stretchy characters by anisotropic scaling of glyphs. Yet I sadly do not eat my own dog food most of the time. The reason is that pmml2svg relies on FOP code handle font metrics, and FOP is currently limited to Unicode plane-0 code points (https://issues.apache.org/jira/browse/FOP-1969), but I often use Mathematical Alphanumeric Symbols (1D400–1D7FF). Since my use case for pmml2svg relies on FOP for PDF output, I have had little motivation to remove pmml2svg's dependency on FOP. Moreover, while I think MathML-to-SVG conversion coded entirely in XSLT is cool and fits well into XML workflows, math rendering is not trivial, and MathML keeps evolving, so implementation and maintenance cannot be done without community help. Perhaps it would be better to try to write a MathML-to-SVG converter and/or a FOP math plugin based on an established math rendering system such as Gecko or MathJax. If you want to use inline formulas, you'd need a small hack to pass the baseline shift generated by pMML2SVG (which is stored in the generated SVG) into the XSL-FO attribute. I have a patch for that somewhere; I'll dig it up if you're interested. I am :-) For LaTeX-to-MathML conversion I use TTM (http://hutchinson.belmont.ma.us/tth/mml/). In the meantime many other converters have appeared (that I have never felt the pressure to try out). Justus - To unsubscribe, e-mail: docbook-unsubscr...@lists.oasis-open.org For additional commands, e-mail: docbook-h...@lists.oasis-open.org