summaryrefslogtreecommitdiff
path: root/math
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2006-10-11 20:21:25 +0000
committerPierre Schmitz <pierre@archlinux.de>2006-10-11 20:21:25 +0000
commitd81f562b712f2387fa02290bf2ca86392ab356f2 (patch)
treed666cdefbe6ac320827a2c6cb473581b46e22c4c /math
parent183851b06bd6c52f3cae5375f433da720d410447 (diff)
Aktualisierung auf Version 1.8.1
Diffstat (limited to 'math')
-rw-r--r--math/README25
-rw-r--r--math/render.ml11
-rw-r--r--math/texutil.ml9
3 files changed, 36 insertions, 9 deletions
diff --git a/math/README b/math/README
index e58cbf04..818ce6bd 100644
--- a/math/README
+++ b/math/README
@@ -1,7 +1,7 @@
== About texvc ==
texvc takes LaTeX-compatible equations and produces formatted output in
-HTML, MathML, and (via LaTeX/dvips/ImageMagick) rasterized PNG images.
+HTML, MathML, and (via LaTeX/dvipng) 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.
@@ -21,8 +21,13 @@ 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
+Rasterization is done via LaTeX, dvipng. These need
+to be installed and in the PATH: latex, dvipng
+
+AMS* packages for LaTeX also need to be installed. Without AMS* some
+equations will render correctly while others won't render.
+Most distributions of TeX already contain AMS*.
+In Debian/Ubuntu you need to install tetex-extra.
To work properly with rendering non-ASCII Unicode characters, a
supplemental TeX package is needed (cjk-latex in Debian)
@@ -92,6 +97,15 @@ 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.
+If some equations render correctly while others don't, you probably don't have
+AMS* packages for LaTeX installed. Most distributions of TeX come with AMS*.
+In Debian/Ubuntu AMS* is in tetex-extra package.
+To check if that is the problem you can try those two equations:
+ x + y
+ x \implies y
+The first uses only standard LaTeX, while the second uses symbol \implies from AMS*.
+If the first renders, but the second doesn't, you need to install AMS*.
+
== Hacking ==
Before you start hacking on the math package its good to know the workflow,
@@ -101,7 +115,6 @@ which is basically:
2. texvc does its magic, which is basically to check for invalid latex code.
3. texvc takes the user input if valid and creates a latex file containing it, see
get_preface in texutil.ml
-4. latex(1) gets called to create a .dvi file, then a .ps file is created from the
- .dvi file using dvips(1), and finally convert(1) creates a .png file from
- the .ps file. See render.ml for this process (commenting out the removal of
+4. dvipng(1) gets called to create a .png file
+ See render.ml for this process (commenting out the removal of
the temporary file is useful for debugging).
diff --git a/math/render.ml b/math/render.ml
index f070a91e..e9a21687 100644
--- a/math/render.ml
+++ b/math/render.ml
@@ -2,6 +2,10 @@ let cmd_dvips tmpprefix = "dvips -R -E " ^ tmpprefix ^ ".dvi -f >" ^ tmpprefix ^
let cmd_latex tmpprefix = "latex " ^ tmpprefix ^ ".tex >/dev/null"
(* Putting -transparent white in converts arguments will sort-of give you transperancy *)
let cmd_convert tmpprefix finalpath = "convert -quality 100 -density 120 " ^ tmpprefix ^ ".ps " ^ finalpath ^ " >/dev/null 2>/dev/null"
+(* Putting -bg Transparent in dvipng's arguments will give full-alpha transparency *)
+(* Note that IE have problems with such PNGs and need an additional javascript snippet *)
+(* Putting -bg transparent in dvipng's arguments will give binary transparency *)
+let cmd_dvipng tmpprefix finalpath = "dvipng -gamma 1.5 -D 120 -T tight --strict " ^ tmpprefix ^ ".dvi -o " ^ finalpath ^ " >/dev/null 2>/dev/null"
exception ExternalCommandFailure of string
@@ -15,7 +19,8 @@ let render tmppath finalpath outtex md5 =
Sys.remove (tmpprefix ^ ".aux");
Sys.remove (tmpprefix ^ ".log");
Sys.remove (tmpprefix ^ ".tex");
- Sys.remove (tmpprefix ^ ".ps");
+ if Sys.file_exists (tmpprefix ^ ".ps")
+ then Sys.remove (tmpprefix ^ ".ps");
end in
let f = (Util.open_out_unless_exists (tmpprefix ^ ".tex")) in
begin
@@ -25,9 +30,11 @@ let render tmppath finalpath outtex md5 =
close_out f;
if Util.run_in_other_directory tmppath (cmd_latex tmpprefix0) != 0
then (unlink_all (); raise (ExternalCommandFailure "latex"))
- else if (Sys.command (cmd_dvips tmpprefix) != 0)
+ else if (Sys.command (cmd_dvipng tmpprefix (finalpath^"/"^md5^".png")) != 0)
+ then (if (Sys.command (cmd_dvips tmpprefix) != 0)
then (unlink_all (); raise (ExternalCommandFailure "dvips"))
else if (Sys.command (cmd_convert tmpprefix (finalpath^"/"^md5^".png")) != 0)
then (unlink_all (); raise (ExternalCommandFailure "convert"))
+ else unlink_all ())
else unlink_all ()
end
diff --git a/math/texutil.ml b/math/texutil.ml
index f7678e34..b4cd268c 100644
--- a/math/texutil.ml
+++ b/math/texutil.ml
@@ -152,6 +152,13 @@ let find = function
| "\\Downarrow" -> DELIMITER (HTMLABLE (FONT_UF, "\\Downarrow ", "&dArr;"))
| "\\updownarrow" -> DELIMITER (TEX_ONLY "\\updownarrow ")
| "\\Updownarrow" -> DELIMITER (TEX_ONLY "\\Updownarrow ")
+ | "\\ulcorner" -> (tex_use_ams (); DELIMITER (TEX_ONLY "\\ulcorner "))
+ | "\\urcorner" -> (tex_use_ams (); DELIMITER (TEX_ONLY "\\urcorner "))
+ | "\\llcorner" -> (tex_use_ams (); DELIMITER (TEX_ONLY "\\llcorner "))
+ | "\\lrcorner" -> (tex_use_ams (); DELIMITER (TEX_ONLY "\\lrcorner "))
+ | "\\twoheadleftarrow" -> (tex_use_ams (); DELIMITER (TEX_ONLY "\\twoheadleftarrow "))
+ | "\\twoheadrightarrow" -> (tex_use_ams (); DELIMITER (TEX_ONLY "\\twoheadrightarrow "))
+ | "\\rightleftharpoons" -> DELIMITER (TEX_ONLY "\\rightleftharpoons ")
| "\\leftrightarrow" -> LITERAL (HTMLABLE (FONT_UF, "\\leftrightarrow ", "&harr;"))
| "\\lrarr" -> LITERAL (HTMLABLE (FONT_UF, "\\leftrightarrow ", "&harr;"))
| "\\harr" -> LITERAL (HTMLABLE (FONT_UF, "\\leftrightarrow ", "&harr;"))
@@ -169,7 +176,6 @@ let find = function
| "\\nearrow" -> LITERAL (TEX_ONLY "\\nearrow ")
| "\\swarrow" -> LITERAL (TEX_ONLY "\\swarrow ")
| "\\nwarrow" -> LITERAL (TEX_ONLY "\\nwarrow ")
- | "\\sim" -> LITERAL (TEX_ONLY "\\sim ")
| "\\simeq" -> LITERAL (TEX_ONLY "\\simeq ")
| "\\star" -> LITERAL (TEX_ONLY "\\star ")
| "\\ell" -> LITERAL (TEX_ONLY "\\ell ")
@@ -440,6 +446,7 @@ let find = function
| "\\choose" -> FUN_INFIX "\\choose "
| "\\atop" -> FUN_INFIX "\\atop "
| "\\binom" -> FUN_AR2 "\\binom "
+ | "\\stackrel" -> FUN_AR2 "\\stackrel "
| "\\frac" -> FUN_AR2h ("\\frac ", fun num den -> Html.html_render [num], "<hr style=\"{background: black}\"/>", Html.html_render [den])
| "\\cfrac" -> (tex_use_ams (); FUN_AR2h ("\\cfrac ", fun num den -> Html.html_render [num], "<hr style=\"{background: black}\">", Html.html_render [den]))
| "\\over" -> FUN_INFIXh ("\\over ", fun num den -> Html.html_render num, "<hr style=\"{background: black}\"/>", Html.html_render den)