Introduction to qworp

qworp is a programmable and self-modifying text editor where you make the rules.

Blocks

The atomic unit of a qworp document is a block. A document is a tree of blocks. A block is a line of text in the document. The tree is represented by the indentation (two spaces) that make blocks children of other blocks.

Tags

Tags are used to identify and find blocks in a document. A block can have many tags and tags can live in many blocks. They are represented by a hashtag and some non-whitespace characters (e.g. #thisisatag).

A tag can have a numerical value associated with it. By default all tags have a value of 0. These can be used as variables to store numeric values. This is represented with a colon and a numerical value (e.g. #mytag:56).

Actions

Actions is what lets you program the document. Actions can be triggered in a variety of ways such as in buttons, textboxes or immediates.

Actions are made up of a sequence of functions. The output of one function will be fed into the input of the next function. This is done with a pipe character | and will be a familiar concept for those who have used UNIX-like terminal commands.

Data Types

Functions in actions work with data types whether passed into the input or as an argument. There are six natively supported data types:

  1. string - A string is the data type used for any text related functions.

  2. number - Numbers can come from tag values, expressions or functions that return a number.

  3. block - Selector functions return blocks.

  4. tag - Functions can accept a tag as an argument.

  5. nested action - A special data type to embed an action within the arguments of a function. Represented with nested parenthesis.

  6. ident - Special keywords that certain functions will understand as an argument.

Functions

There is a large variety of functions available to manipulate and query the document. See the full function reference for more.

Selectors

Querying the document is achieved with selector functions. Selector functions look for blocks that contain the tags. Once you have some blocks you can use tree traversal functions, the filter function or other selector functions to narrow down the results to the exact block you want to target.

Buttons

Buttons are an interactive way to run an action when a button is clicked. This is represented by the following syntax [button label](actions). This will render a button with the label provided and execute the actions when clicked.

Textbox

A textbox is used to render text in the document. This is represented with the following syntax {}(actions). The actions will be executed on every document change and the output of the actions (either a string or number) is inserted in between the curly braces.

Immediates

Immediates are actions that will be executed on every document change but the output of the last function is discarded. These are primarily used to setup rules where you want an action executed on every document change but are not interested in the output. The syntax for immediates is =(action).