Index: trunk/extensions/Math/mathParserTests.txt |
— | — | @@ -98,3 +98,52 @@ |
99 | 99 | <span class="texhtml" dir="ltr">`next' year</span> |
100 | 100 | </p> |
101 | 101 | !! end |
| 102 | + |
| 103 | +!! test |
| 104 | +BUG 6722: Spacing fix for functions in math HTML output |
| 105 | +!! input |
| 106 | +<math>\sin x</math> |
| 107 | +<math>\sin(x)</math> |
| 108 | +<math>\sin{x}</math> |
| 109 | + |
| 110 | +<math>\sin x \,</math> |
| 111 | +<math>\sin(x) \,</math> |
| 112 | +<math>\sin{x} \,</math> |
| 113 | +!!result |
| 114 | +<p><span class="texhtml" dir="ltr">sin <i>x</i></span> |
| 115 | +<span class="texhtml" dir="ltr">sin(<i>x</i>)</span> |
| 116 | +<span class="texhtml" dir="ltr">sin <i>x</i></span> |
| 117 | +</p><p><img class="tex" alt="\sin x \," src="/images/math/7/6/a/76a8e1a01bd233c1e4e16d63b2bbf939.png" /> |
| 118 | +<img class="tex" alt="\sin(x) \," src="/images/math/1/6/c/16c69b0a3658d3b398f72c518d869a03.png" /> |
| 119 | +<img class="tex" alt="\sin{x} \," src="/images/math/8/3/9/839639707da39f691e702c2399cbf943.png" /> |
| 120 | +</p> |
| 121 | +!! end |
| 122 | + |
| 123 | +!! test |
| 124 | +BUG 18912: Add \sen function for Spanish sin to math |
| 125 | +!! input |
| 126 | +<math>\sen x</math> |
| 127 | +<math>\sen(x)</math> |
| 128 | +<math>\sen{x}</math> |
| 129 | + |
| 130 | +<math>\sen x \,</math> |
| 131 | +<math>\sen(x) \,</math> |
| 132 | +<math>\sen{x} \,</math> |
| 133 | +!! result |
| 134 | +<p><span class="texhtml" dir="ltr">sen <i>x</i></span> |
| 135 | +<span class="texhtml" dir="ltr">sen(<i>x</i>)</span> |
| 136 | +<span class="texhtml" dir="ltr">sen <i>x</i></span> |
| 137 | +</p><p><img class="tex" alt="\sen x \," src="/images/math/0/a/c/0ac592b8f31b4698766c50c532f446a7.png" /> |
| 138 | +<img class="tex" alt="\sen(x) \," src="/images/math/b/b/5/bb5469d24fcdd52aa60cb9ee90ba697d.png" /> |
| 139 | +<img class="tex" alt="\sen{x} \," src="/images/math/d/4/8/d4882a4bcf5db1da3e30d905da8b394e.png" /> |
| 140 | +</p> |
| 141 | +!! end |
| 142 | + |
| 143 | +!! test |
| 144 | +BUG 18912: \operatorname{sen} x gets wrong spacing in math |
| 145 | +!! input |
| 146 | +<math>\operatorname{sen}</math> |
| 147 | +!! result |
| 148 | +<p><img class="tex" alt="\operatorname{sen}" src="/images/math/3/e/7/3e71e75d9aac1bf5107271ad89ca7c3b.png" /> |
| 149 | +</p> |
| 150 | +!! end |
Index: trunk/extensions/Math/math/lexer.mll |
— | — | @@ -13,6 +13,8 @@ |
14 | 14 | let delimiter_uf_op = ['/' '|'] |
15 | 15 | let boxchars = ['0'-'9' 'a'-'z' 'A'-'Z' '+' '-' '*' ',' '=' '(' ')' ':' '/' ';' '?' '.' '!' '\'' '`' ' ' '\128'-'\255'] |
16 | 16 | let aboxchars = ['0'-'9' 'a'-'z' 'A'-'Z' '+' '-' '*' ',' '=' '(' ')' ':' '/' ';' '?' '.' '!' '\'' '`' ' '] |
| 17 | +let latex_function_names = "arccos" | "arcsin" | "arctan" | "arg" | "cos" | "cosh" | "cot" | "coth" | "csc"| "deg" | "det" | "dim" | "exp" | "gcd" | "hom" | "inf" | "ker" | "lg" | "lim" | "liminf" | "limsup" | "ln" | "log" | "max" | "min" | "Pr" | "sec" | "sin" | "sinh" | "sup" | "tan" | "tanh" |
| 18 | +let mediawiki_function_names = "arccot" | "arcsec" | "arccsc" | "sgn" | "sen" |
17 | 19 | |
18 | 20 | rule token = parse |
19 | 21 | space + { token lexbuf } |
— | — | @@ -54,10 +56,18 @@ |
55 | 57 | | "-" { let str = Lexing.lexeme lexbuf in LITERAL (MHTMLABLEC (FONT_UFH,"-"," − ",MO,str))} |
56 | 58 | | literal_uf_op { let str = Lexing.lexeme lexbuf in LITERAL (MHTMLABLEC (FONT_UFH, str," "^str^" ",MO,str)) } |
57 | 59 | | delimiter_uf_op { let str = Lexing.lexeme lexbuf in DELIMITER (MHTMLABLEC (FONT_UFH, str," "^str^" ",MO,str)) } |
58 | | - | "\\" alpha + { Texutil.find (Lexing.lexeme lexbuf) } |
59 | 60 | | "\\sqrt" space * "[" { FUN_AR1opt "\\sqrt" } |
60 | 61 | | "\\xleftarrow" space * "[" { Texutil.tex_use_ams(); FUN_AR1opt "\\xleftarrow" } |
61 | 62 | | "\\xrightarrow" space * "[" { Texutil.tex_use_ams(); FUN_AR1opt "\\xrightarrow" } |
| 63 | + | "\\" (latex_function_names as name) space * "(" { LITERAL (HTMLABLEC(FONT_UFH,"\\" ^ name ^ "(", name ^ "(")) } |
| 64 | + | "\\" (latex_function_names as name) space * "[" { LITERAL (HTMLABLEC(FONT_UFH,"\\" ^ name ^ "[", name ^ "[")) } |
| 65 | + | "\\" (latex_function_names as name) space * "\\{" { LITERAL (HTMLABLEC(FONT_UFH,"\\" ^ name ^ "\\{", name ^ "{")) } |
| 66 | + | "\\" (latex_function_names as name) space * { LITERAL (HTMLABLEC(FONT_UFH,"\\" ^ name ^ " ", name ^ " ")) } |
| 67 | + | "\\" (mediawiki_function_names as name) space * "(" { (Texutil.tex_use_ams(); LITERAL (HTMLABLEC(FONT_UFH,"\\operatorname{" ^ name ^ "}(", name^ "("))) } |
| 68 | + | "\\" (mediawiki_function_names as name) space * "[" { (Texutil.tex_use_ams(); LITERAL (HTMLABLEC(FONT_UFH,"\\operatorname{" ^ name ^ "}[", name^ "["))) } |
| 69 | + | "\\" (mediawiki_function_names as name) space * "\\{" { (Texutil.tex_use_ams(); LITERAL (HTMLABLEC(FONT_UFH,"\\operatorname{" ^ name ^ "}\\{", name^ "{"))) } |
| 70 | + | "\\" (mediawiki_function_names as name) space * { (Texutil.tex_use_ams(); LITERAL (HTMLABLEC(FONT_UFH,"\\operatorname{" ^ name ^ "} ", name ^ " "))) } |
| 71 | + | "\\" alpha + { Texutil.find (Lexing.lexeme lexbuf) } |
62 | 72 | | "\\," { LITERAL (HTMLABLE (FONT_UF, "\\,"," ")) } |
63 | 73 | | "\\ " { LITERAL (HTMLABLE (FONT_UF, "\\ "," ")) } |
64 | 74 | | "\\;" { LITERAL (HTMLABLE (FONT_UF, "\\;"," ")) } |
Index: trunk/extensions/Math/math/texutil.ml |
— | — | @@ -20,7 +20,7 @@ |
21 | 21 | | TEX_DQN (a) -> "_{" ^ (render_tex a) ^ "}" |
22 | 22 | | TEX_UQN (a) -> "^{" ^ (render_tex a) ^ "}" |
23 | 23 | | TEX_LITERAL s -> tex_part s |
24 | | - | TEX_FUN1 (f,a) -> "{" ^ f ^ " " ^ (render_tex a) ^ "}" |
| 24 | + | TEX_FUN1 (f,a) -> f ^ " " ^ (render_tex a) |
25 | 25 | | TEX_FUN1hl (f,_,a) -> "{" ^ f ^ " " ^ (render_tex a) ^ "}" |
26 | 26 | | TEX_FUN1hf (f,_,a) -> "{" ^ f ^ " " ^ (render_tex a) ^ "}" |
27 | 27 | | TEX_DECLh (f,_,a) -> "{" ^ f ^ "{" ^ (mapjoin render_tex a) ^ "}}" |
— | — | @@ -248,16 +248,6 @@ |
249 | 249 | | "\\triangleleft" -> LITERAL (TEX_ONLY "\\triangleleft ") |
250 | 250 | | "\\triangleright" -> LITERAL (TEX_ONLY "\\triangleright ") |
251 | 251 | | "\\textvisiblespace" -> LITERAL (TEX_ONLY "\\textvisiblespace ") |
252 | | - | "\\ker" -> LITERAL (HTMLABLEC(FONT_UFH,"\\ker ","ker")) |
253 | | - | "\\lim" -> LITERAL (TEX_ONLY "\\lim ") |
254 | | - | "\\limsup" -> LITERAL (TEX_ONLY "\\limsup ") |
255 | | - | "\\liminf" -> LITERAL (TEX_ONLY "\\liminf ") |
256 | | - | "\\sup" -> LITERAL (TEX_ONLY "\\sup ") |
257 | | - | "\\Pr" -> LITERAL (TEX_ONLY "\\Pr ") |
258 | | - | "\\hom" -> LITERAL (HTMLABLEC(FONT_UFH,"\\hom ","hom")) |
259 | | - | "\\arg" -> LITERAL (HTMLABLEC(FONT_UFH,"\\arg ","arg")) |
260 | | - | "\\dim" -> LITERAL (HTMLABLEC(FONT_UFH,"\\dim ","dim")) |
261 | | - | "\\inf" -> LITERAL (TEX_ONLY "\\inf ") |
262 | 252 | | "\\circ" -> LITERAL (TEX_ONLY "\\circ ") |
263 | 253 | | "\\hbar" -> LITERAL (TEX_ONLY "\\hbar ") |
264 | 254 | | "\\imath" -> LITERAL (TEX_ONLY "\\imath ") |
— | — | @@ -278,32 +268,6 @@ |
279 | 269 | | "\\limits" -> LITERAL (TEX_ONLY "\\limits ") |
280 | 270 | | "\\nolimits" -> LITERAL (TEX_ONLY "\\nolimits ") |
281 | 271 | | "\\top" -> LITERAL (TEX_ONLY "\\top ") |
282 | | - | "\\sin" -> LITERAL (HTMLABLEC(FONT_UFH,"\\sin ","sin")) |
283 | | - | "\\cos" -> LITERAL (HTMLABLEC(FONT_UFH,"\\cos ","cos")) |
284 | | - | "\\sinh" -> LITERAL (HTMLABLEC(FONT_UFH,"\\sinh ","sinh")) |
285 | | - | "\\cosh" -> LITERAL (HTMLABLEC(FONT_UFH,"\\cosh ","cosh")) |
286 | | - | "\\tan" -> LITERAL (HTMLABLEC(FONT_UFH,"\\tan ","tan")) |
287 | | - | "\\tanh" -> LITERAL (HTMLABLEC(FONT_UFH,"\\tanh ","tanh")) |
288 | | - | "\\sec" -> LITERAL (HTMLABLEC(FONT_UFH,"\\sec ","sec")) |
289 | | - | "\\csc" -> LITERAL (HTMLABLEC(FONT_UFH,"\\csc ","csc")) |
290 | | - | "\\arcsin" -> LITERAL (HTMLABLEC(FONT_UFH,"\\arcsin ","arcsin")) |
291 | | - | "\\arctan" -> LITERAL (HTMLABLEC(FONT_UFH,"\\arctan ","arctan")) |
292 | | - | "\\arccos" -> (tex_use_ams (); LITERAL (HTMLABLEC(FONT_UFH,"\\mathop{\\mathrm{arccos}}","arccos"))) |
293 | | - | "\\arccot" -> (tex_use_ams (); LITERAL (HTMLABLEC(FONT_UFH,"\\mathop{\\mathrm{arccot}}","arccot"))) |
294 | | - | "\\arcsec" -> (tex_use_ams (); LITERAL (HTMLABLEC(FONT_UFH,"\\mathop{\\mathrm{arcsec}}","arcsec"))) |
295 | | - | "\\arccsc" -> (tex_use_ams (); LITERAL (HTMLABLEC(FONT_UFH,"\\mathop{\\mathrm{arccsc}}","arccsc"))) |
296 | | - | "\\sgn" -> (tex_use_ams (); LITERAL (HTMLABLEC(FONT_UFH,"\\mathop{\\mathrm{sgn}}","sgn"))) |
297 | | - | "\\cot" -> LITERAL (HTMLABLEC(FONT_UFH,"\\cot ","cot")) |
298 | | - | "\\coth" -> LITERAL (HTMLABLEC(FONT_UFH,"\\coth ","coth")) |
299 | | - | "\\log" -> LITERAL (HTMLABLEC(FONT_UFH,"\\log ", "log")) |
300 | | - | "\\lg" -> LITERAL (HTMLABLEC(FONT_UFH,"\\lg ", "lg")) |
301 | | - | "\\ln" -> LITERAL (HTMLABLEC(FONT_UFH,"\\ln ", "ln")) |
302 | | - | "\\exp" -> LITERAL (HTMLABLEC(FONT_UFH,"\\exp ", "exp")) |
303 | | - | "\\min" -> LITERAL (HTMLABLEC(FONT_UFH,"\\min ", "min")) |
304 | | - | "\\max" -> LITERAL (HTMLABLEC(FONT_UFH,"\\max ", "max")) |
305 | | - | "\\gcd" -> LITERAL (HTMLABLEC(FONT_UFH,"\\gcd ", "gcd")) |
306 | | - | "\\deg" -> LITERAL (HTMLABLEC(FONT_UFH,"\\deg ", "deg")) |
307 | | - | "\\det" -> LITERAL (HTMLABLEC(FONT_UFH,"\\det ", "det")) |
308 | 272 | | "\\bullet" -> LITERAL (HTMLABLE (FONT_UFH, "\\bullet ", "•")) |
309 | 273 | | "\\bull" -> LITERAL (HTMLABLE (FONT_UFH, "\\bullet ", "•")) |
310 | 274 | | "\\angle" -> (tex_use_ams (); LITERAL (HTMLABLE (FONT_UF, "\\angle ", "∠"))) |