gemmula-altera-2.1.1: A tiny gemtext converter for gemmula
Copyright(c) Sena 2024
LicenseAGPL-3.0-or-later
MaintainerSena <jn-sena@proton.me>
Stabilitystable
Portabilityportable
Safe HaskellSafe-Inferred
LanguageHaskell2010

Text.Gemini.Web

Description

A tiny gemtext to HTML converter for gemmula.

Encodes parsed gemtext documents and lines into HTML Text.

Synopsis

Encoding documents

encode :: GemDocument -> Text Source #

Encode parsed GemDocument into a HTML file.

The output Text uses LF line breaks.

Valid HTML characters are escaped before encoding. Uses the prettyItem function below.

Empty GemLists are ignored and empty GemTexts are replaced with /.

Encoding single items

prettyItem :: GemItem -> Text Source #

Encode a single parsed GemItem into HTML text.

The output Text might be multiple lines, in which case it uses LF line breaks.

Valid HTML characters are escaped before encoding.

Unlike encodeItem, long lines (> 80) will be split to multiple lines to make it look prettier. Empty GemTexts 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 does not end with a newline.

encodeItem :: GemItem -> Text Source #

Encode a single parsed GemItem into HTML text.

The output Text might be multiple lines, in which case it uses LF line breaks.

Valid HTML characters are escaped before encoding.

Beware that the output text does not end with a newline.

Rewriting links

rewriteLink :: GemItem -> GemItem Source #

Rewrite .gmi links as .html links.

Beware that this only applies to local GemLinks. 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.

Other

getTitle :: GemDocument -> Maybe Text Source #

Get the text of the first h1 in the document, if there's any.

Useful for using as title.