Remove Wikipedia/Wikimedia specific translations
[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/dvipng) 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, dvipng. These need
25 to be installed and in the PATH: latex, dvipng
26
27 AMS* packages for LaTeX also need to be installed. Without AMS* some
28 equations will render correctly while others won't render.
29 Most distributions of TeX already contain AMS*.
30 In Debian/Ubuntu you need to install tetex-extra.
31
32 To work properly with rendering non-ASCII Unicode characters, a
33 supplemental TeX package is needed (cjk-latex in Debian)
34
35 === Installation ===
36
37 Run 'make' (or 'gmake' if GNU make is not your default make). This should
38 produce the texvc executable.
39
40 If you're using MediaWiki's install.php and have enabled $wgUseTeX in your
41 LocalSettings.php, the installer will try to copy texvc into place, in the
42 'math' subdirectory under where wiki.phtml is installed.
43
44
45 == Usage ==
46
47 Normally texvc is called from MediaWiki's Math.php modules and everything
48 Just Works. It can be run manually for testing or for use in another app.
49
50 === Command-line parameters ===
51
52 texvc <temp directory> <output directory> <TeX code> <encoding>
53
54 Be sure to properly quote the TeX code!
55
56 Example:
57
58 texvc /home/wiki/tmp /home/wiki/math "y=x+2" iso-8859-1
59
60 === Output format ===
61
62 Status codes and HTML/MathML transformations are returned on stdout.
63 A rasterized PNG file will be written to the output directory, named
64 for the MD5 hash code.
65
66 texvc output format is like this:
67 +%5 ok, but not html or mathml
68 c%5%h ok, conservative html, no mathml
69 m%5%h ok, moderate html, no mathml
70 l%5%h ok, liberal html, no mathml
71 C%5%h\0%m ok, conservative html, with mathml
72 M%5%h\0%m ok, moderate html, with mathml
73 L%5%h\0%m ok, liberal html, with mathml
74 X%5%m ok, no html, with mathml
75 S syntax error
76 E lexing error
77 F%s unknown function %s
78 - other error
79
80 \0 - null character
81 %5 - md5, 32 hex characters
82 %h - html code, without \0 characters
83 %m - mathml code, without \0 characters
84
85
86 == Troubleshooting ==
87
88 Unforunately, many error conditions with rasterization are not well reported.
89 texvc will return as though everything is successful, and the only obvious
90 sign of problems for the user is a big X on a wiki page where an equation
91 should be.
92
93 Try running texvc from the command line to ensure that the software it relies
94 upon is all set up.
95
96 Ensure that the temporary and math directories exist and can be written to by
97 the user account the web server runs under; if you don't control the server,
98 you may have to make them world-writable.
99
100 If some equations render correctly while others don't, you probably don't have
101 AMS* packages for LaTeX installed. Most distributions of TeX come with AMS*.
102 In Debian/Ubuntu AMS* is in tetex-extra package.
103 To check if that is the problem you can try those two equations:
104 x + y
105 x \implies y
106 The first uses only standard LaTeX, while the second uses symbol \implies from AMS*.
107 If the first renders, but the second doesn't, you need to install AMS*.
108
109 == Hacking ==
110
111 Before you start hacking on the math package its good to know the workflow,
112 which is basically:
113
114 1. texvc gets called by includes/Math.php (check out the line begining with "$cmd")
115 2. texvc does its magic, which is basically to check for invalid latex code.
116 3. texvc takes the user input if valid and creates a latex file containing it, see
117 get_preface in texutil.ml
118 4. dvipng(1) gets called to create a .png file
119 See render.ml for this process (commenting out the removal of
120 the temporary file is useful for debugging).