r103586 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r103585‎ | r103586 | r103587 >
Date:14:00, 18 November 2011
Author:gwicke
Status:deferred
Tags:
Comment:
Add missing token adapter.
Modified paths:
  • /trunk/extensions/VisualEditor/modules/parser/mediawiki.html5TokenEmitter.js (added) (history)

Diff [purge]

Index: trunk/extensions/VisualEditor/modules/parser/mediawiki.html5TokenEmitter.js
@@ -0,0 +1,64 @@
 2+var events = require('events');
 3+
 4+
 5+var HTML5 = require('./html5/index');
 6+
 7+FauxHTML5 = {}
 8+
 9+
 10+FauxHTML5.Tokenizer = function ( ) {
 11+ this.parser = new HTML5.Parser();
 12+ this.parser.parse(this);
 13+ return this;
 14+}
 15+
 16+FauxHTML5.Tokenizer.prototype = new events.EventEmitter;
 17+
 18+FauxHTML5.Tokenizer.prototype.processToken = function (token) {
 19+ var att = function (maybeAttribs) {
 20+ if ( $.isArray(maybeAttribs) ) {
 21+ var atts = [];
 22+ for(var i = 0, length = maybeAttribs.length; i < length; i++) {
 23+ var att = maybeAttribs[i];
 24+ atts.push({nodeName: att[0], nodeValue: att[1]});
 25+ }
 26+ return atts;
 27+ } else {
 28+ return [];
 29+ }
 30+ };
 31+
 32+ switch (token.type) {
 33+ case "TEXT":
 34+ this.emit('token', {type: 'Characters', data: token.value});
 35+ break;
 36+ case "TAG":
 37+ this.emit('token', {type: 'StartTag',
 38+ name: token.name,
 39+ data: att(token.attribs)});
 40+ break;
 41+ case "ENDTAG":
 42+ this.emit('token', {type: 'EndTag',
 43+ name: token.name,
 44+ data: att(token.attribs)});
 45+ break;
 46+ case "SELFCLOSINGTAG":
 47+ this.emit('token', {type: 'EmptyTag',
 48+ name: token.name,
 49+ data: att(token.attribs)});
 50+ break;
 51+ case "COMMENT":
 52+ this.emit('token', {type: 'EmptyTag',
 53+ data: token.value});
 54+ break;
 55+ case "END":
 56+ this.emit('end');
 57+ break;
 58+ case "NEWLINE":
 59+ //this.emit('end');
 60+ break;
 61+ default:
 62+ console.log("Unhandled token: " + JSON.stringify(token));
 63+ break;
 64+ }
 65+}
Property changes on: trunk/extensions/VisualEditor/modules/parser/mediawiki.html5TokenEmitter.js
___________________________________________________________________
Added: svn:eol-style
166 + native

Status & tagging log