r96990 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r96989‎ | r96990 | r96991 >
Date:19:00, 13 September 2011
Author:brion
Status:ok (Comments)
Tags:
Comment:
Revert changes to texvc that provide no test cases or examples of what they're fixing: r86962, r86965, r87092, r87117, r87284, r87298, r87934, r87936, r87941, r88030, r88260

While these mostly look like they seem to do what they claim, *none* of them provide any test cases.
Most don't even include an example in the commit messages.
Modified paths:
  • /trunk/extensions/Math/math/html.ml (modified) (history)
  • /trunk/extensions/Math/math/lexer.mll (modified) (history)
  • /trunk/extensions/Math/math/mathml.ml (modified) (history)
  • /trunk/extensions/Math/math/parser.mly (modified) (history)
  • /trunk/extensions/Math/math/render_info.mli (modified) (history)
  • /trunk/extensions/Math/math/texutil.ml (modified) (history)
  • /trunk/extensions/ParserPlayground/modules/ext.parserPlayground.pegParser.js (modified) (history)
  • /trunk/extensions/ParserPlayground/modules/mediawiki.parser.environment.js (modified) (history)
  • /trunk/extensions/ParserPlayground/modules/pegParser.pegjs.txt (modified) (history)

Diff [purge]

Index: trunk/extensions/ParserPlayground/modules/ext.parserPlayground.pegParser.js
@@ -9,8 +9,8 @@
1010 * to point at the MW page name containing the parser peg definition; default
1111 * is 'MediaWiki:Gadget-ParserPlayground-PegParser.pegjs'.
1212 */
13 -function PegParser(options) {
14 - this.options = options;
 13+function PegParser(env) {
 14+ this.env = env || {};
1515 }
1616
1717 PegParser.src = false;
@@ -34,8 +34,58 @@
3535 * @param {function(tree, error)} callback
3636 */
3737 PegParser.prototype.expandTree = function(tree, callback) {
38 - // no-op!
39 - callback(tree, null);
 38+ var self = this;
 39+ var subParseArray = function(listOfTrees) {
 40+ var content = [];
 41+ $.each(listOfTrees, function(i, subtree) {
 42+ self.expandTree(subtree, function(substr, err) {
 43+ content.push(tree);
 44+ });
 45+ });
 46+ return content;
 47+ };
 48+ var src;
 49+ if (typeof tree === "string") {
 50+ callback(tree);
 51+ return;
 52+ }
 53+ if (tree.type == 'template') {
 54+ // expand a template node!
 55+
 56+ // Resolve a possibly relative link
 57+ var templateName = this.env.resolveTitle( tree.target, 'Template' );
 58+ this.env.fetchTemplate( tree.target, tree.params || {}, function( templateSrc, error ) {
 59+ // @fixme should pre-parse/cache these too?
 60+ self.parseToTree( templateSrc, function( templateTree, error ) {
 61+ if ( error ) {
 62+ callback({
 63+ type: 'placeholder',
 64+ orig: tree,
 65+ content: [
 66+ {
 67+ // @fixme broken link?
 68+ type: 'link',
 69+ target: templateName
 70+ }
 71+ ]
 72+ });
 73+ } else {
 74+ callback({
 75+ type: 'placeholder',
 76+ orig: tree,
 77+ content: self.env.expandTemplateArgs( templateTree, tree.params )
 78+ });
 79+ }
 80+ })
 81+ } );
 82+ // Wait for async...
 83+ return;
 84+ }
 85+ var out = $.extend( tree ); // @fixme prefer a deep copy?
 86+ if (tree.content) {
 87+ out.content = subParseArray(tree.content);
 88+ }
 89+ callback(out);
4090 };
4191
4292 PegParser.prototype.initSource = function(callback) {
Index: trunk/extensions/ParserPlayground/modules/mediawiki.parser.environment.js
@@ -1,7 +1,8 @@
22 var MWParserEnvironment = function(opts) {
33 var options = {
44 tagHooks: {},
5 - parserFunctions: {}
 5+ parserFunctions: {},
 6+ pageCache: {} // @fixme use something with managed space
67 };
78 $.extend(options, opts);
89 this.tagHooks = options.tagHooks;
@@ -38,12 +39,323 @@
3940 } else {
4041 return null;
4142 }
 43+ },
 44+
 45+ /**
 46+ * @fixme do this for real eh
 47+ */
 48+ resolveTitle: function( name, namespace ) {
 49+ // hack!
 50+ if (name.indexOf(':') == 0 && typeof namespace ) {
 51+ // hack hack hack
 52+ name = namespace + ':' + name;
 53+ }
 54+ return name;
 55+ },
 56+
 57+ /**
 58+ * Async.
 59+ *
 60+ * @todo make some optimizations for fetching multiple at once
 61+ *
 62+ * @param string name
 63+ * @param function(text, err) callback
 64+ */
 65+ fetchTemplate: function( title, callback ) {
 66+ this.fetchTemplateAndTitle( title, function( text, title, err ) {
 67+ callback(title, err);
 68+ });
 69+ },
 70+
 71+ fetchTemplateAndTitle: function( title, callback ) {
 72+ // @fixme normalize name?
 73+ if (title in this.pageCache) {
 74+ // @fixme should this be forced to run on next event?
 75+ callback( this.pageCache[title] );
 76+ } else {
 77+ // whee fun hack!
 78+ $.ajax({
 79+ url: wgScriptPath + '/api' + wgScriptExtension,
 80+ data: {
 81+ format: 'json',
 82+ action: 'query',
 83+ prop: 'revisions',
 84+ rvprop: 'content',
 85+ titles: name
 86+ },
 87+ success: function(data, xhr) {
 88+ var src = null, title = null;
 89+ $.each(data.query.pages, function(i, page) {
 90+ if (page.revisions && page.revisions.length) {
 91+ src = page.revisions[0]['*'];
 92+ title = page.title;
 93+ }
 94+ });
 95+ if (typeof src !== 'string') {
 96+ callback(null, null, 'Page not found');
 97+ } else {
 98+ callback(src, title);
 99+ }
 100+ },
 101+ error: function(msg) {
 102+ callback(null, null, 'Page/template fetch failure');
 103+ },
 104+ dataType: 'json',
 105+ cache: false // @fixme caching, versions etc?
 106+ }, 'json');
 107+ }
 108+ },
 109+
 110+ getTemplateDom: function( title, callback ) {
 111+ var self = this;
 112+ this.fetchTemplateAndTitle( title, function( text, title, err ) {
 113+ if (err) {
 114+ callback(null, err);
 115+ return;
 116+ }
 117+ self.pageCache[title] = text;
 118+ self.parser.parseToTree( text, function( templateTree, err ) {
 119+ // @fixme cache these too :)
 120+ callback(templateTree, err);
 121+ });
 122+ });
 123+ },
 124+
 125+ braceSubstitution: function( templateNode, frame, callback ) {
 126+ // stuff in Parser.braceSubstitution
 127+ // expand/flatten the 'title' piece (to get the template reference)
 128+ frame.flatten(templateNode.name, function(templateName, err) {
 129+ if (err) {
 130+ callback(null, err);
 131+ return;
 132+ }
 133+ var out = {
 134+ type: 'placeholder',
 135+ orig: templateNode,
 136+ contents: []
 137+ };
 138+
 139+ // check for 'subst:'
 140+ // check for variable magic names
 141+ // check for msg, msgnw, raw magics
 142+ // check for parser functions
 143+
 144+ // resolve template name
 145+ // load template w/ canonical name
 146+ // load template w/ variant names
 147+ // recursion depth check
 148+ // fetch from DB or interwiki
 149+ // infinte loop check
 150+ this.getTemplateDom(templateName, function(dom, err) {
 151+ // Expand in-place!
 152+ var templateFrame = frame.newChild(templateName.params || []);
 153+ templateFrame.expand(dom, 0, function(expandedTemplateNode) {
 154+ out.contents = expandedTemplateNode.contents;
 155+ callback(out);
 156+ return; // done
 157+ });
 158+ return; // wait for async
 159+ });
 160+ });
 161+ },
 162+
 163+ argSubstitution: function( argNode, frame, callback ) {
 164+ frame.flatten(argNode.name, function(argName, err) {
 165+ if (err) {
 166+ callback(null, err);
 167+ return;
 168+ }
 169+
 170+ var arg = frame.getArgument(argName);
 171+ if (arg === false && 'params' in argNode && argNode.params.length) {
 172+ // No match in frame, use the supplied default
 173+ arg = argNode.params[0].val;
 174+ }
 175+ var out = {
 176+ type: 'placeholder',
 177+ orig: argNode,
 178+ contents: [arg]
 179+ };
 180+ callback(out);
 181+ });
42182 }
43 -
 183+
 184+
44185 });
45186
 187+function PPFrame(env) {
 188+ this.env = env;
 189+ this.loopCheckHash = [];
 190+ this.depth = 0;
 191+}
46192
 193+// Flag constants
 194+$.extend(PPFrame, {
 195+ NO_ARGS: 1,
 196+ NO_TEMPLATES: 2,
 197+ STRIP_COMMENTS: 4,
 198+ NO_IGNORE: 8,
 199+ RECOVER_COMMENTS: 16
 200+});
 201+PPFrame.RECOVER_ORIG = PPFrame.NO_ARGS
 202+ | PPFrame.NO_TEMPLATES
 203+ | PPFrame.STRIP_COMMENTS
 204+ | PPFrame.NO_IGNORE
 205+ | PPFrame.RECOVER_COMMENTS;
47206
 207+$.extend(PPFrame.prototype, {
 208+ newChild: function(args, title) {
 209+ //
 210+ },
 211+
 212+ /**
 213+ * Using simple recursion for now -- PHP version is a little fancier
 214+ * @param {object} tree
 215+ * @param {number} flags
 216+ * @param {function(tree, error)} callback
 217+ */
 218+ expand: function(root, flags, callback) {
 219+ var self = this,
 220+ expansionDepth = 0,
 221+ outStack = [Array(), Array()],
 222+ iteratorStack = [false, root],
 223+ indexStack = [0, 0],
 224+ contextNode = false,
 225+ newIterator = false;
 226+
 227+ var iteration = function() {
 228+ var level = outStack.length - 1,
 229+ iteratorNode = iteratorStack[level],
 230+ out = outStack[level],
 231+ index = indexStack[level]; // ????
 232+
 233+ if ($.isArray(iteratorNode)) {
 234+ if (index >= iteratorNode.length) {
 235+ // All done with this iterator.
 236+ iteratorStack[level] = false;
 237+ contextNode = false;
 238+ } else {
 239+ contextNode = iteratorNode[index];
 240+ indexStack[level]++;
 241+ }
 242+ } else {
 243+ // Copy to contextNode and then delete from iterator stack,
 244+ // because this is not an iterator but we do have to execute it once
 245+ contextNode = iteratorStack[level];
 246+ iteratorStack[level] = false;
 247+ }
 248+
 249+ if (contextNode === false) {
 250+ // nothing to do
 251+ } else if (typeof contextNode === 'string') {
 252+ out.push(contextNode);
 253+ } else if (contextNode.type === 'template') {
 254+ // Double-brace expansion
 255+ self.env.braceSubstitution(contextNode, self, function(replacementNode, err) {
 256+ out.push(replacementNode);
 257+ // ... and continue on the next node!
 258+ iteration();
 259+ });
 260+ } else if (contextNode.type == 'tplarg') {
 261+ // Triple-brace expansion
 262+ self.env.argSubstitution(contextNode, self, function(replacementNode, err) {
 263+ out.push(replacementNode);
 264+ // ... and continue on the next node!
 265+ iteration();
 266+ });
 267+ } else if (contextNode.type === 'comment') {
 268+ // HTML-style comment
 269+ } else if (contextNode.type === 'ignore') {
 270+ //
 271+ } else if (contextNode.type === 'ext') {
 272+ //
 273+ } else if (contextNode.type === 'h') {
 274+ //
 275+ } else {
 276+ if ('content' in contextNode) {
 277+ newIterator = contextNode.content;
 278+ }
 279+ }
 280+
 281+ if (newIterator !== false) {
 282+ outStack.push([]);
 283+ iteratorStack.push(newIterator);
 284+ indexStack.push(0);
 285+ } else if ( iteratorStack[level] === false) {
 286+ // Return accumulated value to parent
 287+ // With tail recursion
 288+ while (iteratorStack[level] === false && level > 0) {
 289+ outStack[level - 1];
 290+ }
 291+ }
 292+ };
 293+ iteration();
 294+
 295+ if (typeof tree === "string") {
 296+ callback(tree);
 297+ return;
 298+ }
 299+ if (tree.type == 'template') {
 300+ // expand a template node!
 301+ // Resolve a possibly relative link
 302+ }
 303+ if (tree.type == 'tplarg') {
 304+
 305+ }
 306+ var out = $.extend( tree ); // @fixme prefer a deep copy?
 307+ if (tree.content) {
 308+ out.content = subParseArray(tree.content);
 309+ }
 310+ callback(out);
 311+ },
 312+
 313+ implodeWithFlags: function(sep, flags) {
 314+
 315+ },
 316+
 317+ implode: function(sep) {
 318+
 319+ },
 320+
 321+ virtualImport: function(sep) {
 322+
 323+ },
 324+
 325+ virtualBracketedImplode: function(start, sep, end /*, ... */ ) {
 326+
 327+ },
 328+
 329+ isEmpty: function() {
 330+
 331+ },
 332+
 333+ getArguments: function() {
 334+
 335+ },
 336+
 337+ getNumberedArguments: function() {
 338+
 339+ },
 340+
 341+ getNamedArguments: function() {
 342+
 343+ },
 344+
 345+ getArgument: function( name ) {
 346+
 347+ },
 348+
 349+ loopCheck: function(title) {
 350+ },
 351+
 352+ isTemplate: function() {
 353+
 354+ }
 355+
 356+});
 357+
 358+
 359+
