1LOWDOWN_GEMINI_RNDR(3)   BSD Library Functions Manual   LOWDOWN_GEMINI_RNDR(3)
2

NAME

4     lowdown_gemini_rndr — render Markdown into gemini
5

LIBRARY

7     library “liblowdown”
8

SYNOPSIS

10     #include <sys/queue.h>
11     #include <stdio.h>
12     #include <lowdown.h>
13
14     int
15     lowdown_gemini_rndr(struct lowdown_buf *out, void *arg,
16         const struct lowdown_node *n);
17

DESCRIPTION

19     Renders a node tree n created by lowdown_doc_parse(3) or lowdown_diff(3)
20     using the gemini renderer arg as returned by lowdown_gemini_new(3).  The
21     output is written into out, which must be initialised and freed by the
22     caller.
23
24     The caller is expected to have invoked setlocale(3) to a "UTF-8" charac‐
25     ter encoding prior to using this function, otherwise UTF-8 sequences will
26     not be properly recognised.  This is used when formatting table column
27     widths.
28

RETURN VALUES

30     Returns zero on failure to allocate memory, non-zero on success.
31

EXAMPLES

33     The following parses b of length bsz and outputs in Gemini format.
34
35           struct lowdown_buf *out;
36           struct lowdown_doc *doc;
37           struct lowdown_node *n;
38           void *rndr;
39
40           if (setlocale(LC_CTYPE, "en_US.UTF-8") == NULL)
41                   err(1, NULL);
42           if ((doc = lowdown_doc_new(NULL)) == NULL)
43                   err(1, NULL);
44           if ((n = lowdown_doc_parse(doc, NULL, b, bsz, NULL)) == NULL)
45                   err(1, NULL);
46           if ((out = lowdown_buf_new(256)) == NULL)
47                   err(1, NULL);
48           if ((rndr = lowdown_gemini_new(NULL)) == NULL)
49                   err(1, NULL);
50           if (!lowdown_gemini_rndr(out, rndr, n))
51                   err(1, NULL);
52
53           fwrite(out->data, 1, out->size, stdout);
54
55           lowdown_gemini_free(rndr);
56           lowdown_buf_free(out);
57           lowdown_node_free(n);
58           lowdown_doc_free(doc);
59

SEE ALSO

61     lowdown(3), lowdown_gemini_free(3), lowdown_gemini_new(3)
62

STANDARDS

64     The gemini format is documented in Project Gemini:
65     https://gemini.circumlunar.space/docs/specification.html The version at
66     the time of writing is 0.14.3.
67
68BSD                            December 17, 2023                           BSD
Impressum