# plaintxt: An everlasting formatted text

Take great ideas from gemtext, markdown and others.
Define a better syntax.

See directories for implementations in awk and c.

## About plaintext and markups

### Plaintext

Plaintext will be readable forever, instead of some other file formats.

It is VERY light.
As example, a plaintext file with "Hello!" weighs only 7B.
Save is as a docx and it weights 4,9KB!

You can shape your text the way you like.

Also, it works well with screen readers.

See also "Writing for the internet across a human lifetime"
=> https://web.archive.org/web/20211025182333/https://len.falken.ink/misc/writing-for-the-internet-across-a-human-lifetime.txt

### Markup

Some markup tools are handy to render your plain text to other formats,
like html. One can add hyperlinks, titles or even pictures.

A good markup language should be:

* Easy to remember.
* Easy to read.
* Easy to edit (think about git commit).
* Easily convertible to another markup.

One of the most known markup language is Markdown:
=> https://www.markdownguide.org/

It is quite easy to read and remember and edit.

However, it suffers of unbearable flaws:

* Hyperlinks are unreadable.
* Links for pictures are different of hyperlinks.
* There are different implementations, making it inconsistent.
* Unordered lists can't start with a number (except with some magic and
  complexity).

Gemtext is another markup with very good ideas:
=> https://geminiprotocol.net/docs/gemtext-specification.gmi

It is very easy to remember and avoid complexity.
It is also very easy to convert it to another markup.

However, its line-oriented mindset can make it difficult to read for
long lines.

## A better text syntax

To shape your text, the following characters are written at the
beginning of a line:

```
# --- => * > !!! ``` %%%
```

* # : header (title).
  1 to 6 "#" may be used to distinguish header levels.
* --- : horizontal rule.
* => : a link.Images, Audio and videos are supported,
  not only hyperlinks to other site.
* * : new list item.
* > : quote.
* !!! : important message (strong).
* ``` : begin/stop a code block.
* %%% : begin/stop a verbatim block.

Two blocks should be separated by an empty line for readability.

Two consecutive empty lines force a line break.

Any other line is part of a paragraph.

This is less than 10 to remember.

If one of the previous chars must be written at the beginning of a line
without formatting, they must be written after a space.

### Headers

```
# Header 1
## Header 2
### Header 3
```

A header line start with one to six "#" character.

Heading level 4, 5, 6 should be avoided : 3 levels are enough for
sanity.

Spaces after the last "#" are optional.

### Horizontal rules

```
---
```

A line starting with "---" is turned into an horizontal rule.

### Links

```
=> https://foo.bar
=> https://another.link Link with description
=> https://this.is/a-picture.jpg Alt text

The description for the following link is very long,
so it is written before:
=> http://one-last.link
```

A link should be easy to copy/paste, so it's written on a single line.
A link must be identified easily: it is after "=> " chars.
A link must be described.
The description is written after the link on the same line, on in a
paragraph before the link for long descriptions.

An image, an audio file or a video can be inserted with their URL.
The parser will detect the extension.
End the URL with a "?" or a "#" so it is considered as a link to the
resource.

### Lists

```
* Item 1
* Item 2
* Item 3
* Item 4 a little too long so
  it is split on two lines
```

Lists items are identified with lines starting with "*".
To actually write a "*" in a long item after a line break, add a space
at the beginning of the line.

### Quotes

```
> This is a quote. -- author

> This is a very long quote
on multiple lines
-- another author
```

A line starting with a ">" open a new quote block.

### Warning/Important

```
!!! This is a very important message
```

A line starting with "!!!" must be displayed as a very important
warning.

### Code blocks

```
 ```
	/* This is a code block */

	#include <stdio.h>

	int
	main(int argc, char *argv[])
	{
	    return 0;
	}
 ```
```

A line starting with "```" enable or disable pre-formatted mode.

### Verbatim

```
%%%
This is verbatim code that won't be turned into anything
<details>
    <summary>Click to show more</summary>
    Surprise!
</details>
%%%
```

Start a line with "%%%" to open/close a verbatim block.

## FAQ

### But I miss <insert feature here>!

Maybe it is time to reconsider how the text is organised.
Often, the result is clearer.

Otherwise, another markup may be more suited to your needs?

### Tables?

no

If you really need table, use ascii tables in pre-formatted blocks.

=> https://plaintexttools.github.io/plain-text-table/
=> https://www.tablesgenerator.com/text_tables
=> https://asciiflow.com/#/

### How do I add nested lists?

You can't.
Nested lists are a pain to read.

### How do I write numbered lists?

Just add numbers:

```
* 1. First item
* 2. Second item
* 3. Third item
```

### How do I insert empty lines?

Just add a space at the beginning of a line to force a line break.
Actually, this will insert and empty paragraph.

### How to I add bold, italic, underlined text?

You can't.
Using "__underline__", or "**bold**" or even "//italic//" is awful for
screen readers, and for readers too.
If you want to emphasize some part :

* USE CAPITALS
* Write the important text on its own line
* Use a "!!!" block

### How to insert subscript?

Use utf-8 : H₂O

### How to insert a footnote

Please don't.

footnotes are annoying : the reader is forced to go down the whole
text, then back up.

However, a well written sentence or even parentheses -- or such thing
-- are much easier to read.

### How do I link a picture or a video without displaying it?

End the URL with a "?" or a "#" so it is considered as a link to the
resource.

### Which file extension should I use?

You may use ".pot" file extension, like "prx's opinionated text".
Or maybe ".bts" like "better text syntax".

Just kidding, it doesn't matter.
I personally use ".txt", since it's plaintext after all.
