Re: [Docutils-develop] ASCII math converts ASCII math to MathML From: Paul Tremblay - 2012-02-28 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 wrote: > On 2012-02-28, Paul Tremblay wrote: > > On 2/27/12 6:18 AM, Guenter Milde wrote: > >> On 2012-02-19, 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 ASCII-Math -> LaTeX converter would be very desirable for > adoption of ASCII-Math 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 Python-based 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: > > > --math-input 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 > > > > --math-output 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] > > math-output: mathjax, mathml, html, literal > > [html4strict writer] > > math-output: mathml, mathjax, html, literal > > [latex2e writer] > > math-output: latex, literal > > which could be overridden in a config file or the command line like > > rst2html --math-output=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/learndevnow-d2d > _______________________________________________ > Docutils-develop mailing list > Docutils-develop@... > https://lists.sourceforge.net/lists/listinfo/docutils-develop > > Please use "Reply All" to reply to the list. >  ### Thread view  [Docutils-develop] ASCII math converts ASCII math to MathML From: Paul Tremblay - 2012-02-19 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   Re: [Docutils-develop] ASCII math converts ASCII math to MathML From: Guenter Milde - 2012-02-27 11:18:55 On 2012-02-19, 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/2008-05/threads.html) Thanks for keeping this up, Günter   Re: [Docutils-develop] ASCII math converts ASCII math to MathML From: Paul Tremblay - 2012-02-28 01:20:28 On 2/27/12 6:18 AM, Guenter Milde wrote: > On 2012-02-19, 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: --math-input ascii --math-output mathml The default for both, without any option, would be latex. Paul   Re: [Docutils-develop] ASCII math converts ASCII math to MathML From: Guenter Milde - 2012-02-28 13:05:06 On 2012-02-28, Paul Tremblay wrote: > On 2/27/12 6:18 AM, Guenter Milde wrote: >> On 2012-02-19, 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 ASCII-Math -> LaTeX converter would be very desirable for adoption of ASCII-Math 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 Python-based 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: > --math-input 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 > --math-output 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] math-output: mathjax, mathml, html, literal [html4strict writer] math-output: mathml, mathjax, html, literal [latex2e writer] math-output: latex, literal which could be overridden in a config file or the command line like rst2html --math-output=html,mathml,literal Thanks Günter   Re: [Docutils-develop] ASCII math converts ASCII math to MathML From: Paul Tremblay - 2012-02-28 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 wrote: > On 2012-02-28, Paul Tremblay wrote: > > On 2/27/12 6:18 AM, Guenter Milde wrote: > >> On 2012-02-19, 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 ASCII-Math -> LaTeX converter would be very desirable for > adoption of ASCII-Math 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 Python-based 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: > > > --math-input 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 > > > > --math-output 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] > > math-output: mathjax, mathml, html, literal > > [html4strict writer] > > math-output: mathml, mathjax, html, literal > > [latex2e writer] > > math-output: latex, literal > > which could be overridden in a config file or the command line like > > rst2html --math-output=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/learndevnow-d2d > _______________________________________________ > Docutils-develop mailing list > Docutils-develop@... > https://lists.sourceforge.net/lists/listinfo/docutils-develop > > Please use "Reply All" to reply to the list. > 
 Re: [Docutils-develop] ASCII math converts ASCII math to MathML From: Guenter Milde - 2012-02-29 08:50:06 Hi Paul and all Docutils developers, On 2012-02-28, 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 (Alt-Gr+ß). Also, ASCIImath looks much more similar to non-math rST. This makes it also a viable output option for text formats (rst, man-page, 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_δ(x-x') 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. drag-and-drop of equations from documents made with LyX (or some other LaTeX front-end) or the Wikipedia. This means that conversion between ASCIImath and TeX-math 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 longer-existing Docutils math extensions (including Sphinx)) all use TeX-math 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