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

NAME

4     lowdown_nroff_rndr — render Markdown into roff
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_nroff_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 roff renderer arg as returned by lowdown_nroff_new(3).  The
21     output is written into out, which must be initialised and freed by the
22     caller.
23
24     The output consists of roff output using the ms or man macro packages.
25

RETURN VALUES

27     Returns zero on failure to allocate memory, non-zero on success.
28

EXAMPLES

30     The following parses b of length bsz and outputs in groff_ms(7) 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_nroff_new(NULL)) == NULL)
44                   err(1, NULL);
45           if (!lowdown_nroff_rndr(out, rndr, n))
46                   err(1, NULL);
47
48           fwrite(out->data, 1, out->size, stdout);
49
50           lowdown_nroff_free(rndr);
51           lowdown_buf_free(out);
52           lowdown_node_free(n);
53           lowdown_doc_free(doc);
54

SEE ALSO

56     lowdown(3), lowdown_nroff_free(3), lowdown_nroff_new(3)
57
58     This uses both the original troff man macros for Version 7 AT&T UNIX, de‐
59     fined in man(7), and the man-ext groff extensions.  Both are implemented
60     in mandoc.
61
62     The troff ms macros are defined in groff_ms(7), with the mspdf groff ex‐
63     tensions described in "Portable Document Format Publishing with GNU
64     Troff" by Keith Marshall.  Neither are implemented in mandoc.
65
66BSD                            December 17, 2023                           BSD
Impressum