[users] Tables in Gemtext

Paper paper at tilde.institute
Sat Jan 2 23:25:29 GMT 2021


On Sat, Jan 02, 2021 at 06:13:45PM +0000, Luke Emmet wrote:
> On 02-Jan-2021 03:04, Kiëd Llaentenn wrote:
> > Just recently I was creating a Gemini mirror of an HTTP site, and came
> > across several pages that made heavy use of tables. I did what I suspect
> > most Gemini publishers/content authors do: use ASCII tables, like so:
> > 
> > +--------------------------------+-------+
> > | Food                           | Price |
> > +--------------------------------+-------+
> > | Eggs                           | $2    |
> > | Eggs and spam                  | $4    |
> > | Eggs, spam, eggs and spam      | $8    |
> > | Spam spam baked beans and spam | $8    |
> > | Just spam                      | $2    |
> > +--------------------------------+-------+
> > 
> > There are several problems with this approach, though:
> > 
> > 1. It requires the client to display the table in a monospaced font,
> >     which many would prefer not to use.
> > 2. Text in table rows won't be wrapped properly on narrow displays.
> > 3. ASCII tables are anything but screenreader friendly, since there's no
> >     semantic information about the table's structure.
> > 4. It mixes information and presentation, which is against the spirit of
> >     Gemini(?)
> > 
> > So, are there any other options for having tables in Gemtext, other than
> > adding a new syntax to the spec? I'm hard pressed to think of another
> > solution.
> Some other ideas:
> 
> If you want to present the information in its original structure, there are
> other options
> (as well as trying to inline it into gemtext preformatted text already
> discussed on this thread):
> 
> 1. provide link to a CSV

We should try to use what we have before designing a new gemtext feature.

Lagrange provides a way to create scripts which handle MIME types lagrange
which are not supported by lagrange natively. We can use this to render CSV:

~/.config/lagrange/mimehooks.txt:

	CSV tables
	text/csv
	/bin/sh;/home/user/bin/csv2txt

~/bin/csv2txt:

	#!/bin/sh
	printf "20 text/plain\r\n"
	/bin/column -s, -t

Don't forget to make this script executable. Now, test how well it works:

gemini://gempaper.strangled.net/experiments/ubuntu-versions.csv

picture: https://ttm.sh/dvO.png

This is obviously not optimal:

* there are no cell borders (can be fixed easily)
* wide tables will overflow the border to the right (can be fixed in the
  client)
* if you link to a csv file, clicking on it will open it in a new
  frame, not inside the text like images (lagrange specific feature,
  can be fixed)
* only lagrange supports MIME hooks (can we improve this?)

But also has many advantages:

* embraces an existing format
* doesn't require anything special in gemtext
* even big tables can work
* if some clients choose to support CSV natively, they can do fancy
  tricks like sorting by columns

~paper


More information about the Gemini mailing list