💾 Archived View for siiky.srht.site › projects › gemtext.gmi captured on 2023-09-28 at 16:32:49. Gemini links have been rewritten to link to archived content
⬅️ Previous capture (2023-03-20)
-=-=-=-=-=-=-
siiky
2022/07/05
2022/07/05
en
Yesterday I made a Scheme library to read Gemtext into a simple AST: a list of lines of text, headers, links, list blocks, or code blocks.
some text
"some text"
Just a string, not tagged in any way. Empty lines are kept.
^(#+)\s+(.*)$
`(header ,(string-length $1) ,$2)
If *strict-gemtext-headers* is enabled, header lines of level > 3 are not considered headers.
##### title
"##### title" ; (w/ *strict-gemtext-headers* enabled) '(header 5 "title") ; (w/ *strict-gemtext-headers* disabled)
=> some-uri.gmi Optional alt text
'(link "some-uri.gmi" "Optional alt text")
If there's no alt text, the empty string is used:
=> some-uri.gmi
'(link "some-uri.gmi" "")
'(list "item 1" "item 2")
(pretend there's no space between the three backticks)
`` `some optional alt text some pre-formatted text `` `
'(code "some optional alt text" "some" "pre-formatted" "text")
If there's no alt text, the empty string is used:
`` `some optional alt text some pre-formatted text `` `
'(code "" "some" "pre-formatted" "text")
# Factorial There are two steps to compute the factorial of a number:
'((header 1 "Factorial") "" "There are two steps to compute the factorial of a number:" "" (list "Compute the list of integers from 1 up to the number" "Multiply all the integers of the list") "" (link "gemini://gemi.dev/cgi-bin/wp.cgi/view/en?Factorial" "") (link "gemini://gemi.dev/cgi-bin/wp.cgi/view/en?Factorial" "Factorial") "" (header 2 "Haskell code") "" "Here's the code in Haskell:" "" (code "hs" "fact n = prod [1..n]"))
(header level title) (link uri alt-text) (code alt-text . lines) (list . items)