Syntax highlighting

Alexis flexibeast at gmail.com
Mon Sep 20 10:03:36 BST 2021


Omar Polo <op at omarpolo.com> writes:

> 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.

And having had to deal with parsing Markdown - due to Markdown 
libraries tending to assume that you want HTML output, and not 
making a parse tree available - i can confirm that this is a nice 
property indeed.

Fwiw, as someone with disabilities (albeit not vision-related), 
and who has watched accessibility affordances on the Web get (to 
put it politely) short shrift over the decades, i tend to agree 
with raingloom:

> 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.


Alexis.


More information about the Gemini mailing list