💾 Archived View for rawtext.club › ~sloum › geminilist › 007297.gmi captured on 2024-03-21 at 15:55:58. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2021-11-30)

-=-=-=-=-=-=-

<-- back to the mailing list

[spec] comments on the proposed gemini spec revisions

Chris McGowan cmcgowan9990 at gmail.com

Wed Oct 13 21:38:32 BST 2021

- - - - - - - - - - - - - - - - - - - 
Unfortunately, no. For example, take this line: `# Foo bar I'm a level-1 title`
A 3-char substring of that would yield "# F", which isn't useful.

In what way isn't it useful? It tells you literally everything you need to know. An example (in Perl):

>/ ){   return "Link"}elsif( $first3 =~ m/```/ ){   return "preformatted";}elsif( $first3 =~ m/\*/ ){   return "list item";}elsif ( $first3 =~ m/
>/ ){   return 'Blockquote';}else{   return "Text";}```

That's a simplified, very naive gemtext parser I wrote in my email client in about 3 minutes. It took longer to remember all of the list types than it did to write the code for them. In fact, the substring isn't even necessary in this code as I could anchor the regex at the start of the line like so:

but that's largely true for languages which have decent regex support. If you weren't using one of those (i.e. C) or are for some reason allergic to regexes you could simply index the string to determine the line type (note: this would likely improve speed, but probably only a imperceptibly small amount and likely wouldn't be worth it.)

Just to really drive home the point that this isn't a difficult task, here's the version I wouldn't write unless I was using C (still in Perl though):

>' ){   return "link";}elsif ( $first3[0] eq '*' ){   return 'List Item';}elsif ($first3[0] eq '
>' ){   return "Blockquote";}elsif( $first3[0] eq '`' && $first3[1] eq '`' && $first3[2] eq '`' ){   return "preformatted";}else{   return "Text";}```

It's a bit more annoying to write, sure but it's still really simple. That's ~33 lines of code (mostly because of the Allman style braces, honestly.) It only took me 5 minutes to write.

In summary, I hardly think it's impossible or even difficult to unambiguously parse gemtext without having a mandatory space.