The Basics of Textflow

Textflow is a JavaScript library. You will never encounter it outside of it being embedded in some other application.

Some definitions:

A Pipeline is an ordered series of Commands. The Commands of the Pipeline are usually executed in order.

A Command is a unit of logic that operates on a string of text. It takes some text as input, usually changes it in some way, then outputs it to the next Command.

The Working Text is the text that is passed from one Command to another, progressively moving “down” the a Pipeline. Each Command usually changes the Working Text in some way, then passes the result to the next Command. The Working Text returned from the last command is the output. Working Text may be specified before the Pipeline starts, or the Pipeline might be started “empty” and a Command acquires initial the Working Text (usually the first Command).

flowchart TD
    1([Start])

    subgraph Pipeline
    A[Command A]
    B[Command B]
    C[Command C]
    end 
    2([End])
    1 -->|Optional Input Text| A
    A -->|Working Text| B
    B -->|Working Text| C
    C -->|Output Text| 2

Pipelines are specified in text using a low-code language. An Argument configures a Command by providing information on how the Command should operation. Arguments usually have a value. For example, here is a Command (extract) with two Arguments (selector and scope), which each have a value:

extract -selector:body -scope:inner

The key to understanding Textflow is that the Working Text is the common thread to all Commands. It is passed from Command to Command, and progressively modified as it “moves down the pipe.”

The goal of a Textflow pipeline is to transform a string of uncontrolled text and turn it into something controlled, safe, and knowable that can be displayed in another application.