http://www.mediawiki.org/wiki/Special:Code/MediaWiki/99741
Revision: 99741
Author: thenub314
Date: 2011-10-13 23:04:41 +0000 (Thu, 13 Oct 2011)
Log Message:
-----------
The following patches restore how texvc added braces for all commands
but \operatorname to fix Bug 31442. More specifically, TEX_FUN1 now
adds braces as it did in previous versions. The result is texvc will
once again correctly sanitize multiple math accents even when no braces are
given (e.g. \dot \vec B) and it will allow math accents to be used with
symbols whose font as been changed (e.g. \tilde \mathcal{M}). Parser
tests are created to ensure these continue to work.
The handling of \operatorname is now handled specially by the
function TEX_FUN1nb (nb stands for no braces and the name is taken to
be consistent with the existing function TEX_FUN2nb). The addition of
braces causes this command to LaTeX incorrectly. The parser test for
\operatorname has been updated to reflect the fact the hash of the
images involved has changed.
Modified Paths:
--------------
trunk/extensions/Math/math/html.ml
trunk/extensions/Math/math/lexer.mll
trunk/extensions/Math/math/parser.mly
trunk/extensions/Math/math/tex.mli
trunk/extensions/Math/math/texutil.ml
trunk/extensions/Math/mathParserTests.txt
Modified: trunk/extensions/Math/math/html.ml
===================================================================
--- trunk/extensions/Math/math/html.ml 2011-10-13 22:37:50 UTC (rev 99740)
+++ trunk/extensions/Math/math/html.ml 2011-10-13 23:04:41 UTC (rev 99741)
@@ -56,6 +56,7 @@
| TEX_BOX (_,s)::r -> s^html_render_flat ctx r
| TEX_LITERAL (TEX_ONLY _)::_ -> raise Too_difficult_for_html
| TEX_FUN1 _::_ -> raise Too_difficult_for_html
+ | TEX_FUN1nb _::_ -> raise Too_difficult_for_html
| TEX_FUN2 _::_ -> raise Too_difficult_for_html
| TEX_FUN2nb _::_ -> raise Too_difficult_for_html
| TEX_FUN2h _::_ -> raise Too_difficult_for_html
Modified: trunk/extensions/Math/math/lexer.mll
===================================================================
--- trunk/extensions/Math/math/lexer.mll 2011-10-13 22:37:50 UTC (rev
99740)
+++ trunk/extensions/Math/math/lexer.mll 2011-10-13 23:04:41 UTC (rev
99741)
@@ -56,6 +56,7 @@
| "-" { let str = Lexing.lexeme lexbuf in
LITERAL (MHTMLABLEC (FONT_UFH,"-"," − ",MO,str))}
| literal_uf_op { let str = Lexing.lexeme lexbuf in LITERAL
(MHTMLABLEC (FONT_UFH, str," "^str^" ",MO,str)) }
| delimiter_uf_op { let str = Lexing.lexeme lexbuf in DELIMITER
(MHTMLABLEC (FONT_UFH, str," "^str^" ",MO,str)) }
+ | "\\operatorname" { Texutil.tex_use_ams(); FUN_AR1nb
"\\operatorname" }
| "\\sqrt" space * "[" { FUN_AR1opt "\\sqrt" }
| "\\xleftarrow" space * "[" { Texutil.tex_use_ams(); FUN_AR1opt
"\\xleftarrow" }
| "\\xrightarrow" space * "[" { Texutil.tex_use_ams(); FUN_AR1opt
"\\xrightarrow" }
Modified: trunk/extensions/Math/math/parser.mly
===================================================================
--- trunk/extensions/Math/math/parser.mly 2011-10-13 22:37:50 UTC (rev
99740)
+++ trunk/extensions/Math/math/parser.mly 2011-10-13 23:04:41 UTC (rev
99741)
@@ -5,7 +5,7 @@
let sq_close_ri = HTMLABLEC(FONT_UFH,"]", "]")
%}
%token <Render_info.t> LITERAL DELIMITER
-%token <string> FUN_AR2 FUN_INFIX FUN_AR1 DECL FUN_AR1opt BIG FUN_AR2nb
+%token <string> FUN_AR2 FUN_INFIX FUN_AR1 DECL FUN_AR1nb FUN_AR1opt BIG
FUN_AR2nb
%token <string*string> BOX
%token <string*(string*string)> FUN_AR1hl
%token <string*Render_info.font_force> FUN_AR1hf DECLh
@@ -85,6 +85,7 @@
| BIG SQ_CLOSE { TEX_BIG ($1,sq_close_ri) }
| left expr right { TEX_LR ($1,$3,$2) }
| FUN_AR1 lit { TEX_FUN1($1,$2) }
+ | FUN_AR1nb lit { TEX_FUN1nb($1,$2) }
| FUN_AR1hl lit { let t,h=$1 in TEX_FUN1hl(t,h,$2) }
| FUN_AR1hf lit { let t,h=$1 in TEX_FUN1hf(t,h,$2) }
| FUN_AR1opt expr_nosqc SQ_CLOSE lit { TEX_FUN2sq($1,TEX_CURLY $2,$4) }
Modified: trunk/extensions/Math/math/tex.mli
===================================================================
--- trunk/extensions/Math/math/tex.mli 2011-10-13 22:37:50 UTC (rev 99740)
+++ trunk/extensions/Math/math/tex.mli 2011-10-13 23:04:41 UTC (rev 99741)
@@ -11,6 +11,7 @@
| TEX_BOX of string * string
| TEX_BIG of string * Render_info.t
| TEX_FUN1 of string * t
+ | TEX_FUN1nb of string * t
| TEX_FUN2 of string * t * t
| TEX_FUN2nb of string * t * t
| TEX_INFIX of string * t list * t list
Modified: trunk/extensions/Math/math/texutil.ml
===================================================================
--- trunk/extensions/Math/math/texutil.ml 2011-10-13 22:37:50 UTC (rev
99740)
+++ trunk/extensions/Math/math/texutil.ml 2011-10-13 23:04:41 UTC (rev
99741)
@@ -20,7 +20,8 @@
| TEX_DQN (a) -> "_{" ^ (render_tex a) ^ "}"
| TEX_UQN (a) -> "^{" ^ (render_tex a) ^ "}"
| TEX_LITERAL s -> tex_part s
- | TEX_FUN1 (f,a) -> f ^ " " ^ (render_tex a)
+ | TEX_FUN1 (f,a) -> "{" ^ f ^ " " ^ (render_tex a) ^ "}"
+ | TEX_FUN1nb (f,a) -> f ^ " " ^ (render_tex a)
| TEX_FUN1hl (f,_,a) -> "{" ^ f ^ " " ^ (render_tex a) ^ "}"
| TEX_FUN1hf (f,_,a) -> "{" ^ f ^ " " ^ (render_tex a) ^ "}"
| TEX_DECLh (f,_,a) -> "{" ^ f ^ "{" ^ (mapjoin render_tex a) ^ "}}"
Modified: trunk/extensions/Math/mathParserTests.txt
===================================================================
--- trunk/extensions/Math/mathParserTests.txt 2011-10-13 22:37:50 UTC (rev
99740)
+++ trunk/extensions/Math/mathParserTests.txt 2011-10-13 23:04:41 UTC (rev
99741)
@@ -144,6 +144,24 @@
!! input
<math>\operatorname{sen}</math>
!! result
-<p><img class="tex" alt="\operatorname{sen}"
src="/images/math/3/e/7/3e71e75d9aac1bf5107271ad89ca7c3b.png" />
+<p><img class="tex" alt="\operatorname{sen}"
src="/images/math/f/a/9/fa9660c7eb053ca8d3c9a87fa86635d9.png" />
</p>
!! end
+
+!! test
+BUG 31442: Multiple math accents without braces fails to parse
+!! input
+<math>\dot \vec B</math>
+!! result
+<p><img class="tex" alt="\dot \vec B"
src="/images/math/e/6/4/e64939568ecb506a86a392373cec0458.png" />
+</p>
+!! end
+
+!! test
+BUG 31442: Math accents with math font fail to parse if braces not used
+!! input
+<math>\tilde \mathcal{M}</math>
+!! result
+<p><img class="tex" alt="\tilde \mathcal{M}"
src="/images/math/5/5/0/55072ce6ef8c840c4b7687bd8a028bde.png" />
+</p>
+!! end
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs