-
-
Notifications
You must be signed in to change notification settings - Fork 134
/
comrak_ffi.h
70 lines (55 loc) · 2.94 KB
/
comrak_ffi.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#ifndef COMRAK_FFI_H
#define COMRAK_FFI_H
#if defined(__cplusplus)
extern "C" {
#endif
#include <stddef.h>
#include <stdbool.h>
typedef struct comrak_ComrakOptions comrak_options_t;
// Creates new ComrakOptions struct.
comrak_options_t *comrak_options_new();
// Frees the memory allocated for ComrakOptions struct.
void comrak_options_free(comrak_options_t *options);
void comrak_set_extension_option_strikethrough(comrak_options_t *options, bool value);
void comrak_set_extension_option_tagfilter(comrak_options_t *options, bool value);
void comrak_set_extension_option_table(comrak_options_t *options, bool value);
void comrak_set_extension_option_autolink(comrak_options_t *options, bool value);
void comrak_set_extension_option_tasklist(comrak_options_t *options, bool value);
void comrak_set_extension_option_superscript(comrak_options_t *options, bool value);
void comrak_set_extension_option_header_ids(comrak_options_t *options, const char *header_id, size_t header_id_len);
void comrak_set_extension_option_footnotes(comrak_options_t *options, bool value);
void comrak_set_extension_option_description_lists(comrak_options_t *options, bool value);
void comrak_set_extension_option_front_matter_delimiter(comrak_options_t *options, const char *front_matter_delimiter, size_t front_matter_delimiter_len);
void comrak_set_parse_option_smart(comrak_options_t *options, bool value);
void comrak_set_parse_option_default_info_string(comrak_options_t *options, const char *default_info_string, size_t default_info_string_len);
void comrak_set_render_option_hardbreaks(comrak_options_t *options, bool value);
void comrak_set_render_option_github_pre_lang(comrak_options_t *options, bool value);
void comrak_set_render_option_width(comrak_options_t *options, size_t value);
void comrak_set_render_option_unsafe_(comrak_options_t *options, bool value);
void comrak_set_render_option_escape(comrak_options_t *options, bool value);
// Library-allocated UTF-8 string fat pointer.
//
// The string is not NULL-terminated.
//
// Use `comrak_str_free` function to deallocate.
typedef struct {
// String data pointer.
const char *data;
// The length of the string in bytes.
size_t len;
} comrak_str_t;
// Convert 'text' (assumed to be a UTF-8 encoded string) from Commonmark to HTML,
// returning a null-terminated, UTF-8-encoded string, using the options specified.
comrak_str_t comrak_commonmark_to_html(const char *text, comrak_options_t *options);
//
// Convert 'text' (assumed to be a UTF-8 encoded string) from Commonmark back to CommonMark,
// returning a null-terminated, UTF-8-encoded string, using the options specified.
comrak_str_t comrak_commonmark_to_commonmark(const char *text, comrak_options_t *options);
// Frees the memory held by the library-allocated string.
//
// This is valid to call even if `str.data == NULL` (it does nothing, like `free(NULL)`).
void comrak_str_free(comrak_str_t str);
#if defined(__cplusplus)
} // extern C
#endif
#endif // COMRAK_FFI_H