/*\ title: js/WikiTextRenderer.js \*/ (function(){ /*jslint node: true */ "use strict"; var ArgParser = require("./ArgParser.js").ArgParser, utils = require("./Utils.js"), util = require("util"); var WikiTextRenderer = function(store,title,parser) { this.parser = parser; this.store = store; this.title = title; }; WikiTextRenderer.prototype.render = function(type,treenode) { if(type === "text/html") { return this.renderAsHtml(treenode); } else if (type === "text/plain") { return this.renderAsText(treenode); } else { return null; } }; WikiTextRenderer.prototype.renderAsHtml = function(treenode) { var output = [], renderSubTree; var renderElement = function(element, selfClosing) { var tagBits = [element.type]; if(element.attributes) { for(var a in element.attributes) { var r = element.attributes[a]; if(a === "style") { var s = []; for(var t in r) { s.push(t + ":" + r[t] + ";"); } r = s.join(""); } tagBits.push(a + "=\"" + utils.htmlEncode(r) + "\""); } } output.push("<" + tagBits.join(" ") + (selfClosing ? " /" : "") + ">"); if(!selfClosing) { if(element.children) { renderSubTree(element.children); } output.push(""); } }; renderSubTree = function(tree) { for(var t=0; t 0) { macroNode.output.push(ul); this.executeMacros(macroNode.output,title); } else if (emptyMessage) { macroNode.output.push({type: "text", value: emptyMessage}); } }, types: { all: function() { return this.store.getTitles("title","excludeLists"); }, missing: function() { return this.store.getMissingTitles(); }, orphans: function() { return this.store.getOrphanTitles(); }, shadowed: function() { return this.store.getShadowTitles(); }, touched: function() { // Server syncing isn't implemented yet return []; }, filter: function() { // Filters aren't implemented yet return []; } } }, slider: { handler: function(macroNode,title) { } }, tabs: { handler: function(macroNode,title) { } }, tag: { handler: function(macroNode,title) { } }, tagging: { handler: function(macroNode,title) { } }, tags: { handler: function(macroNode,title) { } }, tiddler: { handler: function(macroNode,title) { var args = new ArgParser(macroNode.params,{defaultName:"name",cascadeDefaults:true}), targetTitle = args.getValueByName("name",null), withTokens = args.getValuesByName("with",[]), tiddler = this.store.getTiddler(targetTitle), text = this.store.getTiddlerText(targetTitle,""), t; for(t=0; t