[DEV] Math BBCode

A place for MOD Authors to post and receive feedback on MODs still in development. No MODs within this forum should be used within a live environment! No new topics are allowed in this forum.
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

IMPORTANT: MOD Development Forum rules

On February 1, 2009 this forum will be set to read only as part of retiring of phpBB2.

[DEV] Math BBCode

Postby ElizabeththeGrey » Fri Jan 23, 2004 4:40 pm

There is a program written by the nice code wizards at Wikipedia that will, on a wiki, transform TeX from
Code: Select all
<math>\lim_{x\to\,a}f(x)=L</math>
into Image.
I'm wondering if anyone else would be interested in a BBCode wrapper for this function. It should be relatively trivial to write, as all one needs to do is call "texvc" with appropriate arguments, and return an <img src=$root_path/lala>. The README provided in their CVS says that:

== About texvc ==

texvc takes LaTeX-compatible equations and produces formatted output in
HTML, MathML, and (via LaTeX/dvips/ImageMagick) rasterized PNG images.
Input data is parsed and scrutinized for safety, and the output includes
an estimate of whether the code is simple enough that HTML rendering will
look acceptable.

The program was written by Tomasz Wegrzanowski for use with MediaWiki;
it's included as part of the MediaWiki package (http://wikipedia.sf.net)
and is under the GPL license.

Please report bugs at:
http://sourceforge.net/tracker/?group_i ... tid=411192

== Setup ==

=== Requirements ===

OCaml 3.06 or later is required to compile texvc; this can be acquired
from http://caml.inria.fr/ if your system doesn't have it available.

The makefile requires GNU make.

Rasterization is done via LaTeX, dvips, and ImageMagick. These need
to be installed and in the PATH: latex, dvips, convert

To work properly with rendering non-ASCII Unicode characters, a
supplemental TeX package is needed (cjk-latex in Debian)

=== Installation ===

Run 'make' (or 'gmake' if GNU make is not your default make). This should
produce the texvc executable.

If you're using MediaWiki's install.php and have enabled $wgUseTeX in your
LocalSettings.php, the installer will try to copy texvc into place, in the
'math' subdirectory under where wiki.phtml is installed.


== Usage ==

Normally texvc is called from MediaWiki's Math.php modules and everything
Just Works. It can be run manually for testing or for use in another app.

=== Command-line parameters ===

texvc <temp directory> <output directory> <TeX code> <encoding>

Be sure to properly quote the TeX code!

Example:

texvc /home/wiki/tmp /home/wiki/math "y=x+2" iso-8859-1

=== Output format ===

Status codes and HTML/MathML transformations are returned on stdout.
A rasterized PNG file will be written to the output directory, named
for the MD5 hash code.

texvc output format is like this:
+%5 ok, but not html or mathml
c%5%h ok, conservative html, no mathml
m%5%h ok, moderate html, no mathml
l%5%h ok, liberal html, no mathml
C%5%h\0%m ok, conservative html, with mathml
M%5%h\0%m ok, moderate html, with mathml
L%5%h\0%m ok, liberal html, with mathml
X%5%m ok, no html, with mathml
S syntax error
E lexing error
F%s unknown function %s
- other error

\0 - null character
%5 - md5, 32 hex characters
%h - html code, without \0 characters
%m - mathml code, without \0 characters


== Troubleshooting ==

Unforunately, many error conditions with rasterization are not well reported.
texvc will return as though everything is successful, and the only obvious
sign of problems for the user is a big X on a wiki page where an equation
should be.

Try running texvc from the command line to ensure that the software it relies
upon is all set up.

Ensure that the temporary and math directories exist and can be written to by
the user account the web server runs under; if you don't control the server,
you may have to make them world-writable.


The code can be found at http://cvs.sourceforge.net/viewcvs.py/w ... se3/math/.

I'll start writing this one myself as soon as I have time, but I haven't done a BBCode MOD before, so I wouldn't mind having people help me :)
Last edited by ElizabeththeGrey on Fri Jan 23, 2004 10:57 pm, edited 2 times in total.
ElizabeththeGrey
Registered User
 
Posts: 118
Joined: Sun Nov 16, 2003 5:52 pm

Postby ElizabeththeGrey » Fri Jan 23, 2004 7:28 pm

Okay... I guess I should have a MOD Team member move this to MOD Development since I'm actually starting :)

I've been looking through the (GPLed) code of Wikipedia, figuring out how the math is parsed. They already have some nice functions for the formatting and return of the appropriate code, so all I have to do is just drop it in, and add in support for the phpBB DBAL.
ElizabeththeGrey
Registered User
 
Posts: 118
Joined: Sun Nov 16, 2003 5:52 pm

Postby ElizabeththeGrey » Fri Jan 23, 2004 11:05 pm

This MOD will have the following dependencies:
Runtime: ImageMagick, Ghostscript, Tetex
Compilation: Ocaml

