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

NAME

4     lowdown_term_new — allocate a Markdown terminal renderer
5

LIBRARY

7     library “liblowdown”
8

SYNOPSIS

10     #include <sys/queue.h>
11     #include <stdio.h>
12     #include <lowdown.h>
13
14     void *
15     lowdown_term_new(const struct lowdown_opts *opts);
16

DESCRIPTION

18     Allocates a terminal renderer using opts->cols, opts->hmargin,
19     opts->vmargin, and opts->oflags, or 80 and all others zero, respectively,
20     if opts is NULL.  These fields are documented in lowdown(3).  The re‐
21     turned pointer may be used with multiple invocations of
22     lowdown_term_rndr(3) and must be freed with lowdown_term_free(3).
23
24     The bits recognised in opts->oflags are LOWDOWN_TERM_SHORTLINK,
25     LOWDOWN_TERM_NOCOLOUR, and LOWDOWN_TERM_NOLINK.
26

RETURN VALUES

28     Returns a pointer to the renderer or NULL on memory failure.  The re‐
29     turned pointer must be freed with lowdown_term_free(3).
30

EXAMPLES

32     The following parses b of length bsz and outputs in ANSI terminal format.
33
34           struct lowdown_buf *out;
35           struct lowdown_doc *doc;
36           struct lowdown_node *n;
37           void *rndr;
38
39           if (setlocale(LC_CTYPE, "en_US.UTF-8") == NULL)
40                   err(1, NULL);
41
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_term_new(NULL)) == NULL)
49                   err(1, NULL);
50           if (!lowdown_term_rndr(out, rndr, n))
51                   err(1, NULL);
52
53           fwrite(out->data, 1, out->size, stdout);
54
55           lowdown_term_free(rndr);
56           lowdown_buf_free(out);
57           lowdown_node_free(n);
58           lowdown_doc_free(doc);
59

SEE ALSO

61     lowdown(3), lowdown_term_free(3), lowdown_term_rndr(3)
62

STANDARDS

64     ANSI escape codes are described in ISO/IEC 6429, previously ECMA-48.
65
66BSD                            December 17, 2023                           BSD
Impressum