mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-24 02:27:19 +00:00
d338a54370
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...
35 lines
962 B
JavaScript
35 lines
962 B
JavaScript
/*\
|
|
title: $:/core/modules/testnewwikiparser.js
|
|
type: application/javascript
|
|
module-type: global
|
|
|
|
Test the new parser
|
|
|
|
\*/
|
|
(function(){
|
|
|
|
/*jslint node: true, browser: true */
|
|
/*global $tw: false */
|
|
"use strict";
|
|
|
|
var testNewParser = function() {
|
|
$tw.wiki.new_initParsers();
|
|
var templateTitle = "$:/templates/NewPageTemplate";
|
|
var parser = $tw.wiki.new_parseTiddler(templateTitle);
|
|
console.log("parsetree after execution",parser);
|
|
var renderTree = new $tw.WikiRenderTree(parser,{wiki: $tw.wiki});
|
|
renderTree.execute({tiddlerTitle: templateTitle});
|
|
console.log("html rendering:",renderTree.render("text/html"));
|
|
console.log("renderTree after execution",renderTree);
|
|
var container = document.createElement("div");
|
|
document.body.insertBefore(container,document.body.firstChild);
|
|
renderTree.renderInDom(container);
|
|
$tw.wiki.addEventListener("",function(changes) {
|
|
renderTree.refreshInDom(changes);
|
|
});
|
|
};
|
|
|
|
exports.testNewParser = testNewParser;
|
|
|
|
})();
|