diff --git a/plugins/tiddlywiki/railroad/doc/readme.tid b/plugins/tiddlywiki/railroad/doc/readme.tid index e7642b2d1..05a22aeb4 100644 --- a/plugins/tiddlywiki/railroad/doc/readme.tid +++ b/plugins/tiddlywiki/railroad/doc/readme.tid @@ -1,5 +1,5 @@ created: 20150102163222184 -modified: 20150119220023000 +modified: 20150119231005000 title: $:/plugins/tiddlywiki/railroad/readme This plugin provides a `<$railroad>` widget for generating railroad diagrams as SVG images. @@ -17,4 +17,11 @@ The content of the `<$railroad>` widget is ignored. |end |Style of the endpoint: `single`, `double`, `none` |`single` | |debug |If set to `yes`, the diagram displays its parse tree |`no` | -These options can also be specified via pragmas in the diagram notation. +These options can also be specified via pragmas in the diagram notation, or globally via a dictionary tiddler called `$:/config/railroad`: + +``` +arrow: yes +start: single +end: single +debug: no +``` diff --git a/plugins/tiddlywiki/railroad/wrapper.js b/plugins/tiddlywiki/railroad/wrapper.js index af8bd42eb..89806b24c 100644 --- a/plugins/tiddlywiki/railroad/wrapper.js +++ b/plugins/tiddlywiki/railroad/wrapper.js @@ -19,6 +19,8 @@ var RailroadWidget = function(parseTreeNode,options) { this.initialise(parseTreeNode,options); }; +var RAILROAD_OPTIONS = "$:/config/railroad"; + /* Inherit from the base widget class */ @@ -37,12 +39,13 @@ RailroadWidget.prototype.render = function(parent,nextSibling) { // Create a div to contain the SVG or error message var div = this.document.createElement("div"); try { - // Initialise options from widget attributes + // Initialise options from the config tiddler or widget attributes + var config = $tw.wiki.getTiddlerData(RAILROAD_OPTIONS,{}); var options = { - arrow: this.getAttribute("arrow","yes") === "yes", - debug: this.getAttribute("debug","no") === "yes", - start: this.getAttribute("start","single"), - end: this.getAttribute("end","single") + arrow: this.getAttribute("arrow", config.arrow || "yes") === "yes", + debug: this.getAttribute("debug", config.debug || "no") === "yes", + start: this.getAttribute("start", config.start || "single"), + end: this.getAttribute("end", config.end || "single") }; // Parse the source var parser = new Parser(this,source,options);