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 |
A tiny Gemtext to HTML converter for gemmula.
Encodes parsed Gemtext documents and lines as HTML Text
.
Synopsis
- encode :: GemDocument -> Text
- prettyItem :: GemItem -> Text
- encodeItem :: GemItem -> Text
- rewriteLink :: GemItem -> GemItem
- webifyLink :: GemItem -> IO GemItem
- getTitle :: GemDocument -> Maybe Text
Encoding documents
encode :: GemDocument -> Text Source #
Encode parsed GemDocument
as a HTML file.
The output Text
uses LF-endings. Uses the prettyItem
function below.
Valid HTML characters are escaped before encoding.
Empty GemList
s are ignored and empty GemText
s are replaced with /
.
Encoding single items
prettyItem :: GemItem -> Text Source #
Encode a single parsed GemItem
as HTML text.
The output Text
uses LF-endings and might be multiple lines.
Valid HTML characters are escaped before encoding.
Unlike encodeItem
, long lines (> 80) will be split to multiple lines to
make it look prettier. Empty GemText
s are also replaced with /
.
Links have a "scheme" attribute set to "gemini" if the scheme of the URI
is gemini://
, to make them stylable with CSS.
Beware that the output text doesn't end with a newline.
encodeItem :: GemItem -> Text Source #
Rewriting links
rewriteLink :: GemItem -> GemItem Source #
Rewrite .gmi
links as .html
links.
Beware that this only applies to local GemLink
s.
For rewriting non-local links as http
, see webifyLink
.
webifyLink :: GemItem -> IO GemItem Source #
Rewrite gemini://
link as http://
if it can be reached over HTTP.
This is only useful if the specified link has a proxied mirror (like geminiprotocol.net
).
Does nothing if the link is local or can't be reached.