Peter Marinov: 1
Add syntax coloring for Gemini markup via `awk`
4 files changed, 90 insertions(+), 2 deletions(-)
Hello Greg,
Hi Peter,
Peter Marinov <pmar21@sonic.net> writes:
Hello Greg,
Peter Marinov <pmar21@sonic.net> writes:
Hi Peter,
You should know that, since my last email, I’ve made a number of changes
to gmi inspired by your contributions. I’m quite pleased with the
results even if the program is some 13 lines longer for it.
Hello Greg,
I was thinking that the main problem that the formatting has to solve
is wrapping of long lines. The coloring is nice but the wrapping is
what makes the navigation of pages pleasant to read.
Go to this page for example:
gemini://guardian.shit.cx/uk-news/business/2021/may/19/uk-rail-overhaul-privatised-great-british-railways-/index.gmi
Another good one is with combination of code sections + quote sections
and long lines in all of them:
gemini://drewdevault.com/2021/05/03/awk-is-the-coolest-tool-you-dont-know.gmi
Try with and without the gawk script
(Maximize your terminal window for maxium effect)
Hmm, good point. It is much more readable with your gawk script.
Now, if you want an even simpler solition, instead of coloring you can
pipe through `fold` (although that would be indiscriminate, it would
fold even code sections and will mangle the quotes sections, but you
can try it to get a sense of what it is)
I don’t think fold can repeat the "> " prefix, so Awk is probably the
right tool for that job.
A bug, I guess you have to mention `uuencode` in the README as
required:
$ ./gmi gemini://drewdevault.com
./gmi: 58: uuencode: not found
I found POSIX man pages for uuencode and uudecode on my system, so I
assumed they were required utilities. It seems base64(1) may be more
portable so I may switch gmi over to that instead.
A bug, you have to invoke `less` with option --raw for the coloring to
show up
Gemtext documents are now rendered with syntax colouring using a
portable Awk script embedded in gmi itself. It’s enabled by default,
but can be disabled by setting the PAGER environment variable. See the
Git log for more details about this.
I think the variable PAGER is too generic, it is used to point to
`less` or equivalents. `lessgmi` itself it nos universal pager but a
pager for GMI pages. I think GMI_PAGER is a better name with less of a
chance of a conflict
As documented in the readme, gmi still lacks rendering of bold and
italic text inline. My Awk skills are limited so, if anyone is able to
share a patch for this, that would be ace. Until then I will be
chipping away at the wishlist/to-do list in the readme.
I guess I can look into that. Basically a coloring script without
wrapping of lines
I’ve added "pretty line wrapping" to the wishlist/to-do list. It is an
important feature I had overlooked. I’ll have another read of your gawk
script and see if I can rewrite it in standardised Awk as part of the
embedded script -- or feel free to share a patch.
Hello Greg,
After your last two messages I got into action and this evening I'm
sending you a self-contained `lessgmi` pager
I think it will be alright if `gmi` installs two files -- the
main script itself and the pager `lessgmi`. Both are small and
individually easy to reason about and understand.
Because `lessgmi` now works with any (well the 2 I could test with)
`awk` I suggest this to be plugged as the default pager for
`gmi`. Then diverting to `less` could be an option.
I've also cleaned the script code and I hope it is easier to
understand and manipulate
I hope with this it has crystalized to its final form
:-)
A PROBLEM:
`lessgmi` can only receive content via a pipe, I simply couldn't make
it operate via a file from the command line, I hope you can make that
work so it is a proper pager (I imagine people might use it to open
local .gmi files)
Example:
cat README.gmi | lessgmi = Works
lessgmi READM.gmi = Doesn't
--pe
Greg.
--pe
Regards,
Greg.
Peter Marinov <pmar21@sonic.net> writes:
Peter Marinov <pmar21@sonic.net> writes:
Hadn’t thought of it that way. Much of that is owed to the limited
scope of the Gemini protocol and the simplicity of text/gemini. My
initial reaction to Gemtext markup was that it was way too restrictive
for authors, especially since it lacks inline links. Writing a client
has given me a new perspective on that.
Greg.