Many hosts are not likely to have some of these, so you may be on your own if you try to do this on a server that you don't control.
ElizabeththeGrey
Registered User
 
Posts: 118
Joined: Sun Nov 16, 2003 5:52 pm

Postby LegendKnight » Sat Jan 24, 2004 12:24 am

Hi,
very interesting ...
With this MOD mathematicians can express their feeling the right way ;)
keep us posted on the development

~MK
User avatar
LegendKnight
Registered User
 
Posts: 94
Joined: Sun Jun 15, 2003 3:49 am
Location: Tarn-Vedra

Postby Salamence » Sat Jan 24, 2004 12:28 am

thats too complex for me. :x
Visit NP!
http://michelle90.proboards17.com/index.cgi
I wish phpBB was like proboards. :cry: Stupid javascript!
Salamence
Registered User
 
Posts: 5
Joined: Thu Jan 22, 2004 9:59 pm
Location: OKLAHOMA

Postby Einstein » Sat Jan 24, 2004 12:37 am

Great! ... I have no need for it but it would be a great MOD.
User avatar
Einstein
Registered User
 
Posts: 247
Joined: Sat Oct 18, 2003 9:48 pm
Location: Finland

Postby LegendKnight » Sat Jan 24, 2004 1:27 am

User avatar
LegendKnight
Registered User
 
Posts: 94
Joined: Sun Jun 15, 2003 3:49 am
Location: Tarn-Vedra

Postby Einstein » Sat Jan 24, 2004 1:32 am

LegendKnight wrote:Hi again
take a look at this
http://www.mathtype.com/en/products/mathplayer/
and this too
http://www.mathtype.com/en/products/webeq/

LaTeX is the only correct tool for writing mathematics.
User avatar
Einstein
Registered User
 
Posts: 247
Joined: Sat Oct 18, 2003 9:48 pm
Location: Finland

Postby ElizabeththeGrey » Sat Jan 24, 2004 3:55 am

I plan to include support in this MOD for MathML output, as it _is_ natively supported by texvc. However, I do not plan to allow MathML input, as I find MathML simply nasty to write... TeX is the simplest way to go in terms of doing input, and plenty of frontends like Mathematica will produce TeX output.

Also, note that the Mathtype projects are not FOSS, whereas all the components of phpBB MODs must be GPLed, like phpBB itself.
ElizabeththeGrey
Registered User
 
Posts: 118
Joined: Sun Nov 16, 2003 5:52 pm

Postby ElizabeththeGrey » Sat Jan 24, 2004 9:55 pm

work is going pretty well... I'm just tracking down some magic numbers they have in their programming, and abstracting them for placement in constants.php

I have the code basically working, so now I need to test it out and give it a good shakedown...
ElizabeththeGrey
Registered User
 
Posts: 118
Joined: Sun Nov 16, 2003 5:52 pm

Postby ElizabeththeGrey » Sun Jan 25, 2004 12:10 am

Sigh - whoever wrote the original code for Mediawiki was apparently following a very different coding standard...
1.) There are magic numbers all over the place.
2.) There are whole huge chains of if-elseif-elseif-...-elseif-else clauses, which I'm working on replacing with switch() case x: stuff.
3.) The indentation and (lack of) bracketing after conditionals is really getting to me...

I think I basically have everything DBAL compliant, and I'm still chasing down a couple of code tweaks before I start testing things. And no, it's not even been made ready to use in BBCode tags - I'm just working on the function that will take the foobar from [math]foobar[/math] and the user's preference for method of displaying math as its argument.
ElizabeththeGrey
Registered User
 
Posts: 118
Joined: Sun Nov 16, 2003 5:52 pm

Postby uberwald » Sun Jan 25, 2004 4:13 am

I totally love this idea, and look forward to installing it on my boards :) Yay for developing!
uberwald
Registered User
 
Posts: 10
Joined: Mon Jan 19, 2004 3:20 am

Postby ElizabeththeGrey » Fri Jan 30, 2004 6:32 am

I apologize for lack of development - I was on vacation beginning Tuesday, and I just got back.
ElizabeththeGrey
Registered User
 
Posts: 118
Joined: Sun Nov 16, 2003 5:52 pm

Postby ElizabeththeGrey » Wed Feb 04, 2004 6:50 am

Yes!!!! Base code is working!!! Now time to get that BBCode integration done!
ElizabeththeGrey
Registered User
 
Posts: 118
Joined: Sun Nov 16, 2003 5:52 pm

Postby ElizabeththeGrey » Wed Feb 04, 2004 8:07 pm

and... BBCode integration seems to be done - I have to check some usages of stripslashes involved and test it, then I'll release for public consumption.
ElizabeththeGrey
Registered User
 
Posts: 118
Joined: Sun Nov 16, 2003 5:52 pm

Next

Return to [2.0.x] MODs in Development

Who is online

Users browsing this forum: No registered users and 11 guests