A while back  ago, someone on gopher or  bboard or somewhere
wrote about  using the "par"  utility to format text.  I can
only imagine  it was  on gopher.  I fiddled  with it  a bit,
liked it, and then promptly forgot all about it.

Since  people  have  been  talking about  troff  and  gopher
formatting a  bit, I  thought I'd have  another look.  I use
"nano" to write most of my posts, so I decided to find a way
to create prettier posts with what I already use.

I discovered that for some  time, nano has supported linters
and formatters. However, in the  ^G help for nano, there was
only  a  single keystroke  (^T)  for  invoking the  speller,
linter,  and formatter.  In  reading the  online manual  for
nano, I found  that the settings would  clobber one another,
so I decided to make a script that I would set the ^T action
to invoke, which would both format and spell check.

It's probably about  time I started to  spell-check my phlog
entries anyway...

I used  a bash script,  which rather than explain  I'll just
post here:

   #!/usr/local/bin/bash
   temp_file=$(mktemp)
   /usr/local/bin/par P=[ Ejw60 < $1 > $temp_file
   /usr/local/bin/aspell -x -c $temp_file
   /bin/cat $temp_file > $1
   /bin/rm $temp_file

Nothing fancy, it first justifies everything using par. Note
that I added a protective character  to par, "[", so that my
URL  references at  the bottom  of posts  would be  retained
as-is. I justify at 60 characters width. After that is done,
the script just runs aspell on  the text, and then it cleans
up.

I add this to my nanorc:

   set speller "gopher_format.sh"

and now  ^T helps  me format for  gopher. Of  course, gopher
posts  are  almost  all  I  do in  nano.  I  am  considering
modifying the  script so that the  justification is optional
or user-configurable  at runtime, but it  doesn't matter too
much to me.

Finally,  when I'm  writing  gopher posts,  I'll start  nano
with:

   nano -r60

so that  I have a  rough idea as I  type of how  things will
look when I'm done.

The end result is "what you see here." That is to say, after
I finish typing this, I'm going to hit ^T and run the script
on what I  typed.  If you're reading this, it worked. At the
end of the day, it's not perfect by any means,  but it gives
me the  ability to do a  bit of formatting  without a bit of
effort, and that's nice.