Procedural Text Edit

v1.0.0 Runs on Windows, Linux Video Documentation

Procedural Text Edit is a very powerful text editing tool driven by its own programming language.
Both the full version and a demo are currently available on itch.io.

.ptep programs are interpreted and run on input texts to produce the desired result.
Procedural Text Edit is available both as GUI version (for very easy usage) and as console version (for easy automation and combination with existing programs or scripts). The program’s functions are applied in sequence on the input, feeding their result to the next function.

  +-------+     +----+      +---------+     +----+      +---------+                +--------+
  | INPUT |  +  | F1 |  =>  | Change1 |  +  | F2 |  =>  | Change2 |  ...  =>  ...  | OUTPUT |
  +-------+     +----+      +---------+     +----+      +---------+                +--------+

The programs only have read access to the input. It therefore is impossible to break the input data.
The available functions are grouped into different categories, explained below.

Overview of function types

Note that the documentation lists all available functions including a description and an example for each.
There’s also a video showing more usage examples.
The clips below show the GUI. The console version is shown separately further down.

Actions

Actions directly alter the text. There’s actions to append text, align the input, sort it, move words, remove duplicates and much more.
There’s also combinators to apply other actions e.g. per line, per word or at certain split characters.

sort word cs      -- sort the words case sensitive
reverse char      -- reverse everything character by character
forEach line {    -- apply the following per line
    prepend "[] " -- prepends "[] " to every line
    append "."    -- appends "." to every line
}

Below a basic usage example. The program is inserted at the top, the input written to the left. Procedural Text Edit then prints the result in the bottom right.
There’s also a list showing the available functions and their parameters. Note that ci stands for case insensitive, while cs stands for case sensitive.

Math Actions

There’s also many basic math functions that can be used the same as actions. They are applied if the input is a number, otherwise they do nothing.

Conditions

Conditions can be used in if statements to only alter the text in certain cases.
contains, endsWith, isNumber and many more. There’s also combinators such as all or not which make it possible to create really complex conditions. There’s also ifelse accepting a second set of actions that is executed if the condition is false.

-- append "." to every number
--        "!" to others
ifElse (isNumber) {
    append "."
} {
    append "!"
}

Conditions in action:

Selectors

With selectors actions can be applied to certain parts of the input. The selected part will be affected, while the rest will stay unchanged. There’s selectors such as after, between, firstN and nth.

-- replace the third word of every line by "third"
forEach line {
    select (nth word 3) {
        replace "third"
    }
}

The clip below shows the usage of selectors:

Alignment

There’s also several functions that can be used to align the text at certain keywords or positions:

Usage

GUI

The GUI version can be started by running either pteGUI or pteGUIDemo.
It is split in 4 areas:

  • Top: The program
  • Bottom left: The input
  • Bottom right: The result / output
  • Far right: The autocomplete suggestions

There’s save and load buttons for the program, input and output.
The program can both be saved and loaded, the input only loaded and the output only saved.

Any changes to the input or program will result in an update of the output.
In case of an error, the error message and the last valid result will be displayed.
You have immediate feedback while writing the program or changing the input data.

Console

The console version can be started by running either pte or pteDemo.
The arguments are interpreted as program, while the input is passed to the program.
Passing --help shows additional information.

printf "hello world" | ./pte 'toUpper append "x"'
HELLO WORLDx