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 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.
- A Pipeline is an ordered series of Commands. The Commands of the Pipeline are executed in order (with some exceptions).
- 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([Optional Input])
A[Command A]
B[Command B]
C[Command C]
2([Output])
1 -->|Working Text| A
A -->|Working Text| B
B -->|Working Text| C
C -->|Working Text| 2
- Commands 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 (selectorandscope), 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 is to transform a string of uncontrolled text and turn it into something controlled, safe, and knowable that can be displayed in another application.