/*\ title: $:/core/modules/rendertree/wikirendertree.js type: application/javascript module-type: global Wiki text render tree \*/ (function(){ /*jslint node: true, browser: true */ /*global $tw: false */ "use strict"; /* Create a render tree object for a parse tree parser: reference to the parse tree to be rendered options: see below Options include: wiki: mandatory reference to wiki associated with this render tree context: optional hashmap of context variables (see below) parentRenderer: optional reference to a parent renderer node for the context chain Context variables include: tiddlerTitle: title of the tiddler providing the context templateTitle: title of the tiddler providing the current template macroDefinitions: hashmap of macro definitions */ var WikiRenderTree = function(parser,options) { this.parser = parser; this.wiki = options.wiki; this.context = options.context || {}; this.parentRenderer = options.parentRenderer; // Hashmap of the renderer classes if(!this.rendererClasses) { WikiRenderTree.prototype.rendererClasses = $tw.modules.applyMethods("wikirenderer"); } }; /* Generate the full render tree for this parse tree */ WikiRenderTree.prototype.execute = function() { this.rendererTree = this.createRenderers(this,this.parser.tree); }; /* Create an array of renderers for an array of parse tree nodes */ WikiRenderTree.prototype.createRenderers = function(parentRenderer,parseTreeNodes) { var rendererNodes = []; if(parseTreeNodes) { for(var t=0; t