Textflow Commands and Arguments

A Pipeline is simply a series of Commands. A Pipeline has no other information or data other than the Commands contained within it.

A Command has a name, and usually one or more Arguments which specify how it operates. For example, the extract command will extract an element from a string of HTML. To do this, it has to know which element to extract, and this is specified in an Argument called selector.

The name of the Command starts the line, followed by a space. Arguments start with a dash, then the name of the Argument, then a colon, then the Argument’s value. Multiple Arguments are separated with spaces.

extract -selector:body

This is the extract command with the selector Argument specified.

If an Argument value contains a space, you must wrap it in quotes:

extract -selector:"body h1"

To create a Pipeline, simply stack Commands and their Arguments on consecutive lines:

extract -selector:body
remove -selector:h1
wrap -tag:div

This is a Pipeline with three Commands. extract will execute first, then remove, then wrap. Each Command will (might) modify the Working Text. Whatever Working Text wrap returns is the output of the Pipeline.

The here a list of default Commands bundled into the library.

Textflow Command Reference

That reference is automatically kept up to date by parsing the latest version of the library.

Multi-line Commands

Commands with a lot of Arguments can be confusing to manage, so they can be split over multiple lines, as long as each subsequent line of the command starts with space (is indented, essentially). A non-indented line followed by one or more indented lines is considered one line and one Command.

make-table
  -col_title:Title
  -col_year:"Year Released"
  -col_director:Director
  -col_box_office:"Box Office Gross"

Tokens

Long and multi-line Argument values can be confusing, so “tokens” can be specified. These are references in the Argument value to text stored below all the Commands. When the Commands are parsed, the tokens are replaced with the the value they reference.

Tokens are specified in the Argument value by a dollar sign and the name of the token. Then, below all commands, a value is provided for each token by specifying the name of the token (with the dollar sign), then the value of the token on the following lines. The value of the token ends when the next token starts or the file/text ends.

template-json -template:$my-template

$my-template
<h1>This is my Template</h2>
<p>
   Assuming a lot is going on here, which is why it has to be on multiple lines…
</p>

$another-token
Something else…

This is one command – template-json – with one argument – template – the value of which is specified as whatever $my-template holds. The $my-template token is specified below the command, and consists of four lines of templating language. Another token and value is specified below it, but is unused in this example.