This page is part of a static HTML representation of the TiddlyWiki at https://tiddlywiki.com/

Railroad Plugin

 28th February 2017 at 10:25am

This plugin provides a <$railroad> widget for generating railroad diagrams as SVG images.

Alternatively, the diagram notation can be stored in a dedicated tiddler with its type field set to text/vnd.tiddlywiki.railroad, and that tiddler can simply be transcluded to wherever it is needed.

The plugin is based on a library by Tab Atkins, and has been extended to make it more flexible, including allowing components of a diagram to function as links or be transcluded from other tiddlers.

The railroad widget uses a special notation to construct the components defined below.

x and y here stand for any component.

Names (as opposed to quoted strings) are available when a value starts with a letter and contains only letters, digits, underscores, dots and hyphens.


sequence
<-x->
  • A sequence of components
  • The <- and -> delimiters allow you to force a single component to be treated as a sequence. This is occasionally useful for spacing a diagram out

optional
[:x]
  • A component that can be omitted
  • The colon makes x appear straight ahead

repeated
{x+y}
  • A list of one or more x
  • The + suffix adds y as a separator between each x and the next

optional repeated
[{:x+y}]
  • An optional list of x, i.e. a list of zero or more x

choice
(:x|)
  • A set of alternatives
  • The colon indicates which branch appears straight ahead. By default, it's the first branch

string / terminal
"text"'text'"""text"""
  • A literal or terminal component
  • This follows the normal TiddlyWiki rules for quoted strings

nonterminal
name<string>
  • A nonterminal component, i.e. the name of another diagram

comment
/string/
  • A comment

dummy
-
  • The absence of a component

link
[[x|namestring]]
  • A link to the tiddler title or URI given by the string or name

transclusion
{{namestring}}
  • Treats the content of another tiddler as diagram syntax and transcludes it into the current diagram

arrow pragma
\arrowyesno
  • Controls whether repeat paths have an arrow on them
  • Can be toggled on and off in mid-diagram, if desired

debug pragma
\debug
  • Causes the diagram to display its parse tree

start/end pragma
\start\endnonesingledouble
  • Controls the style of the diagram's startpoint or endpoint