Index: trunk/extensions/VisualEditor/modules/parser/mediawiki.TokenTransformManager.js |
— | — | @@ -342,6 +342,7 @@ |
343 | 343 | this.loopAndDepthCheck, |
344 | 344 | this.env.normalizeTitle( this.env.tokensToString ( title ) ) |
345 | 345 | ); |
| 346 | + child.title = title; |
346 | 347 | return pipe; |
347 | 348 | }; |
348 | 349 | |
— | — | @@ -357,6 +358,7 @@ |
358 | 359 | AsyncTokenTransformManager.prototype.getAttributePipeline = function ( inputType, args ) { |
359 | 360 | var pipe = this.childFactories.attributes( inputType, args ); |
360 | 361 | var child = pipe.last; |
| 362 | + child.title = this.title; |
361 | 363 | child.loopAndDepthCheck = new LoopAndDepthCheck ( this.loopAndDepthCheck, '' ); |
362 | 364 | return pipe; |
363 | 365 | }; |
— | — | @@ -884,12 +886,14 @@ |
885 | 887 | tokens = this.accum.concat( tokens ); |
886 | 888 | // A sibling will transform tokens, so we don't have to do this |
887 | 889 | // again. |
888 | | - this.manager.env.dp( 'TokenAccumulator._returnTokens: sibling done and parentCB ' + |
| 890 | + this.manager.env.dp( 'TokenAccumulator._returnTokens: ' + |
| 891 | + 'sibling done and parentCB ' + |
889 | 892 | JSON.stringify( tokens ) ); |
890 | 893 | this.parentCB( tokens, false ); |
891 | 894 | return null; |
892 | 895 | } else if ( this.outstanding === 1 && notYetDone ) { |
893 | | - this.manager.env.dp( 'TokenAccumulator._returnTokens: sibling done and parentCB but notYetDone ' + |
| 896 | + this.manager.env.dp( 'TokenAccumulator._returnTokens: ' + |
| 897 | + 'sibling done and parentCB but notYetDone ' + |
894 | 898 | JSON.stringify( tokens ) ); |
895 | 899 | // Sibling is not yet done, but child is. Return own parentCB to |
896 | 900 | // allow the sibling to go direct, and call back parent with |
— | — | @@ -901,7 +905,8 @@ |
902 | 906 | this.manager.env.dp( 'TokenAccumulator._returnTokens: sibling done, but not overall. notYetDone=' + |
903 | 907 | notYetDone + ', this.outstanding=' + this.outstanding + |
904 | 908 | ', this.accum=' + |
905 | | - JSON.stringify( this.accum, null, 2 ) ); |
| 909 | + JSON.stringify( this.accum, null, 2 ) + |
| 910 | + ' manager.title=', this.manager.title ); |
906 | 911 | } |
907 | 912 | |
908 | 913 | |
Index: trunk/extensions/VisualEditor/modules/parser/ext.core.ParserFunctions.js |
— | — | @@ -1,5 +1,8 @@ |
2 | 2 | /** |
3 | | - * Some parser functions |
| 3 | + * Some parser functions, and quite a bunch of stubs of parser functions. |
| 4 | + * Instantiated and called by the TemplateHandler extension. |
| 5 | + * |
| 6 | + * @author Gabriel Wicke <gwicke@wikimedia.org> |
4 | 7 | */ |
5 | 8 | |
6 | 9 | function ParserFunctions ( manager ) { |
— | — | @@ -53,9 +56,11 @@ |
54 | 57 | ParserFunctions.prototype['pf_lc'] = function ( target, argList, argDict ) { |
55 | 58 | return [{type: 'TEXT', value: target.toLowerCase()}]; |
56 | 59 | }; |
| 60 | + |
57 | 61 | ParserFunctions.prototype['pf_uc'] = function ( target, argList, argDict ) { |
58 | 62 | return [{type: 'TEXT', value: target.toUpperCase()}]; |
59 | 63 | }; |
| 64 | + |
60 | 65 | ParserFunctions.prototype['pf_ucfirst'] = function ( target, argList, argDict ) { |
61 | 66 | if ( target ) { |
62 | 67 | return [{ |
— | — | @@ -66,6 +71,7 @@ |
67 | 72 | return []; |
68 | 73 | } |
69 | 74 | }; |
| 75 | + |
70 | 76 | ParserFunctions.prototype['pf_lcfirst'] = function ( target, argList, argDict ) { |
71 | 77 | if ( target ) { |
72 | 78 | return [{ |
— | — | @@ -81,6 +87,11 @@ |
82 | 88 | return [{type: 'TAG', name: target, attribs: argList}]; |
83 | 89 | }; |
84 | 90 | |
| 91 | + |
| 92 | +/** |
| 93 | + * Stub section: Pick any of these and actually implement them! |
| 94 | + */ |
| 95 | + |
85 | 96 | // FIXME |
86 | 97 | ParserFunctions.prototype['pf_#ifexpr'] = function ( target, argList, argDict ) { |
87 | 98 | return []; |
— | — | @@ -94,8 +105,6 @@ |
95 | 106 | ParserFunctions.prototype['pf_#ifexist'] = function ( target, argList, argDict ) { |
96 | 107 | return []; |
97 | 108 | }; |
98 | | - |
99 | | -// pure fake.. |
100 | 109 | ParserFunctions.prototype['pf_formatnum'] = function ( target, argList, argDict ) { |
101 | 110 | return [{type: 'TEXT', value: target}]; |
102 | 111 | }; |
— | — | @@ -124,22 +133,11 @@ |
125 | 134 | return [{type: 'TEXT', value: 'Main'}]; |
126 | 135 | }; |
127 | 136 | |
128 | | -// FIXME! This is just fake. |
129 | 137 | ParserFunctions.prototype['pf_#time'] = function ( target, argList, argDict ) { |
130 | 138 | return [{type: 'TEXT', value: new Date().toString()}]; |
131 | 139 | }; |
132 | 140 | |
133 | | -// #time |
134 | | -// #ifexp |
135 | | -// PAGENAME |
136 | | -// #expr |
137 | | -// NAMESPACE |
138 | | -// #iferror |
139 | | -// |
140 | 141 | |
141 | | -//ParserFunctions.prototype['pf_FORMATNUM'] = function ( target, argList, argDict ) { |
142 | | -//}; |
143 | | - |
144 | 142 | if (typeof module == "object") { |
145 | 143 | module.exports.ParserFunctions = ParserFunctions; |
146 | 144 | } |
Index: trunk/extensions/VisualEditor/modules/parser/ext.core.TemplateHandler.js |
— | — | @@ -144,6 +144,7 @@ |
145 | 145 | TemplateHandler.prototype._expandTemplate = function ( tplExpandData ) { |
146 | 146 | //console.log('TemplateHandler.expandTemplate: ' + |
147 | 147 | // JSON.stringify( tplExpandData, null, 2 ) ); |
| 148 | + var res; |
148 | 149 | |
149 | 150 | |
150 | 151 | if ( ! tplExpandData.target ) { |
— | — | @@ -170,7 +171,7 @@ |
171 | 172 | if ( prefix && 'pf_' + prefix in this.parserFunctions ) { |
172 | 173 | var funcArg = target.substr( prefix.length + 1 ); |
173 | 174 | this.manager.env.dp( 'entering prefix', funcArg, args ); |
174 | | - var res = this.parserFunctions[ 'pf_' + prefix ]( funcArg, |
| 175 | + res = this.parserFunctions[ 'pf_' + prefix ]( funcArg, |
175 | 176 | tplExpandData.expandDone, args ); |
176 | 177 | |
177 | 178 | // XXX: support async parser functions! |
— | — | @@ -188,9 +189,8 @@ |
189 | 190 | |
190 | 191 | var checkRes = this.manager.loopAndDepthCheck.check( target ); |
191 | 192 | if( checkRes ) { |
192 | | - // Loop detected, abort! |
193 | | - return { |
194 | | - tokens: [ |
| 193 | + // Loop detected or depth limit exceeded, abort! |
| 194 | + res = [ |
195 | 195 | { |
196 | 196 | type: 'TEXT', |
197 | 197 | value: checkRes |
— | — | @@ -208,8 +208,12 @@ |
209 | 209 | type: 'ENDTAG', |
210 | 210 | name: 'a' |
211 | 211 | } |
212 | | - ] |
213 | | - }; |
| 212 | + ]; |
| 213 | + if ( tplExpandData.overallAsync ) { |
| 214 | + return tplExpandData.cb( res, false ); |
| 215 | + } else { |
| 216 | + return { tokens: res }; |
| 217 | + } |
214 | 218 | } |
215 | 219 | |
216 | 220 | // Get a nested transformation pipeline for the input type. The input |