1LOWDOWN_TREE_RNDR(3) BSD Library Functions Manual LOWDOWN_TREE_RNDR(3)
2
4 lowdown_tree_rndr — render Markdown into debugging output
5
7 library “liblowdown”
8
10 #include <sys/queue.h>
11 #include <stdio.h>
12 #include <lowdown.h>
13
14 int
15 lowdown_tree_rndr(struct lowdown_buf *out, const struct lowdown_node *n);
16
18 Renders a node tree n created by lowdown_doc_parse(3) or lowdown_diff(3).
19 The output is written into out, which must be initialised and freed by
20 the caller.
21
22 The output consists of an UTF-8 tree. The format is not standardised and
23 subject to change.
24
25 Unlike other renderers, lowdown_tree_rndr() accepts no options and thus
26 has no context.
27
29 Returns zero on failure to allocate memory, non-zero on success.
30
32 The following parses b of length bsz and outputs the parse tree.
33
34 struct lowdown_buf *out;
35 struct lowdown_doc *doc;
36 struct lowdown_node *n;
37 void *rndr;
38
39 if ((doc = lowdown_doc_new(NULL)) == NULL)
40 err(1, NULL);
41 if ((n = lowdown_doc_parse(doc, NULL, b, bsz, NULL)) == NULL)
42 err(1, NULL);
43 if ((out = lowdown_buf_new(256)) == NULL)
44 err(1, NULL);
45 if (!lowdown_tree_rndr(out, n))
46 err(1, NULL);
47
48 fwrite(out->data, 1, out->size, stdout);
49
50 lowdown_buf_free(out);
51 lowdown_node_free(n);
52 lowdown_doc_free(doc);
53
55 lowdown(3)
56
57BSD December 17, 2023 BSD