LOWDOWN_ODT_RNDR(3)

πŸ“¦
version 3.2.1 Β· 2 versions
, in alpine 3.24, arch rolling, debian trixie, fedora 43, fedora 44, nixpkgs unstable, opensuse-leap 16.0, ubuntu noble, ubuntu questing, ubuntu resolute, ubuntu stonking

✨ LOWDOWN_ODT_RNDR(3) ✨

okay bestie, so this is a page from the Library Functions Manual and it's literally about lowdown_odt_rndr πŸ’… buckle up


🌸 NAME 🌸

lowdown_odt_rndr β€” render Markdown into OpenDocument


πŸŽ€ LIBRARY πŸŽ€

library β€œliblowdown” β€” yes she has a whole library, main character energy fr


πŸ¦‹ SYNOPSIS πŸ¦‹

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

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

πŸ’– DESCRIPTION πŸ’–

so what this does is it renders a node tree n β€” and that tree has to have been created by lowdown_doc_parse(3) or lowdown_diff(3) β€” using the OpenDocument renderer arg, which you get back from lowdown_odt_new(3). πŸ‘‘

the output gets written into out, and heads up: you (the caller) have to initialise it and free it yourself. no one's doing that for you, bestie 😭

and what comes out the other side? an OpenDocument document. that's the whole vibe. ✨


⭐ RETURN VALUES ⭐

  • returns zero on failure to allocate memory (boooo πŸ’€)
  • returns non-zero on success (slay πŸ‘‘)

πŸ”₯ EXAMPLES πŸ”₯

here's the moment you've been waiting for β€” this parses b of length bsz and outputs in β€œflat” OpenDocument format. no cap, it's giving iconic:

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

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_odt_new(NULL)) == NULL)
        err(1, NULL);
if (!lowdown_odt_rndr(out, rndr, n))
        err(1, NULL);

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

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

see how everything gets freed at the end? that's the clean-up routine, we love a tidy queen 🧚


πŸ’œ SEE ALSO πŸ’œ

go read those too, iykyk πŸ“š


🌈 STANDARDS 🌈

the referenced OpenDocument standard is 1.3, and here's the link exactly as it lives: https://docs.oasis-open.org/office/OpenDocument/v1.3/ 🫢


a gentle reminder from your girl: out is your responsibility to initialise and free. don't be the person who forgets. that's not the vibe. πŸ™ˆ

and that's the whole page!! this one shipped from Debian, version $Mdocdate$, and it goes by LOWDOWN_ODT_RNDR(3) β€” periodt πŸ’…πŸ’–