From: Paul Tremblay <paulhtremblay@gm...>  20120219 20:22:37
Attachments:
screen_shot1.png
screen_shot2.png

Hi group, I've written a library that converts ASCII Math to Mathml: https://sourceforge.net/projects/asciimathpython/ I've included two screenshots from the project page. It would take only 10 or 15 lines of code to actually use this library. One would only have to include a visit for the math_block and math elements in the writers/docutils_xml.py, and likewise include a few in the HTML writer. As it stands now, I use a separate script to read in the docutils tree to convert the ASCII math to MathML before converting the document to FO, and then to PDF. Paul 
From: Guenter Milde <milde@us...>  20120227 11:18:55

On 20120219, Paul Tremblay wrote: > I've written a library that converts ASCII Math to Mathml: > https://sourceforge.net/projects/asciimathpython/ Good news. How is this related to ASCIIMathML_? .. _ASCIIMathML: http://pypi.python.org/pypi/asciimathml/ > It would take only 10 or 15 lines of code to actually use this library. > One would only have to include a visit for the math_block and math > elements in the writers/docutils_xml.py, and likewise include a few in > the HTML writer. How would the math input format be recognized? It seems like the whole math handling needs to be restructured to be more open to new formats. See the May 2008 thread for an discussion: (http://osdir.com/ml/text.docutils.devel/200805/threads.html) Thanks for keeping this up, Günter 
From: Paul Tremblay <paulhtremblay@gm...>  20120228 01:20:28

On 2/27/12 6:18 AM, Guenter Milde wrote: > On 20120219, Paul Tremblay wrote: > >> I've written a library that converts ASCII Math to Mathml: >> https://sourceforge.net/projects/asciimathpython/ > Good news. > > How is this related to ASCIIMathML_? > > .. _ASCIIMathML: http://pypi.python.org/pypi/asciimathml/ > > >> It would take only 10 or 15 lines of code to actually use this library. >> One would only have to include a visit for the math_block and math >> elements in the writers/docutils_xml.py, and likewise include a few in >> the HTML writer. > How would the math input format be recognized? > > My asciitomathml is much more complete than the ASCIIMathML in your link. I originally started working on the ASCIIMathML project, but found the code inscrutable and not easily changed. My own library is complete, and handles all cases of ASCII math. I imagine it handles nearly all types of math markup. A lot has changed since the thread in 2008. Firefox can handle MathML without any special plugins; it simply works. Likewise, FOP, the Java converter that converts FO to PDF, handles MathML without any fuss. You download an extra jar, put it in a directory, and then the MathML gets converted to PDF. In order for the math input to be recognized, the rst2xml.py script could simply accept two options. Other scripts could likewise accept these options: mathinput ascii mathoutput mathml The default for both, without any option, would be latex. Paul 
From: Guenter Milde <milde@us...>  20120228 13:05:06

On 20120228, Paul Tremblay wrote: > On 2/27/12 6:18 AM, Guenter Milde wrote: >> On 20120219, Paul Tremblay wrote: >>> I've written a library that converts ASCII Math to Mathml: >>> https://sourceforge.net/projects/asciimathpython/ >> Good news. >> How is this related to ASCIIMathML_? >> .. _ASCIIMathML: http://pypi.python.org/pypi/asciimathml/ > My asciitomathml is much more complete than the ASCIIMathML in your > link. I originally started working on the ASCIIMathML project, but found > the code inscrutable and not easily changed. My own library is complete, > and handles all cases of ASCII math. I imagine it handles nearly all > types of math markup. I see. This makes it a good candidate for Docutils indeed and it makes me want more (: ASCIIMathML.js (http://www1.chapman.edu/~jipsen/mathml/asciimath.html) accepts standard LaTeX notation as an alternative. Do you think your library could be used as basis for an improved LaTeX > MathML translator for Docutils? Also, an ASCIIMath > LaTeX converter would be very desirable for adoption of ASCIIMath as rst math input format. There is a JavaScript script at http://dlippman.imathas.com/asciimathtex/ASCIIMath2TeX.js How difficult would it be to write a Pythonbased ASCIImath  LaTeX math converter? ... > In order for the math input to be recognized, the rst2xml.py script > could simply accept two options. Other scripts could likewise accept > these options: > mathinput ascii IMV, the input format should rather be given in the document. Otherwise documents may render invalid/untranslatable. I envisage a directive option and derived roles like: .. math:: :input: asciimath .. role:: asciimath(math) :input: asciimath > mathoutput mathml This could be easily done by making the setting of the HTML writer a generic one. We could use list of accepted output formats in order of preference (idea by David) with defaults like:: [html4css1 writer] mathoutput: mathjax, mathml, html, literal [html4strict writer] mathoutput: mathml, mathjax, html, literal [latex2e writer] mathoutput: latex, literal which could be overridden in a config file or the command line like rst2html mathoutput=html,mathml,literal Thanks Günter 
From: Paul Tremblay <paulhtremblay@gm...>  20120228 18:24:58
Attachments:
Message as HTML

