This page is part of a static HTML representation of the TiddlyWiki at

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.

  • 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

  • A component that can be omitted
  • The colon makes x appear straight ahead

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

optional repeated
  • An optional list of x, i.e. a list of zero or more x

  • A set of alternatives
  • The colon indicates which branch appears straight ahead. By default, it's the first branch

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

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

  • A comment

  • The absence of a component

  • A link to the tiddler title or URI given by the string or name

  • Treats the content of another tiddler as diagram syntax and transcludes it into the current diagram

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

debug pragma
  • Causes the diagram to display its parse tree

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