LOWDOWN_HTML_NEW(3)

hey bestie πŸ’… welcome to LOWDOWN_HTML_NEW(3) β€” the liblowdown Library Functions Manual page that’s all about allocating your very own Markdown HTML renderer ✨

πŸ’– NAME πŸ’–

lowdown_html_new β€” allocate a Markdown HTML renderer, bestie πŸŽ€

πŸ“š LIBRARY πŸ“š

library β€œliblowdown” β€” that’s the squad 🫢

✨ SYNOPSIS ✨

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

void *
lowdown_html_new(const struct lowdown_opts *opts);

🌸 DESCRIPTION 🌸

okay so lowdown_html_new allocates an HTML5 renderer using opts->flags, or zero if opts is NULL. that opts->flags field has its whole own explanation in lowdown(3), iykyk πŸ“–

the returned pointer is reusable: you can use it with multiple invocations of lowdown_html_rndr(3), and you must free it with lowdown_html_free(3). no leaking, bestie πŸ˜­πŸ’€

the bits recognised in opts->oflags are literally these exact ones:

  • LOWDOWN_HTML_HTML_CUSTOM_ATTRS
  • LOWDOWN_HTML_OWASP
  • LOWDOWN_HTML_NUM_ENT
  • LOWDOWN_HTML_HEAD_IDS
  • LOWDOWN_HTML_HARD_WRAP
  • LOWDOWN_SKIP_HTML
  • LOWDOWN_HTML_ESCAPE
  • LOWDOWN_HTML_CALLOUT_MDN
  • LOWDOWN_HTML_CALLOUT_GFM
  • LOWDOWN_STANDALONE

πŸ”₯ RETURN VALUES πŸ”₯

returns a pointer to the renderer or NULL on memory failure. the returned pointer must be freed with lowdown_html_free(3) β€” yes, again, free it, bestie πŸ’…

πŸ¦‹ EXAMPLES πŸ¦‹

the following parses b of length bsz and outputs in HTML format. iconic pipeline behavior:

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);

πŸ‘‘ SEE ALSO πŸ‘‘

lowdown(3), lowdown_html_free(3), lowdown_html_rndr(3) β€” go read those too, bestie 🫢

🌈 STANDARDS 🌈

the referenced HTML5 standard is HTML5.2: https://www.w3.org/TR/html52. output is compatible with prior HTML5 standards. periodt πŸ’…


okay that’s the whole page, bestie 🫢 source/version vibes: Debian; date: $Mdocdate$; title: LOWDOWN_HTML_NEW(3). mwah πŸ’‹βœ¨

πŸ“¦ where this page comes from