Hi Guenter, If you think a directive option would work better than an option, then I would go with the directive option. I suppose one could mix different types of math in a document. I am not that well versed in latex to know exactly how to convert it. Converting latex to mathml might not require a complete reworking of my code. For example, ASCIImath uses text(apple) Whereas latex uses \text(apple) If latex is indeed that close to ASCIImath, it doesn't seem to make sense to use latex, since ASCIImath math doesn't need the back slashes. Converting latex to mathml sounds like I would need to write a whole new library. Like I said, I don't know the syntax of latex. Paul On Tue, Feb 28, 2012 at 8:04 AM, Guenter Milde <milde@...> wrote: > On 20120228, Paul Tremblay wrote: > > On 2/27/12 6:18 AM, Guenter Milde wrote: > >> On 20120219, Paul Tremblay wrote: > > >>> I've written a library that converts ASCII Math to Mathml: > >>> https://sourceforge.net/projects/asciimathpython/ > >> Good news. > > >> How is this related to ASCIIMathML_? > > >> .. _ASCIIMathML: http://pypi.python.org/pypi/asciimathml/ > > > My asciitomathml is much more complete than the ASCIIMathML in your > > link. I originally started working on the ASCIIMathML project, but found > > the code inscrutable and not easily changed. My own library is complete, > > and handles all cases of ASCII math. I imagine it handles nearly all > > types of math markup. > > I see. This makes it a good candidate for Docutils indeed and it makes me > want more (: > > ASCIIMathML.js (http://www1.chapman.edu/~jipsen/mathml/asciimath.html) > accepts standard LaTeX notation as an alternative. Do you think your > library could be used as basis for an improved LaTeX > MathML translator > for Docutils? > > Also, an ASCIIMath > LaTeX converter would be very desirable for > adoption of ASCIIMath as rst math input format. There is a JavaScript > script at http://dlippman.imathas.com/asciimathtex/ASCIIMath2TeX.js How > difficult would it be to write a Pythonbased ASCIImath  LaTeX math > converter? > > ... > > > In order for the math input to be recognized, the rst2xml.py script > > could simply accept two options. Other scripts could likewise accept > > these options: > > > mathinput ascii > > IMV, the input format should rather be given in the document. Otherwise > documents may render invalid/untranslatable. I envisage a directive option > and derived roles like: > > .. math:: > :input: asciimath > > .. role:: asciimath(math) > :input: asciimath > > > > mathoutput mathml > > This could be easily done by making the setting of the HTML writer a > generic one. > > We could use list of accepted output formats in order of preference > (idea by David) with defaults like:: > > [html4css1 writer] > > mathoutput: mathjax, mathml, html, literal > > [html4strict writer] > > mathoutput: mathml, mathjax, html, literal > > [latex2e writer] > > mathoutput: latex, literal > > which could be overridden in a config file or the command line like > > rst2html mathoutput=html,mathml,literal > > > Thanks > > Günter > > > >  > Keep Your Developer Skills Current with LearnDevNow! > The most comprehensive online learning library for Microsoft developers > is just $99.99! Visual Studio, SharePoint, SQL  plus HTML5, CSS3, MVC3, > Metro Style Apps, more. Free future releases when you subscribe now! > http://p.sf.net/sfu/learndevnowd2d > _______________________________________________ > Docutilsdevelop mailing list > Docutilsdevelop@... > https://lists.sourceforge.net/lists/listinfo/docutilsdevelop > > Please use "Reply All" to reply to the list. > 
From: Guenter Milde <milde@us...>  20120229 08:50:06

Hi Paul and all Docutils developers, On 20120228, Paul Tremblay wrote: > I am not that well versed in latex to know exactly how to convert it. > Converting latex to mathml might not require a complete reworking of my > code. For example, ASCIImath uses > text(apple) > Whereas latex uses > \text(apple) > If latex is indeed that close to ASCIImath, (This is because ASCIImath is modelled after TeX  with simplifications for the user) > it doesn't seem to make sense to use latex, since ASCIImath math > doesn't need the back slashes. Yes, backslashes are hard to type, especially on a German keyboard (AltGr+ß). Also, ASCIImath looks much more similar to nonmath rST. This makes it also a viable output option for text formats (rst, manpage, txt) and other formats witout proper math support. This becomes especially useful and readable if combined with Unicode math character replacements (already implemented for TeX math input), e.g. ∫ s_δ(xx') dx However, there are many use cases for TeX math input even for people not knowing the details of the TeX math syntax, e.g. draganddrop of equations from documents made with LyX (or some other LaTeX frontend) or the Wikipedia. This means that conversion between ASCIImath and TeXmath could make ASCIImath a "full citizen" in standard rst (maybe even the default?). > Converting latex to mathml sounds like I would need to write a whole new > library. Do you mean "converting asciimath to TeX"? > Like I said, I don't know the syntax of latex. My hope was that the JavaScript sources might help in devising the ASCIImath<>TeX math converter. How did you start when programming the Python lib? Also, there are plenty of test cases as Wikipedia (as well as the current Docutils math and the various longerexisting Docutils math extensions (including Sphinx)) all use TeXmath as math input format. For a start, see ``docutils/test/functional/input/data/math.txt`` and the various math_output* files in ``docutils/test/functional`` 