1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-06-16 10:29:54 +00:00

Support a global railroad config tiddler

This commit is contained in:
Astrid Elocson 2015-01-19 23:11:25 +00:00
parent 998361de59
commit 9e5eaed4a8
2 changed files with 17 additions and 7 deletions

View File

@ -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
```

View File

@ -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);