Copyright | (c) Sena 2024 |
---|---|
License | AGPL-3.0-or-later |
Maintainer | Sena <jn-sena@proton.me> |
Stability | stable |
Portability | portable |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Text.Gemini
Description
A tiny gemtext (unofficially text/gemini
) parser
Parses gemtext documents from and back to Text
.
See the Gemini hypertext format specification at https://geminiprotocol.net/docs/gemtext-specification.gmi.
Gemtext types
type GemDocument = [GemItem] Source #
A gemtext document, in the form of an ordered list of GemItem
s
A gemtext item
Constructors
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] | An unordered gemtext list -- |
GemQuote !Text | A gemtext quote -- |
GemPre ![Text] !(Maybe Text) | A preformatted gemtext block -- |
Decoding from text
decode :: Text -> GemDocument Source #
Parse a gemtext block as GemDocument
.
The text should be supplied as a Text
which uses LF line breaks.
decodeLine :: Text -> GemItem Source #
Encoding into text
encode :: GemDocument -> Text Source #
Encode a parsed GemDocument
into a gemtext block.
The output Text
uses LF line breaks.
Valid prefixes are escaped before encoding. See the encodeItem
function below.
Empty lists are ignored if given.
encodeItem :: GemItem -> Text Source #