LOWDOWN_GEMINI_RNDR(3)

πŸ“¦
version 3.2.1 Β· 3 versions
, in alpine 3.24, arch rolling, debian trixie, fedora 43, fedora 44, nixpkgs unstable, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ’– LOWDOWN_GEMINI_RNDR(3) πŸ’–

okay bestie, welcome to lowdown_gemini_rndr from the Library Functions Manual β€” this is the lil function that turns your Markdown into gemtext and honestly? it ate. πŸ’…


✨ NAME ✨

lowdown_gemini_rndr β€” render Markdown into gemini πŸ¦‹


πŸ“š LIBRARY πŸ“š

library β€œliblowdown” β€” she lives in there, that's her house 🏠


🌸 SYNOPSIS 🌸

#include <sys/queue.h>
#include <stdio.h>
#include <lowdown.h>

int
lowdown_gemini_rndr(struct lowdown_buf *out, void *arg,
    const struct lowdown_node *n);

πŸ‘‘ DESCRIPTION πŸ‘‘

So here's the tea, bestie πŸ“ β€” this function renders a node tree n that was created by lowdown_doc_parse(3) or lowdown_diff(3), using the gemini renderer arg as returned by lowdown_gemini_new(3). The output gets written into out, and you (the caller, the main character) are responsible for initialising it and freeing it. no cap. 🫢

The caller is also expected to have invoked setlocale(3) to a "UTF-8" character encoding before using this function β€” otherwise UTF-8 sequences will not be properly recognised. and where does that matter, you ask? it's used when formatting table column widths πŸ“. so like, set your locale or your tables are gonna be lowkey busted. 😭


⭐ RETURN VALUES ⭐

  • returns zero on failure to allocate memory πŸ’€
  • returns non-zero on success ✨

that's it. that's the whole vibe check.


πŸŽ€ EXAMPLES πŸŽ€

The following parses b of length bsz and outputs in Gemini format. look at her go 🧚

struct lowdown_buf *out;
struct lowdown_doc *doc;
struct lowdown_node *n;
void *rndr;

if (setlocale(LC_CTYPE, "en_US.UTF-8") == NULL)
        err(1, NULL);
if ((doc = lowdown_doc_new(NULL)) == NULL)
        err(1, NULL);
if ((n = lowdown_doc_parse(doc, NULL, b, bsz, NULL)) == NULL)
        err(1, NULL);
if ((out = lowdown_buf_new(256)) == NULL)
        err(1, NULL);
if ((rndr = lowdown_gemini_new(NULL)) == NULL)
        err(1, NULL);
if (!lowdown_gemini_rndr(out, rndr, n))
        err(1, NULL);

fwrite(out->data, 1, out->size, stdout);

lowdown_gemini_free(rndr);
lowdown_buf_free(out);
lowdown_node_free(n);
lowdown_doc_free(doc);

notice how she frees everything at the end? that's called ✨being responsible✨ and we love that for us. 🌈


πŸ”₯ SEE ALSO πŸ”₯

go read those next, bestie, iykyk πŸ’œ


🌟 STANDARDS 🌟

The gemini β€œgemtext” format is documented in Project Gemini: https://geminiprotocol.net. The version at the time of writing is 0.24.1. πŸ¦‹


and that's the whole page, periodt πŸ’… thanks for coming to my TED talk, go render some gemtext and slay ✨

β€” Debian, $Mdocdate$, LOWDOWN_GEMINI_RNDR(3) πŸŽ€ bye bestie, ily πŸ«ΆπŸ’–

πŸ“¦ where this page comes from