logo

oasis-root

Compiled tree of Oasis Linux based on own branch at <https://hacktivis.me/git/oasis/> git clone https://anongit.hacktivis.me/git/oasis-root.git

gemini.lua (892B)


  1. -- Copyright 2020-2024 Haelwenn (lanodan) Monnier <contact+gemini.lua@hacktivis.me>. See LICENSE.
  2. -- Gemini / Gemtext LPeg lexer.
  3. -- See https://gemini.circumlunar.space/docs/specification.html
  4. local lexer = lexer
  5. local P, S = lpeg.P, lpeg.S
  6. local lex = lexer.new(...)
  7. local header = lex:tag(lexer.HEADING .. '.h3', lexer.to_eol(lexer.starts_line('###'))) +
  8. lex:tag(lexer.HEADING .. '.h2', lexer.to_eol(lexer.starts_line('##'))) +
  9. lex:tag(lexer.HEADING .. '.h1', lexer.to_eol(lexer.starts_line('#')))
  10. lex:add_rule('header', header)
  11. lex:add_rule('list', lex:tag(lexer.LIST, lexer.to_eol(lexer.starts_line('*'))))
  12. lex:add_rule('blockquote', lex:tag(lexer.STRING, lexer.to_eol(lexer.starts_line('>'))))
  13. lex:add_rule('pre', lex:tag(lexer.CODE, lexer.to_eol(lexer.range('```', false, true))))
  14. lex:add_rule('link', lex:tag(lexer.LINK, lexer.to_eol(lexer.starts_line('=>'))))
  15. return lex