* Added a hacking section for people interested in working on the code.
[lhc/web/wiklou.git] / math / README
1 == About texvc ==
2
3 texvc takes LaTeX-compatible equations and produces formatted output in
4 HTML, MathML, and (via LaTeX/dvips/ImageMagick) rasterized PNG images.
5 Input data is parsed and scrutinized for safety, and the output includes
6 an estimate of whether the code is simple enough that HTML rendering will
7 look acceptable.
8
9 The program was written by Tomasz Wegrzanowski for use with MediaWiki;
10 it's included as part of the MediaWiki package (http://wikipedia.sf.net)
11 and is under the GPL license.
12
13 Please report bugs at: http://bugzilla.wikimedia.org/ (under "MediaWiki")
14
15 == Setup ==
16
17 === Requirements ===
18
19 OCaml 3.06 or later is required to compile texvc; this can be acquired
20 from http://caml.inria.fr/ if your system doesn't have it available.
21
22 The makefile requires GNU make.
23
24 Rasterization is done via LaTeX, dvips, and ImageMagick. These need
25 to be installed and in the PATH: latex, dvips, convert
26
27 To work properly with rendering non-ASCII Unicode characters, a
28 supplemental TeX package is needed (cjk-latex in Debian)
29
30 === Installation ===
31
32 Run 'make' (or 'gmake' if GNU make is not your default make). This should
33 produce the texvc executable.
34
35 If you're using MediaWiki's install.php and have enabled $wgUseTeX in your
36 LocalSettings.php, the installer will try to copy texvc into place, in the
37 'math' subdirectory under where wiki.phtml is installed.
38
39
40 == Usage ==
41
42 Normally texvc is called from MediaWiki's Math.php modules and everything
43 Just Works. It can be run manually for testing or for use in another app.
44
45 === Command-line parameters ===
46
47 texvc <temp directory> <output directory> <TeX code> <encoding>
48
49 Be sure to properly quote the TeX code!
50
51 Example:
52
53 texvc /home/wiki/tmp /home/wiki/math "y=x+2" iso-8859-1
54
55 === Output format ===
56
57 Status codes and HTML/MathML transformations are returned on stdout.
58 A rasterized PNG file will be written to the output directory, named
59 for the MD5 hash code.
60
61 texvc output format is like this:
62 +%5 ok, but not html or mathml
63 c%5%h ok, conservative html, no mathml
64 m%5%h ok, moderate html, no mathml
65 l%5%h ok, liberal html, no mathml
66 C%5%h\0%m ok, conservative html, with mathml
67 M%5%h\0%m ok, moderate html, with mathml
68 L%5%h\0%m ok, liberal html, with mathml
69 X%5%m ok, no html, with mathml
70 S syntax error
71 E lexing error
72 F%s unknown function %s
73 - other error
74
75 \0 - null character
76 %5 - md5, 32 hex characters
77 %h - html code, without \0 characters
78 %m - mathml code, without \0 characters
79
80
81 == Troubleshooting ==
82
83 Unforunately, many error conditions with rasterization are not well reported.
84 texvc will return as though everything is successful, and the only obvious
85 sign of problems for the user is a big X on a wiki page where an equation
86 should be.
87
88 Try running texvc from the command line to ensure that the software it relies
89 upon is all set up.
90
91 Ensure that the temporary and math directories exist and can be written to by
92 the user account the web server runs under; if you don't control the server,
93 you may have to make them world-writable.
94
95 == Hacking ==
96
97 Before you start hacking on the math package its good to know the workflow,
98 which is basically:
99
100 1. texvc gets called by includes/Math.php (check out the line begining with "$cmd")
101 2. texvc does its magic, which is basically to check for invalid latex code.
102 3. texvc takes the user input if valid and creates a latex file containing it, see
103 get_preface in texutil.ml
104 4. latex(1) gets called to create a .dvi file, the a .ps file is created from the
105 .dvi file using dvips(1), and finally convert(1) creates a .png file from
106 the .ps file. See render.ml for this process (commenting out the removal of
107 the temporary file is useful for debugging).