The following changes enhance the way texvc handles space around

mathematical function names when translating to HTML; adds support for
the sen, the Spanish name for sin; and corrects a bug that eliminates
spacing around \operatorname{...} in the resulting png.  More
specifically, texvc now dectect whether or not a
standard function such as is followed by a delimitier such as (, {, [
etc. and adds a space or not as appropriate.  This issue  The code has been
reorganized to include a list of standard LaTeX commands whose spacing
rules are the same, and treates them all on an equal footing.  It
similarly treats functions defined for mediawiki in the same way it
treats standard latex functions. One addition function is added, \sen,
and others can be added easily if necessary.  Finally LaTeX generated
by texvc contained to many braces which altered the spacing created by
the command \operatorname, this has now been corrected.  These last
two changes address the issues raised in bug 18912 and the chaning in
translation to HTML address most, but not all, of the issues raised in
bug 6722 .
This commit is contained in:
Nicholas Longo 2011-04-26 18:17:23 +00:00
parent db1c6b4477
commit dbe0a339de
2 changed files with 11 additions and 1 deletions

View File

@ -13,6 +13,8 @@ let literal_uf_op = ['+' '-' '*' '=']
let delimiter_uf_op = ['/' '|']
let boxchars = ['0'-'9' 'a'-'z' 'A'-'Z' '+' '-' '*' ',' '=' '(' ')' ':' '/' ';' '?' '.' '!' ' ' '\128'-'\255']
let aboxchars = ['0'-'9' 'a'-'z' 'A'-'Z' '+' '-' '*' ',' '=' '(' ')' ':' '/' ';' '?' '.' '!' ' ']
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"
let mediawiki_function_names = "arccot" | "arcsec" | "arccsc" | "sgn" | "sen"
rule token = parse
space + { token lexbuf }
@ -58,6 +60,14 @@ rule token = parse
| "\\sqrt" space * "[" { FUN_AR1opt "\\sqrt" }
| "\\xleftarrow" space * "[" { Texutil.tex_use_ams(); FUN_AR1opt "\\xleftarrow" }
| "\\xrightarrow" space * "[" { Texutil.tex_use_ams(); FUN_AR1opt "\\xrightarrow" }
| "\\" (latex_function_names as name) space * "(" { LITERAL (HTMLABLEC(FONT_UFH,"\\" ^ name ^ "(", name ^ "(")) }
| "\\" (latex_function_names as name) space * "[" { LITERAL (HTMLABLEC(FONT_UFH,"\\" ^ name ^ "[", name ^ "[")) }
| "\\" (latex_function_names as name) space * "\\{" { LITERAL (HTMLABLEC(FONT_UFH,"\\" ^ name ^ "\\{", name ^ "{")) }
| "\\" (latex_function_names as name) space * { LITERAL (HTMLABLEC(FONT_UFH,"\\" ^ name, name ^ " ")) }
| "\\" (mediawiki_function_names as name) space * "(" { (Texutil.tex_use_ams(); LITERAL (HTMLABLEC(FONT_UFH,"\\operatorname{" ^ name ^ "}(", name^ "("))) }
| "\\" (mediawiki_function_names as name) space * "[" { (Texutil.tex_use_ams(); LITERAL (HTMLABLEC(FONT_UFH,"\\operatorname{" ^ name ^ "}[", name^ "["))) }
| "\\" (mediawiki_function_names as name) space * "\\{" { (Texutil.tex_use_ams(); LITERAL (HTMLABLEC(FONT_UFH,"\\operatorname{" ^ name ^ "}\\{", name^ "{"))) }
| "\\" (mediawiki_function_names as name) space * { (Texutil.tex_use_ams(); LITERAL (HTMLABLEC(FONT_UFH,"\\operatorname{" ^ name ^ "}", name ^ " "))) }
| "\\," { LITERAL (HTMLABLE (FONT_UF, "\\,"," ")) }
| "\\ " { LITERAL (HTMLABLE (FONT_UF, "\\ "," ")) }
| "\\;" { LITERAL (HTMLABLE (FONT_UF, "\\;"," ")) }

View File

@ -20,7 +20,7 @@ let rec render_tex = function
| 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_FUN1hl (f,_,a) -> "{" ^ f ^ " " ^ (render_tex a) ^ "}"
| TEX_FUN1hf (f,_,a) -> "{" ^ f ^ " " ^ (render_tex a) ^ "}"
| TEX_DECLh (f,_,a) -> "{" ^ f ^ "{" ^ (mapjoin render_tex a) ^ "}}"