LOWDOWN_ROFF_RNDR(3)

πŸ’– LOWDOWN_ROFF_RNDR(3) πŸ’–

okay so bestie, welcome to the Library Functions Manual entry for lowdown_roff_rndr β€” and yes she lives in the library β€œliblowdown”, come on in 🫢


✨ NAME ✨

lowdown_roff_rndr β€” render Markdown into roff πŸ’…


πŸ“š LIBRARY πŸ“š

library β€œliblowdown” 🌸


πŸŽ€ SYNOPSIS πŸŽ€

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

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

πŸ¦‹ DESCRIPTION πŸ¦‹

so basically, this function takes a node tree n β€” the kind you get from lowdown_doc_parse(3) or lowdown_diff(3) β€” and renders it with the roff renderer arg, which you get back from lowdown_roff_new(3). ✨

the output gets written into out, and heads up: out is your responsibility. you initialise it, you free it. no one else is gonna do that for you, bestie. πŸ’…

the output is roff output made with the ms, mdoc, or man macro packages. iconic range honestly.

oh and fun history moment 🫢 β€” this function used to be called lowdown_nroff_rndr(). glow-up era.


🌈 RETURN VALUES 🌈

  • returns zero on failure to allocate memory 😭
  • returns non-zero on success πŸŽ‰

like yes, she's quirky like that. zero = bad news, non-zero = we ate.


⭐ EXAMPLES ⭐

here's the vibe: this parses b of length bsz and outputs in groff_ms(7) format. periodt.

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

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

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

look at all that cleanup at the end β€” main character energy, no leaks on her watch πŸ‘‘


πŸ‘€ SEE ALSO πŸ‘€

okay so this thing uses both the original troff man macros for Version 7 AT&T UNIX, defined in man(7), and the man-ext groff extensions. both of them are implemented in mandoc. πŸ’–

the mdoc macros are defined in mdoc(7). πŸ¦‹

and the troff ms macros are defined in groff_ms(7), along with the mspdf groff extensions described in "Portable Document Format Publishing with GNU Troff" by Keith Marshall. lowkey important: neither of those two are implemented in mandoc. 🚨

ngl, if you're counting on ms + mspdf working under mandoc, vibe check says no. πŸ™ˆ

and that's the whole page, bestie!! πŸ’œ this one comes from the Debian crew, dated $Mdocdate$, and she signs off as LOWDOWN_ROFF_RNDR(3) 🌸✨ bye pookie, go render some roff πŸ’…πŸŽ€

πŸ“¦ where this page comes from