From e5676d058a1f0f2dce238597dfcb13204ddfa7b8 Mon Sep 17 00:00:00 2001 From: Astrid Elocson Date: Mon, 19 Jan 2015 19:59:38 +0000 Subject: [PATCH] Introduce text/vnd.tiddlywiki.railroad --- plugins/tiddlywiki/railroad/tw-parser.js | 28 ++++++++++++++++++++++++ plugins/tiddlywiki/railroad/wrapper.js | 4 ++++ 2 files changed, 32 insertions(+) create mode 100644 plugins/tiddlywiki/railroad/tw-parser.js diff --git a/plugins/tiddlywiki/railroad/tw-parser.js b/plugins/tiddlywiki/railroad/tw-parser.js new file mode 100644 index 000000000..dd60fbdea --- /dev/null +++ b/plugins/tiddlywiki/railroad/tw-parser.js @@ -0,0 +1,28 @@ +/*\ +title: $:/plugins/tiddlywiki/railroad/tw-parser.js +type: application/javascript +module-type: parser + +This parser wraps unadorned railroad syntax into a railroad widget + +\*/ +(function(){ + +/*jslint node: true, browser: true */ +/*global $tw: false */ +"use strict"; + +var RailroadParser = function(type,text,options) { + var element = { + type: "railroad", + tag: "$railroad", + text: text + }; + this.tree = [element]; +console.log(text); +}; + +exports["text/vnd.tiddlywiki.railroad"] = RailroadParser; + +})(); + diff --git a/plugins/tiddlywiki/railroad/wrapper.js b/plugins/tiddlywiki/railroad/wrapper.js index 82d89172d..a6e6d5a4d 100644 --- a/plugins/tiddlywiki/railroad/wrapper.js +++ b/plugins/tiddlywiki/railroad/wrapper.js @@ -33,6 +33,10 @@ RailroadWidget.prototype.render = function(parent,nextSibling) { this.computeAttributes(); this.execute(); // Get the source text +console.log('getAttribute(text)', this.getAttribute("text", 'not found')); +$tw.utils.each(this.parseTreeNode,function(element,title,object) { +console.log(':', element, title); +}); var source = this.getAttribute("text",this.parseTreeNode.text || ""); // Create a div to contain the SVG or error message var div = this.document.createElement("div");