mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-05-06 17:34:11 +00:00
Support a global railroad config tiddler
This commit is contained in:
parent
998361de59
commit
9e5eaed4a8
@ -1,5 +1,5 @@
|
|||||||
created: 20150102163222184
|
created: 20150102163222184
|
||||||
modified: 20150119220023000
|
modified: 20150119231005000
|
||||||
title: $:/plugins/tiddlywiki/railroad/readme
|
title: $:/plugins/tiddlywiki/railroad/readme
|
||||||
|
|
||||||
This plugin provides a `<$railroad>` widget for generating railroad diagrams as SVG images.
|
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` |
|
|end |Style of the endpoint: `single`, `double`, `none` |`single` |
|
||||||
|debug |If set to `yes`, the diagram displays its parse tree |`no` |
|
|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);
|
this.initialise(parseTreeNode,options);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var RAILROAD_OPTIONS = "$:/config/railroad";
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Inherit from the base widget class
|
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
|
// Create a div to contain the SVG or error message
|
||||||
var div = this.document.createElement("div");
|
var div = this.document.createElement("div");
|
||||||
try {
|
try {
|
||||||
// Initialise options from widget attributes
|
// Initialise options from the config tiddler or widget attributes
|
||||||
|
var config = $tw.wiki.getTiddlerData(RAILROAD_OPTIONS,{});
|
||||||
var options = {
|
var options = {
|
||||||
arrow: this.getAttribute("arrow","yes") === "yes",
|
arrow: this.getAttribute("arrow", config.arrow || "yes") === "yes",
|
||||||
debug: this.getAttribute("debug","no") === "yes",
|
debug: this.getAttribute("debug", config.debug || "no") === "yes",
|
||||||
start: this.getAttribute("start","single"),
|
start: this.getAttribute("start", config.start || "single"),
|
||||||
end: this.getAttribute("end","single")
|
end: this.getAttribute("end", config.end || "single")
|
||||||
};
|
};
|
||||||
// Parse the source
|
// Parse the source
|
||||||
var parser = new Parser(this,source,options);
|
var parser = new Parser(this,source,options);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user