1LOWDOWN_HTML_RNDR(3) BSD Library Functions Manual LOWDOWN_HTML_RNDR(3)
2
4 lowdown_html_rndr — render Markdown into HTML
5
7 library “liblowdown”
8
10 #include <sys/queue.h>
11 #include <stdio.h>
12 #include <lowdown.h>
13
14 int
15 lowdown_html_rndr(struct lowdown_buf *out, void *arg,
16 const struct lowdown_node *n);
17
19 Renders a node tree n created by lowdown_doc_parse(3) or lowdown_diff(3)
20 using the HTML renderer arg as returned by lowdown_html_new(3). The out‐
21 put is written into out, which must be initialised and freed by the
22 caller.
23
24 The output consists of a UTF-8 HTML5 document.
25
27 Returns zero on failure to allocate memory, non-zero on success.
28
30 The following parses b of length bsz and outputs in HTML format.
31
32 struct lowdown_buf *out;
33 struct lowdown_doc *doc;
34 struct lowdown_node *n;
35 void *rndr;
36
37 if ((doc = lowdown_doc_new(NULL)) == NULL)
38 err(1, NULL);
39 if ((n = lowdown_doc_parse(doc, NULL, b, bsz, NULL)) == NULL)
40 err(1, NULL);
41 if ((out = lowdown_buf_new(256)) == NULL)
42 err(1, NULL);
43 if ((rndr = lowdown_html_new(NULL)) == NULL)
44 err(1, NULL);
45 if (!lowdown_html_rndr(out, rndr, n))
46 err(1, NULL);
47
48 fwrite(out->data, 1, out->size, stdout);
49
50 lowdown_html_free(rndr);
51 lowdown_buf_free(out);
52 lowdown_node_free(n);
53 lowdown_doc_free(doc);
54
56 lowdown(3), lowdown_html_free(3), lowdown_html_new(3)
57
59 The referenced HTML5 standard is HTML5.2: https://www.w3.org/TR/html52
60 Output is compatible with prior HTML5 standards.
61
62BSD December 17, 2023 BSD