ecursive teXt
by Steven Obua
Cite as http://recursivetext.com
January 22, 2024
Technical Demo
Recursive teXt (RX) is a new general-purpose text format.
It has a simple semantics:
RX = Block+
Block = Line (Line | Block)*
Line = Character*
In other words:
- An RX document is a non-empty sequence of blocks.
- A block starts with a line, followed by a sequence of lines and blocks.
- A line is just a sequence of characters.
An RX document is saved as a plain text file, usually with the suffix
.rx.
In plain text, the semantics of RX is encoded via indentation:
- A block is indented by 2 spaces (Unicode 0x20) relative to the normal line start. A block at the top level is not indented.
- Relative to the first line of the block, every other line of the block is indented by 2 spaces.
- A non-breaking space character (Unicode 0xA0) at the start of a line is always converted to a normal space.
This is used to encode a normal space at the start of a line in plain text by replacing it with a non-breaking space.
The above implies that the first line of a nested block is indented by 4 spaces relative to the first line of its parent block.
TypeScript code for reading and writing RX from and to plain text is available.
RX can be edited just as any other text via standard tools. But it is intended to be edited in a special editor that respects and exploits its semantics.