Copyright | (c) Sena 2023 |
---|---|
License | AGPL-3.0-or-later |
Maintainer | Sena <jn-sena@proton.me> |
Stability | stable |
Portability | portable |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
A tiny Gemtext (text/gemini
) parser.
Parses Gemtext documents from and back to Text
. See the Section 5 of the
Gemini Protocol specification.
Gemtext Types
type GemDocument = [GemItem] Source #
A Gemtext document, in the form of an ordered list of GemItem
s.
A Gemtext item.
GemText !Text | A regular Gemtext line. -- |
GemLink !Text !(Maybe Text) | A Gemtext link. -- |
GemHeading !Int !Text | A Gemtext heading of 3 levels max. -- |
GemList ![Text] | A Gemtext unordered list. -- |
GemQuote !Text | A Gemtext quote. -- |
GemPre ![Text] !(Maybe Text) | A Gemtext preformat. -- |
Decoding from Text
decode :: Text -> GemDocument Source #
Parse a Gemtext file as GemDocument
.
The text should be supplied as an LF-ending Text
.
decodeLine :: Text -> GemItem Source #
Encoding as Text
encode :: GemDocument -> Text Source #
Encode parsed GemDocument
as a Gemtext file.
The output Text
uses LF-endings. Uses the encodeItem
function below.
Valid prefixes are escaped before encoding.
Empty lists are ignored if given.
encodeItem :: GemItem -> Text Source #