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.Markdown

Description

A tiny gemtext to Markdown converter for gemmula.

Encodes parsed gemtext documents and lines into Markdown Text. Follows the CommonMark specification.

Synopsis

Encoding documents

encode :: GemDocument -> Text Source #

Encode parsed GemDocument into a Markdown file. The output Text uses LF line breaks.

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

The adjacent links are grouped together in a paragraph to make them look pretty.

Empty GemTexts and GemLists are ignored.

Encoding single items

prettyItem :: GemItem -> Text Source #

Encode a single parsed GemItem into Markdown text.

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

Valid Markdown characters are escaped before encoding.

Unlike encodeItem, long lines (> 80) will be split to multiple lines to make it look prettier. The link items are also put in a seperate line to make them look nice.

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

encodeItem :: GemItem -> Text Source #

Encode a single parsed GemItem into Markdown text.

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

Valid Markdown 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 .md links.

Beware that this only applies to local GemLinks. For rewriting non-local links as http, see webifyLink.