LOWDOWN_TREE_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_tree_rndr β€” the manual page bestie πŸ’…

okay so real talk, this is LOWDOWN_TREE_RNDR from section 3 of the manual (Library Functions Manual), and it lives in the liblowdown library. she's a little niche but she is iconic for debugging. let's get into it ✨


🌸 NAME 🌸

lowdown_tree_rndr β€” render Markdown into debugging output πŸ›βœ¨


πŸ“š LIBRARY πŸ“š

library β€œliblowdown” 🫢


✨ SYNOPSIS ✨

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

int
lowdown_tree_rndr(struct lowdown_buf *out, const struct lowdown_node *n,
    const struct lowdown_opts *opts);

like look at that signature. gorgeous. no notes πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

okay so what she does is render a node tree n β€” and bestie, that tree has to have been made by lowdown_doc_parse(3) or lowdown_diff(3), no bootleg trees allowed πŸ™…β€β™€οΈ β€” and the whole thing gets written into out. heads up: out must be initialised and freed by the caller. that's on you, not her. main character energy means knowing your own responsibilities πŸ’–

the output? it's a whole UTF-8 tree 🌳 ngl the format is not standardised and is subject to change, so don't go building your entire personality around parsing it, k? it's giving "just for the vibes, just for debugging."

and here's the tea: unlike every other renderer in the family, lowdown_tree_rndr() accepts no options β€” so she has no context. literally zero. she's just here to show you the tree. periodt. 🌈


πŸ‘‘ RETURN VALUES πŸ‘‘

  • returns zero when it fails to allocate memory 😭 (yes, zero = bad, it's giving chaotic but that's the rule)
  • returns non-zero on success ✨ slay

πŸŽ€ EXAMPLES πŸŽ€

okay bestie here's the whole routine: this parses b of length bsz and outputs the parse tree. copy it exactly, no improvising 🫢

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 (!lowdown_tree_rndr(out, n))
        err(1, NULL);

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

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

see how every single allocation gets checked and every single thing gets freed? that's the vibe check passing with flying colors πŸ’― don't skip the frees, i'm begging πŸ™ˆ


πŸ”₯ SEE ALSO πŸ”₯

iykyk, go read the main page for the whole lore 🌸


k bye, this page is from Debian, version $Mdocdate$, and yes the title really is LOWDOWN_TREE_RNDR(3) β€” go forth and debug ur trees bestie πŸ’–πŸŒ³βœ¨

πŸ“¦ where this page comes from