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

NAME

4     lowdown_file — parse a Markdown file into formatted output
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_file(const struct lowdown_opts *opts, FILE *in, char **ret,
16         size_t *retsz, struct lowdown_metaq *metaq);
17

DESCRIPTION

19     Parses a lowdown(5) file stream in into an output buffer ret of size
20     retsz according to configuration opts.  The output format is specified by
21     opts->type.  If LOWDOWN_METADATA is set in opts->feat and metaq is not
22     NULL, metaq is filled with metadata rendered in the given output format.
23
24     On success, the caller is responsible for freeing ret and metaq.
25

RETURN VALUES

27     Returns zero on failure, non-zero on success.  On failure, the values
28     pointed to by res and rsz are undefined.
29

EXAMPLES

31     The following parses standard input into a standalone HTML5 document.  It
32     enables footnotes, autolinks, tables, superscript, strikethrough, fenced
33     codeblocks, commonmark, definition lists, extended image attributes, and
34     metadata processing.  The output passes through raw HTML and has smart
35     typography.
36
37           struct lowdown_opts opts;
38           char *buf;
39           size_t bufsz;
40
41           memset(&opts, 0, sizeof(struct lowdown_opts));
42           opts.type = LOWDOWN_HTML;
43           opts.feat = LOWDOWN_FOOTNOTES |
44                   LOWDOWN_AUTOLINK |
45                   LOWDOWN_TABLES |
46                   LOWDOWN_SUPER |
47                   LOWDOWN_STRIKE |
48                   LOWDOWN_FENCED |
49                   LOWDOWN_COMMONMARK |
50                   LOWDOWN_DEFLIST |
51                   LOWDOWN_IMG_EXT |
52                   LOWDOWN_METADATA;
53           opts.oflags = LOWDOWN_HTML_HEAD_IDS |
54                   LOWDOWN_HTML_NUM_ENT |
55                   LOWDOWN_HTML_OWASP |
56                   LOWDOWN_SMARTY |
57                   LOWDOWN_STANDALONE;
58           if (!lowdown_file(&opts, stdin, &buf, &bufsz, NULL))
59                   errx(1, "lowdown_file");
60           fwrite(buf, 1, bufsz, stdout);
61           free(buf);
62

SEE ALSO

64     lowdown(3), lowdown_metaq_free(3)
65
66BSD                            December 17, 2023                           BSD
Impressum