tttml patch
===================================================================
More Nim coming soon. Today I'm making note of a new pair of
files in my "Gopher Stuff" directory. [1]
So I've got a chicken-and-egg problem: I intend to write an
AsciiDoc-to-text (formatted specifically for Gopher clients)
converter (in Nim, naturally). But until I do, I still need some
way of formatting this phlog and any other material I post to my
burrow.
After browsing around on Bitreich's gopher site [2] for a while, I
came across the "tttml" (Text To Text Markup Language) project.
This was exactly what I needed! It allows me to write in my
prefered method: one sentence per line in plain (UTF-8, but really
just the ASCII subset) text. Then a tool reformats paragraphs for
fixed-width output while preserving indented blocks, re-flowing
quotes, lists, and handling the spacing and formatting of of
titles and headings. In other words, I avoid toil unless it has a
specific artistic purpose.
The core tool for me is tttml-fmt. [4] It's a well-formatted AWK
script, so it's readable, compact, and fast.
The only "problem" is that it's hard-coded to output 80-column.
I don't know if there are still some 65, 70, or 72 column
terminals still in use out there (some of you hard-core retro
folks might own something like that), but I do know that I like
using tiling window managers and small devices which often
restrict my virtual terminal width quite a bit. Also, I use the
DiggieDog Android app on my phone (which has been a wonderful
replacement for mindlessly scrolling through Instagram for the
last month!) and I can say for sure that somewhere around 70
columns fits very nicely on the screen in landscape view.
(As an aside, I have been having lots of thoughts about there
being a "native" text format for Gopher clients which would
preserve ASCII art but would allow paragraphs to reflow for
different screen sizes. But that's a whole other ball of wax.)
Anyway, I made some simple modifications to `tttml-fmt` to have it
output at 68 columns/characters per line and I've been happily
using it ever since.
(If I didn't plan to build my own tool, I would probably modify
tttml-fmt further to take a width command line argument, which
would clearly be the correct way to improve the tool.)
The modifications are very simple. But I decided to turn them
into a patch and throw them up on my burrow for two reasons:
- I have never distributed a traditional source patch before, so I
thought it would be a fun learning experience
- I wanted something else to put in my barren "Gopher Stuff"
directory
So there you have it!
[1]
gopher://sdf.org/1/users/ratfactor/gopher [2]
gopher://bitreich.org/ [3]
gopher://bitreich.org/1/scm/tttml/log.gph [4]
gopher://bitreich.org/1/scm/tttml/file/tttml-fmt.gph
Community notes
-------------------------------------------------------------------
It's been fun seeing new "hello world" phlog posts on SDF this
last week. I read pretty much every phlog update on gopher.club
and Bongusta! so keep it up, fellow newbies!