http://www.mediawiki.org/wiki/Special:Code/MediaWiki/59593

Revision: 59593
Author:   freakolowsky
Date:     2009-11-30 18:42:16 +0000 (Mon, 30 Nov 2009)

Log Message:
-----------
* Added 5th parameter to texvc call (can be null and defaults to rgb '1.0 1.0 
1.0').
  This parameter controls texvc background color. Can be set to output 
transparent background
* Added $wgTexvcBackgroundColor parameter to DefaultSettings with value 'rgb 
1.0 1.0 1.0'
* Changed Math.php to call texvc with new parameter

Modified Paths:
--------------
    trunk/phase3/RELEASE-NOTES
    trunk/phase3/includes/DefaultSettings.php
    trunk/phase3/includes/Math.php
    trunk/phase3/math/README
    trunk/phase3/math/render.ml
    trunk/phase3/math/texvc.ml

Modified: trunk/phase3/RELEASE-NOTES
===================================================================
--- trunk/phase3/RELEASE-NOTES  2009-11-30 18:37:30 UTC (rev 59592)
+++ trunk/phase3/RELEASE-NOTES  2009-11-30 18:42:16 UTC (rev 59593)
@@ -290,6 +290,7 @@
 * (bug 20717) Added checkboxes to hide users with bot and/or sysop group
   membership in SpecialActiveusers
 * Allow \pagecolor and \definecolor in texvc
+* $wgTexvcBackgroundColor contains background color for texvc call
 
 === Bug fixes in 1.16 ===
 

Modified: trunk/phase3/includes/DefaultSettings.php
===================================================================
--- trunk/phase3/includes/DefaultSettings.php   2009-11-30 18:37:30 UTC (rev 
59592)
+++ trunk/phase3/includes/DefaultSettings.php   2009-11-30 18:42:16 UTC (rev 
59593)
@@ -1895,6 +1895,13 @@
 $wgUseTeX = false;
 /** Location of the texvc binary */
 $wgTexvc = './math/texvc';
+/** 
+  * Texvc background color 
+  * use LaTeX color format as used in \special function
+  * for transparent background use value 'Transparent' for alpha transparency 
or
+  * 'transparent' for binary transparency.
+  */
+$wgTexvcBackgroundColor = 'rgb 1.0 1.0 1.0';
 
 /**
  * Normally when generating math images, we double-check that the

Modified: trunk/phase3/includes/Math.php
===================================================================
--- trunk/phase3/includes/Math.php      2009-11-30 18:37:30 UTC (rev 59592)
+++ trunk/phase3/includes/Math.php      2009-11-30 18:42:16 UTC (rev 59593)
@@ -33,7 +33,7 @@
 
        function render() {
                global $wgTmpDirectory, $wgInputEncoding;
-               global $wgTexvc, $wgMathCheckFiles;
+               global $wgTexvc, $wgMathCheckFiles, $wgTexvcBackgroundColor;
                $fname = 'MathRenderer::render';
 
                if( $this->mode == MW_MATH_SOURCE ) {
@@ -63,7 +63,8 @@
                                        escapeshellarg( $wgTmpDirectory ).' '.
                                        escapeshellarg( $wgTmpDirectory ).' '.
                                        escapeshellarg( $this->tex ).' '.
-                                       escapeshellarg( $wgInputEncoding );
+                                       escapeshellarg( $wgInputEncoding ).' '.
+                                       escapeshellarg( $wgTexvcBackgroundColor 
);
 
                        if ( wfIsWindows() ) {
                                # Invoke it within cygwin sh, because texvc 
expects sh features in its default shell

Modified: trunk/phase3/math/README
===================================================================
--- trunk/phase3/math/README    2009-11-30 18:37:30 UTC (rev 59592)
+++ trunk/phase3/math/README    2009-11-30 18:42:16 UTC (rev 59593)
@@ -48,13 +48,13 @@
 
 === Command-line parameters ===
 
-    texvc <temp directory> <output directory> <TeX code> <encoding>
+    texvc <temp directory> <output directory> <TeX code> <encoding> <color>
 
 Be sure to properly quote the TeX code!
 
 Example:
 
-    texvc /home/wiki/tmp /home/wiki/math "y=x+2" iso-8859-1
+    texvc /home/wiki/tmp /home/wiki/math "y=x+2" iso-8859-1 "rgb 1.0 1.0 1.0"
 
 === Output format ===
 

Modified: trunk/phase3/math/render.ml
===================================================================
--- trunk/phase3/math/render.ml 2009-11-30 18:37:30 UTC (rev 59592)
+++ trunk/phase3/math/render.ml 2009-11-30 18:42:16 UTC (rev 59593)
@@ -5,11 +5,11 @@
 (* 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"
+let cmd_dvipng tmpprefix finalpath backcolor = "dvipng -bg \'" ^ backcolor ^ 
"\' -gamma 1.5 -D 120 -T tight --strict " ^ tmpprefix ^ ".dvi -o " ^ finalpath 
^ " >/dev/null 2>/dev/null"
 
 exception ExternalCommandFailure of string
 
-let render tmppath finalpath outtex md5 =
+let render tmppath finalpath outtex md5 backcolor =
     let tmpprefix0 = (string_of_int (Unix.getpid ()))^"_"^md5 in
     let tmpprefix = (tmppath^"/"^tmpprefix0) in
     let unlink_all () =
@@ -30,7 +30,7 @@
        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_dvipng tmpprefix (finalpath^"/"^md5^".png")) 
!= 0)
+       else if (Sys.command (cmd_dvipng tmpprefix (finalpath^"/"^md5^".png") 
backcolor) != 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)

Modified: trunk/phase3/math/texvc.ml
===================================================================
--- trunk/phase3/math/texvc.ml  2009-11-30 18:37:30 UTC (rev 59592)
+++ trunk/phase3/math/texvc.ml  2009-11-30 18:42:16 UTC (rev 59593)
@@ -3,7 +3,7 @@
     try Lexer.token lexbuf
     with Failure s -> raise (LexerException s)
 
-let render tmppath finalpath tree =
+let render tmppath finalpath tree backcolor =
     let outtex = Util.mapjoin Texutil.render_tex tree in
     let md5 = Digest.to_hex (Digest.string outtex) in
     begin
@@ -19,11 +19,11 @@
          | Some h,Html.LIBERAL,Some m -> "L" ^ md5 ^ h ^ "\000" ^ m
          | None,_,Some m -> "X" ^ md5   ^ m
        );
-       Render.render tmppath finalpath outtex md5
+       Render.render tmppath finalpath outtex md5 backcolor
     end
 let _ =
     Texutil.set_encoding (try Sys.argv.(4) with _ -> "UTF-8");
-    try render Sys.argv.(1) Sys.argv.(2) (Parser.tex_expr lexer_token_safe 
(Lexing.from_string Sys.argv.(3)))
+    try render Sys.argv.(1) Sys.argv.(2) (Parser.tex_expr lexer_token_safe 
(Lexing.from_string Sys.argv.(3))) (try Sys.argv.(5) with _ -> "rgb 1.0 1.0 
1.0")
     with Parsing.Parse_error -> print_string "S"
        | LexerException _ -> print_string "E"
        | Texutil.Illegal_tex_function s -> print_string ("F" ^ s)



_______________________________________________
MediaWiki-CVS mailing list
MediaWiki-CVS@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to