need translated (JS to pas) ASCII 2 MathML Converter lazarus / 5-Lazarus Extra Components ---------------------------------------------------------------------- danib · 2011-02-22 07:12 im writing a math exercise generator and i need to convert ascii to a math like text i have found this script to can do wat i want http://mathcs.chapman.edu/~jipsen/mathml/ASCIIMathML.js http://www.asciimathml.com/dredging/default.asp?id=1&mnu=1 but i dont have the know how (or the free time to get it) to convert it to pascal is ther a volunteer taht can translate it to pascal im sure it can be of a more general interest ---------------------------------------------------------------------- theo · 2011-02-22 09:51 You could add a bounty: http://wiki.lazarus.freepascal.org/Bounties ---------------------------------------------------------------------- danib · 2011-02-22 11:28 nice idea but at my salary (not a US/EU/UK resident and a teacher) its not going to happen ---------------------------------------------------------------------- JuhaManninen · 2011-02-23 09:46 Quote from: danib on February 22, 2011, 08:12:42 amim writing a math exercise generator and i need to convert ascii to a math like text i have found this script to can do wat i want http://mathcs.chapman.edu/~jipsen/mathml/ASCIIMathML.js http://www.asciimathml.com/dredging/default.asp?id=1&mnu=1 but i dont have the know how (or the free time to get it) to convert it to pascal I am interested to know what exactly you are planning to do. Is it going to be a web application? If so, then the existing Java- Script solutions should be good for you. Or, do you want to make a GUI program that renders the ASCIIMathML in a local browser window using MathML? Or a GUI program that send the generated MathML to a selected web page? I tried to solve a little similar problem when studying mathematics together with other students. We wanted to share solutions and questions about math problems, the same easy way we can send e-mails. There is no practical way to do it! There are formula editors. MS word has a good one but most people don't have MS Office. I have OpenOffice on Linux but I didn't find Formula editor there. Later I learned it must be installed separately. Uhhh... Starting a big office suite and creating a document, just to pass one math formula to a friend, feels like an overkill anyway. Nobody really wanted to do it. I used ascii notation sometimes, about like ASCIIMathML but improvising. Like:       SQRT(x^2 + z^2) y = ----------------------            2 It requires fixed width font when editing and showing it, thus most e-mail clients (or this forum editor) can't be used. Besides the notation becomes very messy with more complex formulas. Nobody wants to struggle with it because math itself is a big enough challenge. The preferred way by some people was to draw on paper, then scan it and send as a picture attachment in e-mail. The attachment is big, nobody can copy from it... Finally the math exchange dried and stopped. The only realistic approach to study together is to go to the same physical location. There should be a e-mail or chat client that can render MathML and has an embedded WYSIWYG formula editor. They already can handle HTML so that user does not need to see or care about HTML syntax. In addition there could be an OCR to convert hand-drawn formulas into MathML. OCR solutions are rather advanced nowadays, a messy formula should not be a problem. Juha ---------------------------------------------------------------------- danib · 2011-02-23 15:41 i want to make  an exercise page(`s) for my pupils (grade 7-11) wen all i needed was simple formulas like 2X=4  or 2x^2+3X+2=12 i told them ^ is the same as writing a small number to the right top of the X but now we got to more complex formulas like       SQRT(x^2 + z^2) y = ----------------------            2 so im trying to do is get the out put of my (upgraded)program  to be more readabil if not ill have to do it by hand the program (pascal lazarus) gets  random numbers (result,a,b,c,...) and then put it in a formula like (b/d)X/e=(b*result/e)/d (b/d) is a single number in the out put so if i get result=2 b=6 d=2 e=3 the out put is 3X/3=4/2 what i want is to thake this ASCII and convert it to MathML  (all 200 formulas) print it and give it to the school to make more copy's that i can give the pupils as home work (or class work) ---------------------------------------------------------------------- Phil · 2011-02-23 16:13 Why not just use ASCIIMathML.js? What exactly does Pascal bring to the table? Thanks. -Phil ---------------------------------------------------------------------- danib · 2011-02-23 16:22 i know pascal i dont know js ---------------------------------------------------------------------- Phil · 2011-02-23 17:30 I would stick to the JS since you'll need to learn some JS in order to convert it to Pascal. I would also guess that learning a little JS would not be the most difficult part. The advantage of JS is that it's Web-ready. In fact, with some cleanup this could easily be made HTML5-ready, so that it can be used offline like a desktop app (albeit in a browser). And optimized for mobile devices. Looking briefly at the JS, here is what I would suggest: - Break it up into UI and non-UI (parsing) .js files. This would allow you to substitute a modern JS framework like ExtJS or Apple's Dashcode "Parts" to do the UI. His code is a little bit antique, working around many browser compatibility issues, particularly for obsolete browsers (IE5). All modern JS frameworks already do this, usually to add "standards compliance" to IE, which even at IE8 is not yet standards compliant. - Add HTML5 manifest for offline use. Thanks. -Phil ---------------------------------------------------------------------- vvzh · 2011-02-23 18:34 If you still would like to use Free Pascal/Lazarus there is one more option. MimeTex is a small CGI program that can generate an image representation of formula from input string using TeX syntax. It is possible to create a wrapper application that calls mimetex binary via TProcess and renders the result. The same idea is a basis of TeXGui program. It is written in Python, not Pascal, but could be considered an example of mimetex usage. Mimetex can generate output image in GIF and ASCII (black+white or grayscale) format. I'm not sure TImage supports GIF, but it is possible to draw the picture on Canvas manually based on grayscale ASCII output. Text antialiasing quality of mimetex output is somewhat lower compared to OpenOffice.org Math or full-blown TeX installation, but it can render quite large subset of TeX math symbols. Mimetex is also web-ready, however it has nothing to do with JS and MathML, so can be considered quite off-topic ---------------------------------------------------------------------- Phil · 2011-02-23 18:39 Quote from: vvzh on February 23, 2011, 07:34:42 pmMimetex is also web- ready, however it has nothing to do with JS and MathML, so can be considered quite off-topic Web-ready, yes. Easy-to-host, no. Very few ISP's permit CGI apps on their servers, whereas you can serve up a pure JS app from any server that allows HTML files. Thanks. -Phil ---------------------------------------------------------------------- JuhaManninen · 2011-02-23 20:17 I understand Danib's students don't need to write ASCIIMathML themselves, so the JS solution sounds right. Does anyone have ideas for the student-formula-exchange problem? I am sure many people face the same problem when they have a mathematical problem and want to ask about it in an e-mail. Juha ---------------------------------------------------------------------- Phil · 2011-02-23 20:23 Juha, If I'm understanding you correctly, perhaps a Web app similar to this would be helpful: http://www1.chapman.edu/~jipsen/mathml/asciimathdemo.html (1) Student A sends Student B (C, D, ...) a text version of equations. (2) Other students copy and paste it into the Web app to see the formatted formula. Thanks. -Phil ---------------------------------------------------------------------- danib · 2011-02-23 20:32 for my porpes ther wont be any server or web use student usually refers to >18y old my pupils are 13-17 y old my programing ability is sirosly over estimated the tex options lives me whit the same problem i have now use a script language i dont know (latex/mathML) or use the ASCII formula as source to manually write in a math formula editor phil: thats the page ill be using if i cant automate the program thanks for the responses so far ill keep monitoring ---------------------------------------------------------------------- JuhaManninen · 2011-02-24 08:49 Danib, if you just use the ASCIIMathML.js as-is, without modifying it, does it not work well enough for you? What is missing? Is the rendering wrong? Phil, I was hoping for a WYSIWYG formula editor solution. ASCIIMathML works when you know the syntax and you already have the formula drawn on paper using a pen. There seems to be a Science Pad on the pages you mentioned:  http://math.chapman.edu/~jipsen/asciencepad/asciencepad.html It requires a local server installation which is already too much for people who just want to learn maths. Juha ---------------------------------------------------------------------- Phil · 2011-02-24 17:32 Quote from: JuhaManninen on February 24, 2011, 09:49:09 amThere seems to be a Science Pad on the pages you mentioned:  http://math.chapman.edu/~jipsen/asciencepad/asciencepad.html It requires a local server installation which is already too much for people who just want to learn maths. Why do you think it needs a server? I'm running the core editor locally in my browser. Thanks. -Phil ---------------------------------------------------------------------- PAEz · 2011-02-24 17:50 Instead of entering the values on that page why not make something in Lazarus to output a html file that uses that script? Have a look at the source for the example page.... http://mathcs.chapman.edu/~jipsen/mathml/asciimathsample.html ....its really simple. You'd have to learn some html maybe to get it just how you want for printing or you could copy the resulting page in to something like wordpad and format it to your liking. ---------------------------------------------------------------------- danib · 2011-02-24 21:56 PAEz: thats exactly what i want to do JuhaManninen : it means i need to do 1 extra stage manually if i can plag a function that gets the ASCII the program generates, and output the MattML html i wont need to do copy ASCII , past at URL (http://www.wjagray.co.uk/maths/Editor/EditorPrint.html), print just load the html and print it edit i had a look at the source asciimathsample.html and i see now what you mean i think i can do that thanks