mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-23 10:07:19 +00:00
Support a global railroad config tiddler
This commit is contained in:
parent
998361de59
commit
9e5eaed4a8
@ -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
|
||||
```
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user