r105196 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r105195‎ | r105196 | r105197 >
Date:17:58, 5 December 2011
Author:gwicke
Status:deferred
Tags:
Comment:
Fix template argument handling somewhat.
Modified paths:
  • /trunk/extensions/VisualEditor/modules/parser/pegParser.pegjs.txt (modified) (history)

Diff [purge]

Index: trunk/extensions/VisualEditor/modules/parser/pegParser.pegjs.txt
@@ -775,22 +775,25 @@
776776 = "{{" target:template_target params:("|" p:template_param { return p })* "}}" {
777777 var obj = { type: 'TAG', name: 'template', attribs: [['target', target]] }
778778 if (params && params.length) {
779 - obj.attribs.push(params);
 779+ obj.attribs = obj.attribs.concat(params);
780780 }
781781 // Should actually use a self-closing tag here, but the Node HTML5
782782 // parser only recognizes known self-closing tags for now, so use an
783783 // explicit end tag for now.
 784+ //console.log(pp(obj));
784785 return [obj, {type: 'ENDTAG', name: 'template'}];
785786 }
786787
787788 template_target
788789 = h:( !"}}" x:([^|\n]) { return x } )* { return h.join(''); }
789790
 791+/* XXX: pass these as convenient js structures to later stages, but serialize
 792+ * (to json) before passing remaining args to the tree builder */
790793 template_param
791794 = name:template_param_name "=" c:template_param_text {
792 - return [name, c];
 795+ return ['data-k-' + name, c];
793796 } / c:template_param_text {
794 - return [null, c];
 797+ return ['data-p-', c];
795798 }
796799
797800 tplarg
@@ -801,7 +804,7 @@
802805 attribs: [['argname', name]]
803806 };
804807 if (params && params.length) {
805 - obj.attribs.push(params);
 808+ obj.attribs = obj.attribs.concat(params);
806809 }
807810 return obj;
808811 }
@@ -810,9 +813,10 @@
811814 = h:( !"}}" x:([^=|\n]) { return x } )* { return h.join(''); }
812815
813816 template_param_text
814 - = template_param_text_chunk*
815 -/* = h:( !"}}" x:([^|]) { return x } )* { return h.join(''); }*/
 817+ = tcs:template_param_text_chunk* { return JSON.stringify(tcs); }
 818+ //= h:( !"}}" x:([^|]) { return x } )* { return h.join(''); }
816819
 820+
817821 template_param_text_chunk
818822 = comment
819823 / xmlish_tag
@@ -820,7 +824,8 @@
821825 / template
822826 / wikilink
823827 / quote
824 - / !"}}" x:([^|\n]) { return x }
 828+ / c:[^}|\n]+ {return {type: 'TEXT', value: c.join('')}}
 829+ / !"}}" x:([^|\n]) { return {type: 'TEXT', value: x} }
825830
826831 wikilink
827832 = "[[" target:link_target text:("|" lt:link_text { return lt })* "]]" suffix:text? {

Status & tagging log