1/*
2 * MD4C: Markdown parser for C
3 * (http://github.com/mity/md4c)
4 *
5 * Copyright (c) 2016-2017 Martin Mitas
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
13 *
14 * The above copyright notice and this permission notice shall be included in
15 * all copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
23 * IN THE SOFTWARE.
24 */
25
26#ifndef MD4C_HTML_H
27#define MD4C_HTML_H
28
29#include "md4c.h"
30
31#ifdef __cplusplus
32 extern "C" {
33#endif
34
35
36/* If set, debug output from md_parse() is sent to stderr. */
37#define MD_HTML_FLAG_DEBUG 0x0001
38#define MD_HTML_FLAG_VERBATIM_ENTITIES 0x0002
39#define MD_HTML_FLAG_SKIP_UTF8_BOM 0x0004
40#define MD_HTML_FLAG_XHTML 0x0008
41
42
43/* Render Markdown into HTML.
44 *
45 * Note only contents of <body> tag is generated. Caller must generate
46 * HTML header/footer manually before/after calling md_html().
47 *
48 * Params input and input_size specify the Markdown input.
49 * Callback process_output() gets called with chunks of HTML output.
50 * (Typical implementation may just output the bytes to a file or append to
51 * some buffer).
52 * Param userdata is just propgated back to process_output() callback.
53 * Param parser_flags are flags from md4c.h propagated to md_parse().
54 * Param render_flags is bitmask of MD_HTML_FLAG_xxxx.
55 *
56 * Returns -1 on error (if md_parse() fails.)
57 * Returns 0 on success.
58 */
59int md_html(const MD_CHAR* input, MD_SIZE input_size,
60 void (*process_output)(const MD_CHAR*, MD_SIZE, void*),
61 void* userdata, unsigned parser_flags, unsigned renderer_flags);
62
63
64#ifdef __cplusplus
65 } /* extern "C" { */
66#endif
67
68#endif /* MD4C_HTML_H */