Re: Syntax highlighting


Nathan Galt <mailinglists@ngalt.com> writes:

>> On Sep 19, 2021, at 1:43 AM, raingloom <raingloom@riseup.net> wrote:
>> 
>> On Sun, 12 Sep 2021 18:14:07 +0000
>> mntn@mntn.xyz wrote:
>> 
>>> The Gemtext spec would seem to have no problem with this, as the
>>> first line is considered "alt text" and it is up to the client to
>>> determine both what should be done with it and how it should affect
>>> the presentation. But I wanted to put this out there to get a broader
>>> perspective.
>> 
>> That's not what alt text is. It's for screen readers. A bunch of people
>> are way into ASCII art so alt text is needed. They are image
>> descriptions.
>> 
>> I recommend the following instead:
>> Just name the language on the line before the <pre> block.
>> ie.:
>> 
>> lua:
>> ```
>> local function whatever() end
>> ```
>> 
>> This way you aren't making an accessibility feature worse by trying to
>> overload it to be some generic metadata container.
>
> Someone floated the idea of using the leading ``` line for alt text
> and the trailing ``` line for language colorization (or maybe the
> reverse). It sounded like a good idea to me, but the current
> maintainer of the Gemini spec (not unreasonably) has a
> try-it-first-and-report-back attitude to these sorts of things and, as
> far as I can tell, nobody’s modified a Gemini browser to try this sort
> of thing out.

Using the trailing ``` has a ugly drawback: we have to read all the code
block before being able to colorize it.  Gemini has a really nice
property of needing only the first few bytes of each line to decide its
"type", there's no going back and forward like it is for markdown (where
link references can be declared after the link itself) or HTML.  This
allows a really cool property: text/gemini files can be *streamed* on
the fly and easily parsed on the fly.  For instance: a irc-like
application can have a page that never stop loading where all the
message "appear" as soon as someone sends them, and a second page where
the users can send text.

That said, regarding the try-and-report part, if someone really wants to
see how this could work, I suggest try hacking something on top of
elpher: Emacs is really cool for this kind of things and already has
syntax highlighting for various programming languages.

Cheers,

---

Previous in thread (9 of 11): 🗣️ Nathan Galt (mailinglists (a) ngalt.com)

Next in thread (11 of 11): 🗣️ Alexis (flexibeast (a) gmail.com)

View entire thread.