README 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. == About texvc ==
  2. texvc takes LaTeX-compatible equations and produces formatted output in HTML,
  3. MathML, and (via LaTeX/dvipng) rasterized PNG images.
  4. Input data is parsed and scrutinized for safety, and the output includes an
  5. estimate of whether the code is simple enough that HTML rendering will look
  6. acceptable.
  7. The program was written by Tomasz Wegrzanowski for use with MediaWiki; it's
  8. included as part of the MediaWiki package (http://www.mediawiki.org) and is
  9. under the GPL license.
  10. Please report bugs at: https://bugzilla.wikimedia.org/
  11. with "MediaWiki extensions" as product and "texvc" as component.
  12. == Setup ==
  13. === Requirements ===
  14. OCaml 3.06 or later is required to compile texvc; this can be acquired from
  15. http://caml.inria.fr/ if your system doesn't have it available.
  16. The makefile requires GNU make.
  17. Rasterization is done via LaTeX, dvipng. These need to be installed and in
  18. the PATH: latex, dvipng
  19. AMS* packages for LaTeX also need to be installed. Without AMS* some equations
  20. will render correctly while others won't render. Most distributions of TeX
  21. already contain AMS*. In Debian/Ubuntu you need to install tetex-extra.
  22. To work properly with rendering non-ASCII Unicode characters, a supplemental TeX
  23. package is needed (cjk-latex in Debian)
  24. === Installation ===
  25. Run 'make' (or 'gmake' if GNU make is not your default make). This should
  26. produce the texvc executable.
  27. Then you'll need to set $wgUseTeX to true in your LocalSettings.php. By default,
  28. MediaWiki will search in this directory for texvc, if you moved it elsewhere,
  29. you'll have to modify $wgTexvc and set it to the path of the texvc executable.
  30. == Usage ==
  31. Normally texvc is called from MediaWiki's Math.php modules and everything
  32. Just Works. It can be run manually for testing or for use in another app.
  33. === Command-line parameters ===
  34. texvc <temp directory> <output directory> <TeX code> <encoding>
  35. Be sure to properly quote the TeX code!
  36. Example:
  37. texvc /home/wiki/tmp /home/wiki/math "y=x+2" iso-8859-1
  38. === Output format ===
  39. Status codes and HTML/MathML transformations are returned on stdout.
  40. A rasterized PNG file will be written to the output directory, named
  41. for the MD5 hash code.
  42. texvc output format is like this:
  43. +%5 ok, but not html or mathml
  44. c%5%h ok, conservative html, no mathml
  45. m%5%h ok, moderate html, no mathml
  46. l%5%h ok, liberal html, no mathml
  47. C%5%h\0%m ok, conservative html, with mathml
  48. M%5%h\0%m ok, moderate html, with mathml
  49. L%5%h\0%m ok, liberal html, with mathml
  50. X%5%m ok, no html, with mathml
  51. S syntax error
  52. E lexing error
  53. F%s unknown function %s
  54. - other error
  55. \0 - null character
  56. %5 - md5, 32 hex characters
  57. %h - html code, without \0 characters
  58. %m - mathml code, without \0 characters
  59. == Troubleshooting ==
  60. Unforunately, many error conditions with rasterization are not well reported.
  61. texvc will return as though everything is successful, and the only obvious
  62. sign of problems for the user is a big X on a wiki page where an equation
  63. should be.
  64. Try running texvc from the command line to ensure that the software it relies
  65. upon is all set up.
  66. Ensure that the temporary and math directories exist and can be written to by
  67. the user account the web server runs under; if you don't control the server,
  68. you may have to make them world-writable.
  69. If some equations render correctly while others don't, you probably don't have
  70. AMS* packages for LaTeX installed. Most distributions of TeX come with AMS*.
  71. In Debian/Ubuntu AMS* is in tetex-extra package.
  72. To check if that is the problem you can try those two equations:
  73. x + y
  74. x \implies y
  75. The first uses only standard LaTeX, while the second uses symbol \implies from AMS*.
  76. If the first renders, but the second doesn't, you need to install AMS*.
  77. == Hacking ==
  78. Before you start hacking on the math package its good to know the workflow,
  79. which is basically:
  80. 1. texvc gets called by includes/Math.php (check out the line begining with "$cmd")
  81. 2. texvc does its magic, which is basically to check for invalid latex code.
  82. 3. texvc takes the user input if valid and creates a latex file containing it, see
  83. get_preface in texutil.ml
  84. 4. dvipng(1) gets called to create a .png file
  85. See render.ml for this process (commenting out the removal of
  86. the temporary file is useful for debugging).