Line breaks in twtxt

twtxt is a minimalist news feed file format and a protocol for sharing status updates. You can compare it to RSS, the Finger protocol, or a decentralized Twitter.

The twtxt file format does not allow newlines in the text of the status update (or “twt”). Since users of competing technologies often use line breaks in their statuses, not having line breaks limits users’ ability to write what they want in twtxt. For this reason I propose a backwards-compatible convention for line breaks in twtxt: when the client sees a sequence of statuses with the same timestamp in a feed, it should join their text with a newline or another line-breaking sequence as appropriate. To simplify parsing, the client should not merge statuses with the same timestamp in the anomalous situation when they do not occur in sequence.

A feed following this convention looks reasonable in a client that does not understand it as long as the client displays statues with the same timestamp in the order they appear.

For example, the original implementation of twtxt renders the file

1845-01-29T12:00:00Z    Once upon a midnight dreary, while I pondered, weak and weary,
1845-01-29T12:00:00Z    Over many a quaint and curious volume of forgotten lore—
1845-01-29T12:00:00Z        While I nodded, nearly napping, suddenly there came a tapping,
1845-01-29T12:00:00Z    As of some one gently rapping, rapping at my chamber door.
1845-01-29T12:00:00Z    “’Tis some visitor,” I muttered, “tapping at my chamber door—
1845-01-29T12:00:00Z                Only this and nothing more.”

as

➤ http://127.0.0.1:8081/poe.txt (175 years ago):
Once upon a midnight dreary, while I pondered, weak and weary,

➤ http://127.0.0.1:8081/poe.txt (175 years ago):
Over many a quaint and curious volume of forgotten lore—

➤ http://127.0.0.1:8081/poe.txt (175 years ago):
While I nodded, nearly napping, suddenly there came a tapping,

➤ http://127.0.0.1:8081/poe.txt (175 years ago):
As of some one gently rapping, rapping at my chamber door.

➤ http://127.0.0.1:8081/poe.txt (175 years ago):
“’Tis some visitor,” I muttered, “tapping at my chamber door—

➤ http://127.0.0.1:8081/poe.txt (175 years ago):
Only this and nothing more.”

If the convention was implemented, twtxt could render the same file as

➤ http://127.0.0.1:8081/poe.txt (175 years ago):
Once upon a midnight dreary, while I pondered, weak and weary,
Over many a quaint and curious volume of forgotten lore—
While I nodded, nearly napping, suddenly there came a tapping,
As of some one gently rapping, rapping at my chamber door.
“’Tis some visitor,” I muttered, “tapping at my chamber door—
Only this and nothing more.”

I have implemented the convention in my twtxt.tcl library and GUI feed reader.


Tags: file format, Internet, my work, programming, protocol.