LOWDOWN_NROFF_RNDR(3)
π lowdown_nroff_rndr β bestie's guide to rendering Markdown into roff β¨
okay so this is LOWDOWN_NROFF_RNDR(3), a page from the Library Functions Manual, and it lives in library βliblowdownβ. yes we're doing C library lore today, stay with me π«Ά
β¨ NAME β¨
lowdown_nroff_rndr β render Markdown into roff
π LIBRARY π
library βliblowdownβ πΈ
π SYNOPSIS π
like, here's the whole vibe, the way you actually call it:
#include <sys/queue.h>
#include <stdio.h>
#include <lowdown.h>
int
lowdown_nroff_rndr(struct lowdown_buf *out, void *arg,
const struct lowdown_node *n);
π DESCRIPTION π
so basically: this function renders a node tree n β and that tree has to have been created by lowdown_doc_parse(3) or lowdown_diff(3) β using the roff renderer arg, which you get back from lowdown_nroff_new(3). no cap. π₯
the output goes into out, and heads up bestie: you are the one who has to initialise it and free it. it is not doing that for you. the audacity? none. it's your job. π
and what even comes out? roff output, using the ms or man macro packages. iconic. π
π RETURN VALUES π
- returns zero if it fails to allocate memory π
- returns non-zero on success β¨
that's it. that's the whole vibe check. lowkey simple, fr fr.
π EXAMPLES π
okay so here's the moment. this parses b of length bsz and outputs in groff_ms(7) format. take notes π:
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_nroff_new(NULL)) == NULL)
err(1, NULL);
if (!lowdown_nroff_rndr(out, rndr, n))
err(1, NULL);
fwrite(out->data, 1, out->size, stdout);
lowdown_nroff_free(rndr);
lowdown_buf_free(out);
lowdown_node_free(n);
lowdown_doc_free(doc);
see how every single thing gets freed at the end? that's the main character energy. clean up after yourself, bestie, the memory doesn't free itself π§
π SEE ALSO π
π¦ deets on the macros, iykyk π¦
this 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 those are implemented in mandoc. slay.
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. and ngl? neither of those are implemented in mandoc. π
πΈ and that's the whole page, bestie. Debian shipped it, the date slot says$Mdocdate$, and it's theLOWDOWN_NROFF_RNDR(3)page. go forth and render, you absolute icon ππ
π¦ where this page comes from
- debian trixie: liblowdown-dev 2.0.2-2 Β· ISC
- fedora 43: lowdown-libs 2.0.2-2.fc43 Β· ISC AND BSD-3-Clause AND MIT
- fedora 43: lowdown-libs 2.0.2-2.fc43 Β· ISC AND BSD-3-Clause AND MIT
- fedora 44: lowdown-libs 2.0.2-3.fc44 Β· ISC AND BSD-3-Clause AND MIT
- fedora 44: lowdown-libs 2.0.2-3.fc44 Β· ISC AND BSD-3-Clause AND MIT
- opensuse-leap 16.0: lowdown-devel 1.1.0+git20231119.1200b9f-bp160.1.13 Β· ISC
- opensuse-leap 16.0: lowdown-devel 1.1.0+git20231119.1200b9f-bp160.1.13 Β· ISC
- opensuse-leap 16.0: lowdown-devel 1.1.0+git20231119.1200b9f-bp160.1.13 Β· ISC
- opensuse-leap 16.0: lowdown-devel 1.1.0+git20231119.1200b9f-bp160.1.13 Β· ISC
- ubuntu noble: liblowdown-dev 1.1.0-1 Β· ISC
- ubuntu questing: liblowdown-dev 2.0.2-2
- ubuntu resolute: liblowdown-dev 2.0.4-2 Β· ISC
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms