| 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.Markdown
Description
A tiny Gemtext to Markdown converter for gemmula.
Encodes parsed Gemtext documents and lines as Markdown Text.
Follows the CommonMark specification.
Synopsis
- encode :: GemDocument -> Text
- prettyItem :: GemItem -> Text
- encodeItem :: GemItem -> Text
- rewriteLink :: GemItem -> GemItem
Encoding documents
encode :: GemDocument -> Text Source #
Encode parsed GemDocument as a Markdown file.
The output Text uses LF-endings. Uses the prettyItem function below.
Valid Markdown characters are escaped before encoding.
The adjacent links are grouped together in a paragraph to make them look pretty.
Encoding single items
prettyItem :: GemItem -> Text Source #
Encode a single parsed GemItem as Markdown text.
The output Text uses LF-endings and might be multiple lines.
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 doesn't end with a newline.
encodeItem :: GemItem -> Text Source #
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.