LOWDOWN_HTML_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_HTML_RNDR(3) ✨

okay bestie, pull up a chair, we're doing lowdown_html_rndr from the liblowdown library πŸ’– this is a Library Functions Manual situation and honestly? iconic.


🌸 NAME 🌸

lowdown_html_rndr β€” render Markdown into HTML πŸ¦‹

πŸ“š LIBRARY πŸ“š

the library is β€œliblowdown”, no cap 🫢

✨ SYNOPSIS ✨

like, here's what you gotta include first, literally:

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

and the function signature goes a little something like:

int
lowdown_html_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 be one that was created by lowdown_doc_parse(3) or lowdown_diff(3) β€” and it uses the HTML renderer arg as returned by lowdown_html_new(3). πŸ‘‘

the output gets written into out, and listen, out must be initialised and freed by you, the caller. not us. that's on you bestie 😭 that's your main character responsibility.

and the output? it's a UTF-8 HTML5 document 🌈 periodt.

πŸ”₯ RETURN VALUES πŸ”₯

  • returns zero on failure to allocate memory πŸ’€
  • returns non-zero on success βœ…

that's the whole vibe check, fr fr.

πŸŽ€ EXAMPLES πŸŽ€

okay so here's the moment you've been waiting for. the following parses b of length bsz and outputs in HTML format ✨ obsessed:

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

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

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

look at all that cleanup at the end 🧚 she's responsible, she's balanced, she frees everything she allocates. we love a tidy queen πŸ’œ

πŸ‘€ SEE ALSO πŸ‘€

go read those too, iykyk πŸ’–

⭐ STANDARDS ⭐

the referenced HTML5 standard is HTML5.2: https://www.w3.org/TR/html52. and the output is also compatible with prior HTML5 standards 🌸 so you're covered either way, no stress.


cute lil sign-off: this page came from the Debian crew, dated $Mdocdate$, and it lives at LOWDOWN_HTML_RNDR(3) πŸ’– thanks for reading, bestie, now go render some HTML πŸ¦‹βœ¨