48360 /**
49361 * @parm MWParserEnvironment env
50362 * @constructor
Index: trunk/extensions/ParserPlayground/modules/pegParser.pegjs.txt
@@ -174,6 +174,17 @@
175175 };
176176 }
177177
 178+tplarg = "{{{" name:link_target params:("|" p:template_param { return p })* "}}}" {
 179+ var obj = {
 180+ type: 'tplarg',
 181+ name: name
 182+ };
 183+ if (params && params.length) {
 184+ obj.params = params;
 185+ }
 186+ return obj;
 187+}
 188+
178189 template_param_name
179190 = h:( !"}}" x:([^=|]) { return x } )* { return h.join(''); }
180191
Index: trunk/extensions/Math/math/mathml.ml
@@ -1,15 +1,13 @@
22 open Tex
33 open Render_info
44
5 -type t = TREE_MN of string | TREE_MO of string | TREE_MI of string | TREE_MF of string | TREE_MFB of string * string
 5+type t = TREE_MN of string | TREE_MO of string | TREE_MI of string
66
77 let rec make_mathml_tree = function
88 TREE_MN a::otr,TEX_LITERAL(MHTMLABLEC(_,_,_,MN,b))::itr -> make_mathml_tree(TREE_MN (a^b)::otr,itr)
99 | otr,TEX_LITERAL(MHTMLABLEC(_,_,_,MN,a))::itr -> make_mathml_tree(TREE_MN a::otr,itr)
1010 | otr,TEX_LITERAL(MHTMLABLEC(_,_,_,MO,a))::itr -> make_mathml_tree(TREE_MO a::otr,itr)
1111 | otr,TEX_LITERAL(MHTMLABLEC(_,_,_,MI,a))::itr -> make_mathml_tree(TREE_MI a::otr,itr)
12 - | otr,TEX_LITERAL(MHTMLABLEC(_,_,_,MF,a))::itr -> make_mathml_tree(TREE_MF a::otr,itr)
13 - | otr,TEX_LITERAL(MHTMLABLEFC(_,_,_,MF,a,b))::itr -> make_mathml_tree(TREE_MFB (a,b)::otr,itr)
1412 | otr,TEX_CURLY(crl)::itr -> make_mathml_tree(otr,crl@itr)
1513 | otr,[] -> List.rev otr
1614 | _ -> failwith "failed to render mathml"
@@ -18,7 +16,5 @@
1917 TREE_MN s -> "<mn>"^s^"</mn>"
2018 | TREE_MI s -> "<mi>"^s^"</mi>"
2119 | TREE_MO s -> "<mo>"^s^"</mo>"
22 - | TREE_MF s -> "<mi>"^s^" </mi>"
23 - | TREE_MFB (s,b) -> "<mi>"^s^"</mi>"^"<mo>"^b^"</mo>"
2420
2521 let render tree = try Some (Util.mapjoin render_mathml_tree (make_mathml_tree ([],tree))) with _ -> None
Index: trunk/extensions/Math/math/parser.mly
@@ -2,7 +2,7 @@
33 open Tex
44 open Render_info
55
6 - let sq_close_ri = MHTMLABLEC(FONT_UFH,"]", "]",MO,"]")
 6+ let sq_close_ri = HTMLABLEC(FONT_UFH,"]", "]")
77 %}
88 %token <Render_info.t> LITERAL DELIMITER
99 %token <string> FUN_AR2 FUN_INFIX FUN_AR1 DECL FUN_AR1opt BIG FUN_AR2nb
Index: trunk/extensions/Math/math/lexer.mll
@@ -6,15 +6,13 @@
77 let space = [' ' '\t' '\n' '\r']
88 let alpha = ['a'-'z' 'A'-'Z']
99 let literal_id = ['a'-'z' 'A'-'Z']
10 -let literal_mn = ['0'-'9' '.']
 10+let literal_mn = ['0'-'9']
1111 let literal_uf_lt = [',' ':' ';' '?' '!' '\'']
12 -let delimiter_uf_lt = ['(' ')']
 12+let delimiter_uf_lt = ['(' ')' '.']
1313 let literal_uf_op = ['+' '-' '*' '=']
1414 let delimiter_uf_op = ['/' '|']
15 -let boxchars = ['0'-'9' 'a'-'z' 'A'-'Z' '+' '-' '*' ',' '=' '(' ')' ':' '/' ';' '?' '.' '!' '\'' '`' ' ' '\128'-'\255']
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"
 15+let boxchars = ['0'-'9' 'a'-'z' 'A'-'Z' '+' '-' '*' ',' '=' '(' ')' ':' '/' ';' '?' '.' '!' ' ' '\128'-'\255']
 16+let aboxchars = ['0'-'9' 'a'-'z' 'A'-'Z' '+' '-' '*' ',' '=' '(' ')' ':' '/' ';' '?' '.' '!' ' ']
1917
2018 rule token = parse
2119 space + { token lexbuf }
@@ -52,39 +50,20 @@
5351 | literal_id { let str = Lexing.lexeme lexbuf in LITERAL (MHTMLABLEC (FONT_IT, str,str,MI,str)) }
5452 | literal_mn { let str = Lexing.lexeme lexbuf in LITERAL (MHTMLABLEC (FONT_RM, str,str,MN,str)) }
5553 | literal_uf_lt { let str = Lexing.lexeme lexbuf in LITERAL (HTMLABLEC (FONT_UFH, str,str)) }
56 - | delimiter_uf_lt { let str = Lexing.lexeme lexbuf in DELIMITER (MHTMLABLEC (FONT_UFH, str,str,MO,str)) }
57 - | "-" { let str = Lexing.lexeme lexbuf in LITERAL (MHTMLABLEC (FONT_UFH,"-"," &minus; ",MO," &minus; "))}
58 - | literal_uf_op { let str = Lexing.lexeme lexbuf in LITERAL (MHTMLABLEC (FONT_UFH, str,"&nbsp;"^str^"&nbsp;",MO," "^str^" ")) }
 54+ | delimiter_uf_lt { let str = Lexing.lexeme lexbuf in DELIMITER (HTMLABLEC (FONT_UFH, str,str)) }
 55+ | "-" { let str = Lexing.lexeme lexbuf in LITERAL (MHTMLABLEC (FONT_UFH,"-"," &minus; ",MO,str))}
 56+ | literal_uf_op { let str = Lexing.lexeme lexbuf in LITERAL (MHTMLABLEC (FONT_UFH, str," "^str^" ",MO,str)) }
5957 | delimiter_uf_op { let str = Lexing.lexeme lexbuf in DELIMITER (MHTMLABLEC (FONT_UFH, str," "^str^" ",MO,str)) }
 58+ | "\\" alpha + { Texutil.find (Lexing.lexeme lexbuf) }
6059 | "\\sqrt" space * "[" { FUN_AR1opt "\\sqrt" }
6160 | "\\xleftarrow" space * "[" { Texutil.tex_use_ams(); FUN_AR1opt "\\xleftarrow" }
6261 | "\\xrightarrow" space * "[" { Texutil.tex_use_ams(); FUN_AR1opt "\\xrightarrow" }
63 - | "\\" (latex_function_names as name) space * "("
64 - { LITERAL (MHTMLABLEFC(FONT_UFH,"\\" ^ name ^ "(", name ^ "(", MF, name, "(")) }
65 - | "\\" (latex_function_names as name) space * "["
66 - { LITERAL (MHTMLABLEFC(FONT_UFH,"\\" ^ name ^ "[", name ^ "[", MF, name, "[")) }
67 - | "\\" (latex_function_names as name) space * "\\{"
68 - { LITERAL (MHTMLABLEFC(FONT_UFH, "\\" ^ name ^ "\\{", name ^ "{", MF, name, "{")) }
69 - | "\\" (latex_function_names as name) space *
70 - { LITERAL (MHTMLABLEC(FONT_UFH,"\\" ^ name ^ " ", name ^ "&nbsp;", MF, name)) }
71 - | "\\" (mediawiki_function_names as name) space * "("
72 - { (Texutil.tex_use_ams(); LITERAL (MHTMLABLEFC(FONT_UFH,
73 - "\\operatorname{" ^ name ^ "}(", name ^ "(", MF, name, "("))) }
74 - | "\\" (mediawiki_function_names as name) space * "["
75 - { (Texutil.tex_use_ams(); LITERAL (MHTMLABLEFC(FONT_UFH,
76 - "\\operatorname{" ^ name ^ "}[", name ^ "[", MF, name, "["))) }
77 - | "\\" (mediawiki_function_names as name) space * "\\{"
78 - { (Texutil.tex_use_ams(); LITERAL (MHTMLABLEFC(FONT_UFH,
79 - "\\operatorname{" ^ name ^ "}\\{", name ^ "{", MF, name, "{"))) }
80 - | "\\" (mediawiki_function_names as name) space *
81 - { (Texutil.tex_use_ams(); LITERAL (MHTMLABLEC(FONT_UFH,"\\operatorname{" ^ name ^ "} ", name ^ "&nbsp;", MF, name))) }
82 - | "\\" alpha + { Texutil.find (Lexing.lexeme lexbuf) }
8362 | "\\," { LITERAL (HTMLABLE (FONT_UF, "\\,","&nbsp;")) }
8463 | "\\ " { LITERAL (HTMLABLE (FONT_UF, "\\ ","&nbsp;")) }
8564 | "\\;" { LITERAL (HTMLABLE (FONT_UF, "\\;","&nbsp;")) }
8665 | "\\!" { LITERAL (TEX_ONLY "\\!") }
87 - | "\\{" { DELIMITER (MHTMLABLEC(FONT_UFH,"\\{","{",MO,"{")) }
88 - | "\\}" { DELIMITER (MHTMLABLEC(FONT_UFH,"\\}","}",MO,"}")) }
 66+ | "\\{" { DELIMITER (HTMLABLEC(FONT_UFH,"\\{","{")) }
 67+ | "\\}" { DELIMITER (HTMLABLEC(FONT_UFH,"\\}","}")) }
8968 | "\\|" { DELIMITER (HTMLABLE (FONT_UFH,"\\|","||")) }
9069 | "\\_" { LITERAL (HTMLABLEC(FONT_UFH,"\\_","_")) }
9170 | "\\#" { LITERAL (HTMLABLE (FONT_UFH,"\\#","#")) }
@@ -120,7 +99,7 @@
121100 | '%' { LITERAL (HTMLABLEC(FONT_UFH,"\\%","%")) }
122101 | '$' { LITERAL (HTMLABLEC(FONT_UFH,"\\$","$")) }
123102 | '~' { LITERAL (HTMLABLE (FONT_UF, "~","&nbsp;")) }
124 - | '[' { DELIMITER (MHTMLABLEC(FONT_UFH,"[","[",MO,"[")) }
 103+ | '[' { DELIMITER (HTMLABLEC(FONT_UFH,"[","[")) }
125104 | ']' { SQ_CLOSE }
126105 | '{' { CURLY_OPEN }
127106 | '}' { CURLY_CLOSE }
Index: trunk/extensions/Math/math/texutil.ml
@@ -9,7 +9,6 @@
1010 | HTMLABLEM (_,t,_) -> t
1111 | HTMLABLEC (_,t,_) -> t
1212 | MHTMLABLEC (_,t,_,_,_) -> t
13 - | MHTMLABLEFC (_,t,_,_,_,_) -> t
1413 | HTMLABLE_BIG (t,_) -> t
1514 | TEX_ONLY t -> t
1615
@@ -21,7 +20,7 @@
2221 | TEX_DQN (a) -> "_{" ^ (render_tex a) ^ "}"
2322 | TEX_UQN (a) -> "^{" ^ (render_tex a) ^ "}"
2423 | TEX_LITERAL s -> tex_part s
25 - | TEX_FUN1 (f,a) -> f ^ " " ^ (render_tex a)
 24+ | TEX_FUN1 (f,a) -> "{" ^ f ^ " " ^ (render_tex a) ^ "}"
2625 | TEX_FUN1hl (f,_,a) -> "{" ^ f ^ " " ^ (render_tex a) ^ "}"
2726 | TEX_FUN1hf (f,_,a) -> "{" ^ f ^ " " ^ (render_tex a) ^ "}"
2827 | TEX_DECLh (f,_,a) -> "{" ^ f ^ "{" ^ (mapjoin render_tex a) ^ "}}"
@@ -46,22 +45,16 @@
4746 let modules_nonascii = ref false
4847 let modules_encoding = ref UTF8
4948 let modules_color = ref false
50 -let modules_teubner = ref false
51 -let modules_euro = ref false
5249
5350 (* wrappers to easily set / reset module properties *)
5451 let tex_use_ams () = modules_ams := true
5552 let tex_use_nonascii () = modules_nonascii := true
5653 let tex_use_color () = modules_color := true
57 -let tex_use_teubner () = modules_teubner := true
58 -let tex_use_euro () = modules_euro := true
5954 let tex_mod_reset () = (
6055 modules_ams := false;
6156 modules_nonascii := false;
6257 modules_encoding := UTF8;
63 - modules_color := false;
64 - modules_teubner := false;
65 - modules_euro := false;
 58+ modules_color := false
6659 )
6760
6861 (* Return TeX fragment for one of the encodings in (UTF8,LATIN1,LATIN2) *)
@@ -75,8 +68,6 @@
7669 (if !modules_nonascii then get_encoding !modules_encoding else "") ^
7770 (if !modules_ams then "\\usepackage{amsmath}\n\\usepackage{amsfonts}\n\\usepackage{amssymb}\n" else "") ^
7871 (if !modules_color then "\\usepackage[dvips,usenames]{color}\n" else "") ^
79 - (if !modules_teubner then "\\usepackage[greek]{babel}\n\\usepackage{teubner}\n" else "") ^
80 - (if !modules_euro then "\\usepackage{eurosym}\n" else "") ^
8172 "\\usepackage{cancel}\n\\pagestyle{empty}\n\\begin{document}\n$$\n"
8273
8374 (* TeX fragment appended after the content *)
@@ -106,7 +97,7 @@
10798 | "\\epsilon" -> LITERAL (TEX_ONLY "\\epsilon ")
10899 | "\\Epsilon" -> (tex_use_ams (); LITERAL (HTMLABLEC (FONT_UF,
109100 "\\mathrm{E}", "&Epsilon;")))
110 - | "\\varepsilon" -> LITERAL (HTMLABLEC (FONT_UF, "\\varepsilon ", "&epsilon;"))
 101+ | "\\varepsilon" -> LITERAL (TEX_ONLY "\\varepsilon ")
111102 | "\\zeta" -> LITERAL (HTMLABLEC (FONT_UF, "\\zeta ", "&zeta;"))
112103 | "\\Zeta" -> (tex_use_ams (); LITERAL (HTMLABLEC (FONT_UF,
113104 "\\mathrm{Z}", "&Zeta;")))
@@ -151,9 +142,9 @@
152143 "\\mathrm{T}", "&Tau;")))
153144 | "\\upsilon" -> LITERAL (HTMLABLEC (FONT_UF, "\\upsilon ", "&upsilon;"))
154145 | "\\Upsilon" -> LITERAL (HTMLABLEC (FONT_UF, "\\Upsilon ", "&Upsilon;"))
155 - | "\\phi" -> LITERAL (HTMLABLEC (FONT_UF, "\\phi ", "&#981;"))
 146+ | "\\phi" -> LITERAL (TEX_ONLY "\\phi ")
156147 | "\\Phi" -> LITERAL (HTMLABLEC (FONT_UF, "\\Phi ", "&Phi;"))
157 - | "\\varphi" -> LITERAL (HTMLABLEC (FONT_UF, "\\varphi ", "&phi;"))
 148+ | "\\varphi" -> LITERAL (TEX_ONLY "\\varphi ")
158149 | "\\chi" -> LITERAL (HTMLABLEC (FONT_UF, "\\chi ", "&chi;"))
159150 | "\\Chi" -> (tex_use_ams (); LITERAL (HTMLABLEC (FONT_UF,
160151 "\\mathrm{X}", "&Chi;")))
@@ -249,6 +240,16 @@
250241 | "\\triangleleft" -> LITERAL (TEX_ONLY "\\triangleleft ")
251242 | "\\triangleright" -> LITERAL (TEX_ONLY "\\triangleright ")
252243 | "\\textvisiblespace" -> LITERAL (TEX_ONLY "\\textvisiblespace ")
 244+ | "\\ker" -> LITERAL (HTMLABLEC(FONT_UFH,"\\ker ","ker"))
 245+ | "\\lim" -> LITERAL (TEX_ONLY "\\lim ")
 246+ | "\\limsup" -> LITERAL (TEX_ONLY "\\limsup ")
 247+ | "\\liminf" -> LITERAL (TEX_ONLY "\\liminf ")
 248+ | "\\sup" -> LITERAL (TEX_ONLY "\\sup ")
 249+ | "\\Pr" -> LITERAL (TEX_ONLY "\\Pr ")
 250+ | "\\hom" -> LITERAL (HTMLABLEC(FONT_UFH,"\\hom ","hom"))
 251+ | "\\arg" -> LITERAL (HTMLABLEC(FONT_UFH,"\\arg ","arg"))
 252+ | "\\dim" -> LITERAL (HTMLABLEC(FONT_UFH,"\\dim ","dim"))
 253+ | "\\inf" -> LITERAL (TEX_ONLY "\\inf ")
253254 | "\\circ" -> LITERAL (TEX_ONLY "\\circ ")
254255 | "\\hbar" -> LITERAL (TEX_ONLY "\\hbar ")
255256 | "\\imath" -> LITERAL (TEX_ONLY "\\imath ")
@@ -269,6 +270,32 @@
270271 | "\\limits" -> LITERAL (TEX_ONLY "\\limits ")
271272 | "\\nolimits" -> LITERAL (TEX_ONLY "\\nolimits ")
272273 | "\\top" -> LITERAL (TEX_ONLY "\\top ")
 274+ | "\\sin" -> LITERAL (HTMLABLEC(FONT_UFH,"\\sin ","sin"))
 275+ | "\\cos" -> LITERAL (HTMLABLEC(FONT_UFH,"\\cos ","cos"))
 276+ | "\\sinh" -> LITERAL (HTMLABLEC(FONT_UFH,"\\sinh ","sinh"))
 277+ | "\\cosh" -> LITERAL (HTMLABLEC(FONT_UFH,"\\cosh ","cosh"))
 278+ | "\\tan" -> LITERAL (HTMLABLEC(FONT_UFH,"\\tan ","tan"))
 279+ | "\\tanh" -> LITERAL (HTMLABLEC(FONT_UFH,"\\tanh ","tanh"))
 280+ | "\\sec" -> LITERAL (HTMLABLEC(FONT_UFH,"\\sec ","sec"))
 281+ | "\\csc" -> LITERAL (HTMLABLEC(FONT_UFH,"\\csc ","csc"))
 282+ | "\\arcsin" -> LITERAL (HTMLABLEC(FONT_UFH,"\\arcsin ","arcsin"))
 283+ | "\\arctan" -> LITERAL (HTMLABLEC(FONT_UFH,"\\arctan ","arctan"))
 284+ | "\\arccos" -> (tex_use_ams (); LITERAL (HTMLABLEC(FONT_UFH,"\\mathop{\\mathrm{arccos}}","arccos")))
 285+ | "\\arccot" -> (tex_use_ams (); LITERAL (HTMLABLEC(FONT_UFH,"\\mathop{\\mathrm{arccot}}","arccot")))
 286+ | "\\arcsec" -> (tex_use_ams (); LITERAL (HTMLABLEC(FONT_UFH,"\\mathop{\\mathrm{arcsec}}","arcsec")))
 287+ | "\\arccsc" -> (tex_use_ams (); LITERAL (HTMLABLEC(FONT_UFH,"\\mathop{\\mathrm{arccsc}}","arccsc")))
 288+ | "\\sgn" -> (tex_use_ams (); LITERAL (HTMLABLEC(FONT_UFH,"\\mathop{\\mathrm{sgn}}","sgn")))
 289+ | "\\cot" -> LITERAL (HTMLABLEC(FONT_UFH,"\\cot ","cot"))
 290+ | "\\coth" -> LITERAL (HTMLABLEC(FONT_UFH,"\\coth ","coth"))
 291+ | "\\log" -> LITERAL (HTMLABLEC(FONT_UFH,"\\log ", "log"))
 292+ | "\\lg" -> LITERAL (HTMLABLEC(FONT_UFH,"\\lg ", "lg"))
 293+ | "\\ln" -> LITERAL (HTMLABLEC(FONT_UFH,"\\ln ", "ln"))
 294+ | "\\exp" -> LITERAL (HTMLABLEC(FONT_UFH,"\\exp ", "exp"))
 295+ | "\\min" -> LITERAL (HTMLABLEC(FONT_UFH,"\\min ", "min"))
 296+ | "\\max" -> LITERAL (HTMLABLEC(FONT_UFH,"\\max ", "max"))
 297+ | "\\gcd" -> LITERAL (HTMLABLEC(FONT_UFH,"\\gcd ", "gcd"))
 298+ | "\\deg" -> LITERAL (HTMLABLEC(FONT_UFH,"\\deg ", "deg"))
 299+ | "\\det" -> LITERAL (HTMLABLEC(FONT_UFH,"\\det ", "det"))
273300 | "\\bullet" -> LITERAL (HTMLABLE (FONT_UFH, "\\bullet ", "&bull;"))
274301 | "\\bull" -> LITERAL (HTMLABLE (FONT_UFH, "\\bullet ", "&bull;"))
275302 | "\\angle" -> (tex_use_ams (); LITERAL (HTMLABLE (FONT_UF, "\\angle ", "&ang;")))
@@ -392,22 +419,6 @@
393420 | "\\asymp" -> LITERAL (TEX_ONLY "\\asymp ")
394421 | "\\doteq" -> LITERAL (TEX_ONLY "\\doteq ")
395422 | "\\parallel" -> LITERAL (TEX_ONLY "\\parallel ")
396 - | "\\euro" -> (tex_use_euro (); LITERAL (HTMLABLE (FONT_UF, "\\mbox{\\euro}", "&euro;")))
397 - | "\\geneuro" -> (tex_use_euro (); LITERAL (TEX_ONLY "\\mbox{\\geneuro}"))
398 - | "\\geneuronarrow" -> (tex_use_euro (); LITERAL (TEX_ONLY "\\mbox{\\geneuronarrow}"))
399 - | "\\geneurowide" -> (tex_use_euro (); LITERAL (TEX_ONLY "\\mbox{\\geneurowide}"))
400 - | "\\officialeuro" -> (tex_use_euro (); LITERAL (TEX_ONLY "\\mbox{\\officialeuro}"))
401 - | "\\Coppa" -> (tex_use_teubner (); LITERAL (HTMLABLE (FONT_UF, "\\mbox{\\Coppa}", "&#984;")))
402 - | "\\coppa" -> (tex_use_teubner (); LITERAL (HTMLABLE (FONT_UF, "\\mbox{\\coppa}", "&#985;")))
403 - | "\\varcoppa" -> (tex_use_teubner (); LITERAL (HTMLABLE (FONT_UF, "\\mbox{\\coppa}", "&#985;")))
404 - | "\\Digamma" -> (tex_use_teubner (); LITERAL (HTMLABLE (FONT_UF, "\\mbox{\\Digamma}", "&#988;")))
405 - | "\\Koppa" -> (tex_use_teubner (); LITERAL (HTMLABLE (FONT_UF, "\\mbox{\\Koppa}", "&#984;")))
406 - | "\\koppa" -> (tex_use_teubner (); LITERAL (HTMLABLE (FONT_UF, "\\mbox{\\koppa}", "&#991;")))
407 - | "\\Sampi" -> (tex_use_teubner (); LITERAL (TEX_ONLY "\\mbox{\\Sampi}"))
408 - | "\\sampi" -> (tex_use_teubner (); LITERAL (HTMLABLE (FONT_UF, "\\mbox{\\sampi}", "&#993;")))
409 - | "\\Stigma" -> (tex_use_teubner (); LITERAL (TEX_ONLY "\\mbox{\\Stigma}"))
410 - | "\\stigma" -> (tex_use_teubner (); LITERAL (HTMLABLE (FONT_UF, "\\mbox{\\stigma}", "&#987;")))
411 - | "\\varstigma" -> (tex_use_teubner (); LITERAL (TEX_ONLY "\\mbox{\\varstigma}"))
412423 | "\\implies" -> (tex_use_ams (); LITERAL (HTMLABLE (FONT_UF, "\\implies ", "&rArr;")))
413424 | "\\mod" -> (tex_use_ams (); LITERAL (HTMLABLE (FONT_UFH,"\\mod ", "mod")))
414425 | "\\Diamond" -> (tex_use_ams (); LITERAL (HTMLABLE (FONT_UF, "\\Diamond ", "&loz;")))
@@ -416,17 +427,16 @@
417428 | "\\dotsi" -> (tex_use_ams (); LITERAL (HTMLABLE (FONT_UF, "\\dotsi ", "&sdot;&sdot;&sdot;")))
418429 | "\\dotsm" -> (tex_use_ams (); LITERAL (HTMLABLE (FONT_UF, "\\dotsm ", "&sdot;&sdot;&sdot;")))
419430 | "\\dotso" -> (tex_use_ams (); LITERAL (HTMLABLE (FONT_UF, "\\dotso ", "...")))
420 - | "\\reals" -> (tex_use_ams (); LITERAL (HTMLABLE (FONT_UFH,"\\mathbb{R}", "&#8477;")))
421 - | "\\Reals" -> (tex_use_ams (); LITERAL (HTMLABLE (FONT_UFH,"\\mathbb{R}", "&#8477;")))
422 - | "\\R" -> (tex_use_ams (); LITERAL (HTMLABLE (FONT_UFH,"\\mathbb{R}", "&#8477;")))
423 - | "\\C" -> (tex_use_ams (); LITERAL (HTMLABLE (FONT_UFH,"\\mathbb{C}", "&#8450;")))
424 - | "\\cnums" -> (tex_use_ams (); LITERAL (HTMLABLE (FONT_UFH,"\\mathbb{C}", "&#8450;")))
425 - | "\\Complex" -> (tex_use_ams (); LITERAL (HTMLABLE (FONT_UFH,"\\mathbb{C}", "&#8450;")))
426 - | "\\Z" -> (tex_use_ams (); LITERAL (HTMLABLE (FONT_UFH,"\\mathbb{Z}", "&#8484;")))
427 - | "\\natnums" -> (tex_use_ams (); LITERAL (HTMLABLE (FONT_UFH,"\\mathbb{N}", "&#8469;")))
428 - | "\\N" -> (tex_use_ams (); LITERAL (HTMLABLE (FONT_UFH,"\\mathbb{N}", "&#8469;")))
429 - | "\\Q" -> (tex_use_ams (); LITERAL (HTMLABLE (FONT_UFH,"\\mathbb{Q}", "&#8474;")))
430 - | "\\H" -> (tex_use_ams (); LITERAL (HTMLABLE (FONT_UFH,"\\mathbb{H}", "&#8461;")))
 431+ | "\\reals" -> (tex_use_ams (); LITERAL (HTMLABLE (FONT_UFH,"\\mathbb{R}", "<b>R</b>")))
 432+ | "\\Reals" -> (tex_use_ams (); LITERAL (HTMLABLE (FONT_UFH,"\\mathbb{R}", "<b>R</b>")))
 433+ | "\\R" -> (tex_use_ams (); LITERAL (HTMLABLE (FONT_UFH,"\\mathbb{R}", "<b>R</b>")))
 434+ | "\\C" -> (tex_use_ams (); LITERAL (HTMLABLE (FONT_UFH,"\\mathbb{C}", "<b>C</b>")))
 435+ | "\\cnums" -> (tex_use_ams (); LITERAL (HTMLABLE (FONT_UFH,"\\mathbb{C}", "<b>C</b>")))
 436+ | "\\Complex" -> (tex_use_ams (); LITERAL (HTMLABLE (FONT_UFH,"\\mathbb{C}", "<b>C</b>")))
 437+ | "\\Z" -> (tex_use_ams (); LITERAL (HTMLABLE (FONT_UFH,"\\mathbb{Z}", "<b>Z</b>")))
 438+ | "\\natnums" -> (tex_use_ams (); LITERAL (HTMLABLE (FONT_UFH,"\\mathbb{N}", "<b>N</b>")))
 439+ | "\\N" -> (tex_use_ams (); LITERAL (HTMLABLE (FONT_UFH,"\\mathbb{N}", "<b>N</b>")))
 440+ | "\\Q" -> (tex_use_ams (); LITERAL (HTMLABLE (FONT_UFH,"\\mathbb{Q}", "<b>Q</b>")))
431441 | "\\lVert" -> (tex_use_ams (); LITERAL (HTMLABLE (FONT_UFH,"\\lVert ", "||")))
432442 | "\\rVert" -> (tex_use_ams (); LITERAL (HTMLABLE (FONT_UFH,"\\rVert ", "||")))
433443 | "\\nmid" -> (tex_use_ams (); LITERAL (TEX_ONLY "\\nmid "))
@@ -482,7 +492,6 @@
483493 | "\\hat" -> FUN_AR1 "\\hat "
484494 | "\\hline" -> LITERAL (TEX_ONLY "\\hline ")
485495 | "\\vline" -> LITERAL (TEX_ONLY "\\vline ")
486 - | "\\widetilde" -> LITERAL (TEX_ONLY "\\widetilde ")
487496 | "\\widehat" -> LITERAL (TEX_ONLY "\\widehat ")
488497 | "\\overline" -> LITERAL (TEX_ONLY "\\overline ")
489498 | "\\overbrace" -> LITERAL (TEX_ONLY "\\overbrace ")
Index: trunk/extensions/Math/math/render_info.mli
@@ -11,13 +11,10 @@
1212 MN
1313 | MI
1414 | MO
15 - | MF
16 -
1715 type t =
1816 HTMLABLEC of font_class * string * string
1917 | HTMLABLEM of font_class * string * string
2018 | HTMLABLE of font_class * string * string
2119 | MHTMLABLEC of font_class * string * string * math_class * string
22 - | MHTMLABLEFC of font_class * string * string * math_class * string * string
2320 | HTMLABLE_BIG of string * string
2421 | TEX_ONLY of string
Index: trunk/extensions/Math/math/html.ml
@@ -28,7 +28,6 @@
2929 TEX_LITERAL (HTMLABLE (ft,_,sh))::r -> (html_liberal (); (font_render sh (ctx,ft))^html_render_flat ctx r)
3030 | TEX_LITERAL (HTMLABLEC(ft,_,sh))::r -> (font_render sh (ctx,ft))^html_render_flat ctx r
3131 | TEX_LITERAL (MHTMLABLEC(ft,_,sh,_,_))::r -> (font_render sh (ctx,ft))^html_render_flat ctx r
32 - | TEX_LITERAL (MHTMLABLEFC(ft,_,sh,_,_,_))::r -> (font_render sh (ctx,ft))^html_render_flat ctx r
3332 | TEX_LITERAL (HTMLABLEM(ft,_,sh))::r -> (html_moderate(); (font_render sh (ctx,ft))^html_render_flat ctx r)
3433 | TEX_LITERAL (HTMLABLE_BIG (_,sh))::r -> (html_liberal (); sh^html_render_flat ctx r)
3534 | TEX_FUN1hl (_,(f1,f2),a)::r -> f1^(html_render_flat ctx [a])^f2^html_render_flat ctx r
@@ -76,7 +75,6 @@
7776 | TEX_LITERAL (HTMLABLEM(ft,_,sh))::r -> (html_moderate(); ("",(font_render sh (ctx,ft)),"")::html_render_deep ctx r)
7877 | TEX_LITERAL (HTMLABLEC(ft,_,sh))::r -> ("",(font_render sh (ctx,ft)),"")::html_render_deep ctx r
7978 | TEX_LITERAL (MHTMLABLEC(ft,_,sh,_,_))::r -> ("",(font_render sh (ctx,ft)),"")::html_render_deep ctx r
80 - | TEX_LITERAL (MHTMLABLEFC(ft,_,sh,_,_,_))::r -> ("",(font_render sh (ctx,ft)),"")::html_render_deep ctx r
8179 | TEX_LITERAL (HTMLABLE_BIG (_,sh))::r -> (html_liberal (); ("",sh,"")::html_render_deep ctx r)
8280 | TEX_FUN2h (_,f,a,b)::r -> (html_liberal (); (f a b)::html_render_deep ctx r)
8381 | TEX_INFIXh (_,f,a,b)::r -> (html_liberal (); (f a b)::html_render_deep ctx r)

Follow-up revisions

RevisionCommit summaryAuthorDate
r96991Followup r96990: revert partial accidental commit of ParserPlayground extensi...brion19:02, 13 September 2011
r96993MFT r96990: provisional revert of texvc changes that don't come with any test...brion19:07, 13 September 2011
r97001* (bug 26380) Add support for \widetilde to <math>...brion21:02, 13 September 2011
r97002Followup r97001: fix for Math parser tests image URLs...brion21:03, 13 September 2011
r97007* (bug 27324) \euro support for <math>...brion21:48, 13 September 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r86962The following changes enhance the way texvc handles space around...thenub31418:17, 26 April 2011
r86965This change adds support for the \widetilde command as mentioned in bug 26380thenub31418:44, 26 April 2011
r87092The following fixes bug 19547 by allowing left and right single...thenub31418:23, 28 April 2011
r87117This update removes unneeded code from texutil.ml and corrects the way...thenub31406:08, 29 April 2011
r87284This update fixes bug 27324 by loading the eurosym package to provide...thenub31419:28, 2 May 2011
r87298This update provides the functionality requested in bug 27754. More...thenub31421:13, 2 May 2011
r87934This updates improves the MathML support of texvc. New new tags have...thenub31421:46, 12 May 2011
r87936Corrects a small bug causing <math>\sin</math> to return an unknown...thenub31422:29, 12 May 2011
r87941A change to fix a bug in LaTeX rendering of function names. An...thenub31400:01, 13 May 2011
r88030Removed the &ApplyFunction; MathML entity. This entity doesn't...thenub31403:04, 14 May 2011
r88260The following change fixes minor issues with the MathML display of...thenub31419:25, 16 May 2011

Comments

#Comment by Brion VIBBER (talk | contribs)   19:22, 13 September 2011

Got some stray files in here from another extension -- sorry for clogging the diff!

Note also that currently there's no automatic cleaning up of old rendered math bits, so there's no guarantee that things that currently render incorrectly would actually get fixed on existing sites if/when these go live.

#Comment by Brion VIBBER (talk | contribs)   19:28, 13 September 2011

And please note this isn't a final vote of no-confidence; I may well have most of them reapplied later today with tests. :)

Status & tagging log