diff --git a/js/WikiTextCompiler.js b/js/WikiTextCompiler.js index 7ae1186e2..a47bb403a 100644 --- a/js/WikiTextCompiler.js +++ b/js/WikiTextCompiler.js @@ -17,6 +17,121 @@ var WikiTextCompiler = function(store,title,parser) { this.title = title; }; +// Compile a javascript tree into an array of string fragments +var compileJavaScript = function(tree) { + var output = [], + compileJavaScriptTree, + compileJavaScriptNode = function(node) { + var p; + switch(node.type) { + case "StringLiteral": + output.push(utils.stringify(node.value)); + break; + case "StringLiterals": + output.push(utils.stringify(node.value.join(""))); + break; + case "FunctionCall": + output.push("("); + compileJavaScriptNode(node.name); + output.push(")"); + output.push("("); + for(p=0; p