1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-07-10 05:54:22 +00:00
TiddlyWiki5/core/modules/rendertree/renderers/text.js
Jeremy Ruston d338a54370 Introduce refactored wiki parser and renderer
This is a half-way through a big refactoring of the parsing and
rendering infrastructure. The main change is to separate the parse and
render trees, which makes the code a lot cleaner. The new parser isn't
yet functional enough to replace the existing parser so for the moment
you have to manually invoke it with `$tw.testNewParser()` in your
browser console. I really ought to use branches for this kind of
thing...
2012-12-13 21:34:31 +00:00

36 lines
752 B
JavaScript

/*\
title: $:/core/modules/rendertree/renderers/text.js
type: application/javascript
module-type: wikirenderer
Text renderer
\*/
(function(){
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
/*
Text renderer
*/
var TextRenderer = function(renderTree,renderContext,parseTreeNode) {
// Store state information
this.renderTree = renderTree;
this.renderContext = renderContext;
this.parseTreeNode = parseTreeNode;
};
TextRenderer.prototype.render = function(type) {
return type === "text/html" ? $tw.utils.htmlEncode(this.parseTreeNode.text) : this.parseTreeNode.text;
};
TextRenderer.prototype.renderInDom = function() {
return document.createTextNode(this.parseTreeNode.text);
};
exports.text = TextRenderer
})();