r91321 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r91320‎ | r91321 | r91322 >
Date:22:59, 1 July 2011
Author:brion
Status:deferred
Tags:
Comment:
ParserPlayground: nested templates, kinda messy for now.
Modified paths:
  • /trunk/extensions/ParserPlayground/modules/ext.parserPlayground.renderer.js (modified) (history)
  • /trunk/extensions/ParserPlayground/modules/ext.parserPlayground.serializer.js (modified) (history)
  • /trunk/extensions/ParserPlayground/modules/pegParser.pegjs.txt (modified) (history)

Diff [purge]

Index: trunk/extensions/ParserPlayground/modules/ext.parserPlayground.renderer.js
@@ -23,6 +23,13 @@
2424 });
2525 };
2626 var node;
 27+ if (typeof tree == "string") {
 28+ // hack
 29+ tree = {
 30+ type: 'text',
 31+ text: tree
 32+ }
 33+ }
2734 switch (tree.type) {
2835 case 'page':
2936 // A sequence of block-level elements...
@@ -78,11 +85,16 @@
7986 var t = $('<span class="parseNode template"></span>').text('{{' + tree.target);
8087 if ('params' in tree) {
8188 $.each(tree.params, function(i, param) {
82 - var str = param.contents;
 89+ var str;
8390 if ('name' in param) {
84 - str = param.name + '=' + str;
 91+ str = param.name + '=';
 92+ } else {
 93+ str = '';
8594 }
8695 var p = $('<span></span>').text('|' + str);
 96+ if ('contents' in param && param.contents) {
 97+ subParseArray(param.contents, p);
 98+ }
8799 t.append(p);
88100 });
89101 }
Index: trunk/extensions/ParserPlayground/modules/ext.parserPlayground.serializer.js
@@ -98,7 +98,7 @@
9999 if ('name' in param) {
100100 src += param.name + '=';
101101 }
102 - src += param.contents;
 102+ src += subParseArray(param.contents);
103103 }
104104 }
105105 src += '}}';
Index: trunk/extensions/ParserPlayground/modules/pegParser.pegjs.txt
@@ -177,8 +177,19 @@
178178 = h:( !"}}" x:([^=|]) { return x } )* { return h.join(''); }
179179
180180 template_param_text
181 - = h:( !"}}" x:([^|]) { return x } )* { return h.join(''); }
 181+ = template_param_text_chunk*
 182+/* = h:( !"}}" x:([^|]) { return x } )* { return h.join(''); }*/
182183
 184+template_param_text_chunk
 185+ = comment
 186+ / ref
 187+ / extlink
 188+ / template
 189+ / link
 190+ / bold
 191+ / italic
 192+ / !"}}" x:([^|]) { return x }
 193+
183194 link
184195 = "[[" target:link_target text:("|" link_text)* "]]" {
185196 var obj = {

Status & tagging log