commonmarker 0.10.0 → 0.11.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of commonmarker might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/Rakefile +3 -0
- data/bin/commonmarker +19 -3
- data/ext/commonmarker/cmark/CMakeLists.txt +1 -0
- data/ext/commonmarker/cmark/COPYING +2 -24
- data/ext/commonmarker/cmark/Makefile +25 -5
- data/ext/commonmarker/cmark/README.md +1 -1
- data/ext/commonmarker/cmark/api_test/CMakeLists.txt +1 -1
- data/ext/commonmarker/cmark/api_test/main.c +25 -27
- data/ext/commonmarker/cmark/build/CMakeCache.txt +12 -9
- data/ext/commonmarker/cmark/build/CMakeFiles/{3.6.0 → 3.6.1}/CMakeCCompiler.cmake +0 -0
- data/ext/commonmarker/cmark/build/CMakeFiles/{3.6.0 → 3.6.1}/CMakeCXXCompiler.cmake +0 -0
- data/ext/commonmarker/cmark/build/CMakeFiles/{3.6.0 → 3.6.1}/CMakeDetermineCompilerABI_C.bin +0 -0
- data/ext/commonmarker/cmark/build/CMakeFiles/{3.6.0 → 3.6.1}/CMakeDetermineCompilerABI_CXX.bin +0 -0
- data/ext/commonmarker/cmark/build/CMakeFiles/{3.6.0 → 3.6.1}/CMakeSystem.cmake +4 -4
- data/ext/commonmarker/cmark/build/CMakeFiles/{3.6.0 → 3.6.1}/CompilerIdC/CMakeCCompilerId.c +0 -0
- data/ext/commonmarker/cmark/build/CMakeFiles/{3.6.0 → 3.6.1}/CompilerIdC/a.out +0 -0
- data/ext/commonmarker/cmark/build/CMakeFiles/{3.6.0 → 3.6.1}/CompilerIdCXX/CMakeCXXCompilerId.cpp +0 -0
- data/ext/commonmarker/cmark/build/CMakeFiles/{3.6.0 → 3.6.1}/CompilerIdCXX/a.out +0 -0
- data/ext/commonmarker/cmark/build/CMakeFiles/CMakeError.log +6 -6
- data/ext/commonmarker/cmark/build/CMakeFiles/CMakeOutput.log +148 -148
- data/ext/commonmarker/cmark/build/CMakeFiles/Makefile.cmake +41 -109
- data/ext/commonmarker/cmark/build/CMakeFiles/Makefile2 +66 -10
- data/ext/commonmarker/cmark/build/CMakeFiles/TargetDirectories.txt +8 -0
- data/ext/commonmarker/cmark/build/CMakeFiles/progress.marks +1 -1
- data/ext/commonmarker/cmark/build/CTestTestfile.cmake +1 -0
- data/ext/commonmarker/cmark/build/Makefile +23 -9
- data/ext/commonmarker/cmark/build/api_test/CMakeFiles/api_test.dir/build.make +2 -2
- data/ext/commonmarker/cmark/build/api_test/CMakeFiles/progress.marks +1 -1
- data/ext/commonmarker/cmark/build/api_test/Makefile +9 -9
- data/ext/commonmarker/cmark/build/cmake_install.cmake +1 -0
- data/ext/commonmarker/cmark/build/extensions/CMakeFiles/CMakeDirectoryInformation.cmake +16 -0
- data/ext/commonmarker/cmark/build/extensions/CMakeFiles/libcmarkextensions_static.dir/C.includecache +190 -0
- data/ext/commonmarker/cmark/build/extensions/CMakeFiles/libcmarkextensions_static.dir/DependInfo.cmake +29 -0
- data/ext/commonmarker/cmark/build/extensions/CMakeFiles/libcmarkextensions_static.dir/autolink.c.o +0 -0
- data/ext/commonmarker/cmark/build/extensions/CMakeFiles/libcmarkextensions_static.dir/build.make +249 -0
- data/ext/commonmarker/cmark/build/extensions/CMakeFiles/libcmarkextensions_static.dir/cmake_clean.cmake +15 -0
- data/ext/commonmarker/cmark/build/extensions/CMakeFiles/libcmarkextensions_static.dir/cmake_clean_target.cmake +3 -0
- data/ext/commonmarker/cmark/build/extensions/CMakeFiles/libcmarkextensions_static.dir/core-extensions.c.o +0 -0
- data/ext/commonmarker/cmark/build/extensions/CMakeFiles/libcmarkextensions_static.dir/depend.internal +92 -0
- data/ext/commonmarker/cmark/build/extensions/CMakeFiles/libcmarkextensions_static.dir/depend.make +92 -0
- data/ext/commonmarker/cmark/build/extensions/CMakeFiles/libcmarkextensions_static.dir/ext_scanners.c.o +0 -0
- data/ext/commonmarker/cmark/build/extensions/CMakeFiles/libcmarkextensions_static.dir/flags.make +10 -0
- data/ext/commonmarker/cmark/build/extensions/CMakeFiles/libcmarkextensions_static.dir/link.txt +2 -0
- data/ext/commonmarker/cmark/build/extensions/CMakeFiles/libcmarkextensions_static.dir/progress.make +8 -0
- data/ext/commonmarker/cmark/build/extensions/CMakeFiles/libcmarkextensions_static.dir/strikethrough.c.o +0 -0
- data/ext/commonmarker/cmark/build/extensions/CMakeFiles/libcmarkextensions_static.dir/table.c.o +0 -0
- data/ext/commonmarker/cmark/build/extensions/CMakeFiles/libcmarkextensions_static.dir/whitelist.c.o +0 -0
- data/ext/commonmarker/cmark/build/extensions/CMakeFiles/progress.marks +1 -0
- data/ext/commonmarker/cmark/build/extensions/Makefile +390 -0
- data/ext/commonmarker/cmark/build/extensions/cmake_install.cmake +29 -0
- data/ext/commonmarker/cmark/build/extensions/libcmarkextensions.a +0 -0
- data/ext/commonmarker/cmark/build/man/Makefile +9 -9
- data/ext/commonmarker/cmark/build/src/CMakeFiles/Export/lib/cmake/cmark.cmake +1 -1
- data/ext/commonmarker/cmark/build/src/CMakeFiles/cmark.dir/DependInfo.cmake +7 -19
- data/ext/commonmarker/cmark/build/src/CMakeFiles/cmark.dir/build.make +6 -517
- data/ext/commonmarker/cmark/build/src/CMakeFiles/cmark.dir/cmake_clean.cmake +0 -19
- data/ext/commonmarker/cmark/build/src/CMakeFiles/cmark.dir/flags.make +1 -1
- data/ext/commonmarker/cmark/build/src/CMakeFiles/cmark.dir/link.txt +1 -1
- data/ext/commonmarker/cmark/build/src/CMakeFiles/cmark.dir/progress.make +0 -19
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark.dir/DependInfo.cmake +9 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark.dir/build.make +112 -4
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark.dir/cmake_clean.cmake +4 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark.dir/flags.make +1 -1
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark.dir/link.txt +1 -1
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark.dir/progress.make +24 -20
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/C.includecache +144 -10
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/DependInfo.cmake +9 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/blocks.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/build.make +112 -4
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/cmake_clean.cmake +4 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/cmark.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/commonmark.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/depend.internal +74 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/depend.make +74 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/flags.make +1 -1
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/html.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/inlines.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/iterator.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/latex.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/link.txt +1 -1
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/linked_list.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/man.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/node.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/plugin.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/progress.make +24 -20
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/registry.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/scanners.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/syntax_extension.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/xml.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/progress.marks +1 -1
- data/ext/commonmarker/cmark/build/src/Makefile +141 -66
- data/ext/commonmarker/cmark/build/src/cmake_install.cmake +4 -0
- data/ext/commonmarker/cmark/build/src/libcmark.a +0 -0
- data/ext/commonmarker/cmark/build/testdir/CTestTestfile.cmake +3 -1
- data/ext/commonmarker/cmark/build/testdir/Makefile +9 -9
- data/ext/commonmarker/cmark/extensions/CMakeLists.txt +82 -0
- data/ext/commonmarker/cmark/extensions/autolink.c +338 -0
- data/ext/commonmarker/cmark/extensions/autolink.h +8 -0
- data/ext/commonmarker/cmark/extensions/core-extensions.c +16 -0
- data/ext/commonmarker/cmark/extensions/core-extensions.h +16 -0
- data/ext/commonmarker/cmark/extensions/ext_scanners.c +585 -0
- data/ext/commonmarker/cmark/extensions/ext_scanners.h +20 -0
- data/ext/commonmarker/cmark/extensions/ext_scanners.re +65 -0
- data/ext/commonmarker/cmark/extensions/strikethrough.c +142 -0
- data/ext/commonmarker/cmark/extensions/strikethrough.h +9 -0
- data/ext/commonmarker/cmark/extensions/table.c +493 -0
- data/ext/commonmarker/cmark/extensions/table.h +8 -0
- data/ext/commonmarker/cmark/extensions/whitelist.c +59 -0
- data/ext/commonmarker/cmark/extensions/whitelist.h +8 -0
- data/ext/commonmarker/cmark/man/man3/cmark.3 +98 -34
- data/ext/commonmarker/cmark/src/CMakeLists.txt +16 -1
- data/ext/commonmarker/cmark/src/blocks.c +219 -40
- data/ext/commonmarker/cmark/src/buffer.h +36 -0
- data/ext/commonmarker/cmark/src/cmark.c +5 -1
- data/ext/commonmarker/cmark/src/cmark.h +91 -34
- data/ext/commonmarker/cmark/src/cmark_ctype.h +7 -0
- data/ext/commonmarker/cmark/src/cmark_extension_api.h +655 -0
- data/ext/commonmarker/cmark/src/commonmark.c +7 -2
- data/ext/commonmarker/cmark/src/houdini.h +12 -6
- data/ext/commonmarker/cmark/src/houdini_html_e.c +1 -1
- data/ext/commonmarker/cmark/src/html.c +102 -54
- data/ext/commonmarker/cmark/src/html.h +27 -0
- data/ext/commonmarker/cmark/src/inlines.c +261 -53
- data/ext/commonmarker/cmark/src/inlines.h +7 -2
- data/ext/commonmarker/cmark/src/iterator.c +12 -7
- data/ext/commonmarker/cmark/src/latex.c +5 -2
- data/ext/commonmarker/cmark/src/linked_list.c +37 -0
- data/ext/commonmarker/cmark/src/main.c +91 -27
- data/ext/commonmarker/cmark/src/man.c +18 -2
- data/ext/commonmarker/cmark/src/node.c +157 -58
- data/ext/commonmarker/cmark/src/node.h +23 -0
- data/ext/commonmarker/cmark/src/parser.h +19 -2
- data/ext/commonmarker/cmark/src/plugin.c +33 -0
- data/ext/commonmarker/cmark/src/plugin.h +34 -0
- data/ext/commonmarker/cmark/src/registry.c +60 -0
- data/ext/commonmarker/cmark/src/registry.h +24 -0
- data/ext/commonmarker/cmark/src/render.h +9 -0
- data/ext/commonmarker/cmark/src/scanners.c +265 -391
- data/ext/commonmarker/cmark/src/scanners.h +5 -0
- data/ext/commonmarker/cmark/src/scanners.re +2 -2
- data/ext/commonmarker/cmark/src/syntax_extension.c +110 -0
- data/ext/commonmarker/cmark/src/syntax_extension.h +27 -0
- data/ext/commonmarker/cmark/suppressions +28 -0
- data/ext/commonmarker/cmark/test/CMakeLists.txt +12 -1
- data/ext/commonmarker/cmark/test/extensions.txt +173 -0
- data/ext/commonmarker/cmark/test/regression.txt +24 -0
- data/ext/commonmarker/cmark/test/spec.txt +27 -26
- data/ext/commonmarker/cmark/toolchain-mingw32.cmake +1 -1
- data/ext/commonmarker/commonmarker.c +132 -15
- data/ext/commonmarker/commonmarker.h +4 -0
- data/ext/commonmarker/extconf.rb +12 -5
- data/lib/commonmarker.rb +8 -6
- data/lib/commonmarker/node.rb +13 -2
- data/lib/commonmarker/renderer.rb +1 -1
- data/lib/commonmarker/version.rb +1 -1
- data/test/test_commonmark.rb +34 -0
- data/test/test_encoding.rb +2 -1
- data/test/test_extensions.rb +50 -0
- data/test/test_helper.rb +2 -1
- metadata +65 -11
@@ -0,0 +1,59 @@
|
|
1
|
+
#include "whitelist.h"
|
2
|
+
#include <parser.h>
|
3
|
+
|
4
|
+
static const char *whitelist[] = {
|
5
|
+
"template", "h1", "h2", "h3", "h4", "h5", "h6", "h7", "h8", "br", "b", "i",
|
6
|
+
"strong", "em", "a", "pre", "code", "img", "tt", "div", "ins", "del", "sup",
|
7
|
+
"sub", "p", "ol", "ul", "table", "thead", "tbody", "tfoot", "blockquote",
|
8
|
+
"dl", "dt", "dd", "kbd", "q", "samp", "var", "hr", "ruby", "rt", "rp", "li",
|
9
|
+
"tr", "td", "th", "s", "strike", "summary", "details",
|
10
|
+
NULL,
|
11
|
+
};
|
12
|
+
|
13
|
+
static int is_tag(const unsigned char *tag_data, size_t tag_size, const char *tagname)
|
14
|
+
{
|
15
|
+
size_t i;
|
16
|
+
|
17
|
+
if (tag_size < 3 || tag_data[0] != '<')
|
18
|
+
return 0;
|
19
|
+
|
20
|
+
i = 1;
|
21
|
+
|
22
|
+
if (tag_data[i] == '/') {
|
23
|
+
i++;
|
24
|
+
}
|
25
|
+
|
26
|
+
for (; i < tag_size; ++i, ++tagname) {
|
27
|
+
if (*tagname == 0)
|
28
|
+
break;
|
29
|
+
|
30
|
+
if (tag_data[i] != *tagname)
|
31
|
+
return 0;
|
32
|
+
}
|
33
|
+
|
34
|
+
if (i == tag_size)
|
35
|
+
return 0;
|
36
|
+
|
37
|
+
if (cmark_isspace(tag_data[i]) || tag_data[i] == '>')
|
38
|
+
return 1;
|
39
|
+
|
40
|
+
return 0;
|
41
|
+
}
|
42
|
+
|
43
|
+
static int filter(cmark_syntax_extension *ext, const unsigned char *tag, size_t tag_len) {
|
44
|
+
const char **it;
|
45
|
+
|
46
|
+
for (it = whitelist; *it; ++it) {
|
47
|
+
if (is_tag(tag, tag_len, *it)) {
|
48
|
+
return 1;
|
49
|
+
}
|
50
|
+
}
|
51
|
+
|
52
|
+
return 0;
|
53
|
+
}
|
54
|
+
|
55
|
+
cmark_syntax_extension *create_whitelist_extension(void) {
|
56
|
+
cmark_syntax_extension *ext = cmark_syntax_extension_new("whitelist");
|
57
|
+
cmark_syntax_extension_set_html_filter_func(ext, filter);
|
58
|
+
return ext;
|
59
|
+
}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
.TH cmark 3 "
|
1
|
+
.TH cmark 3 "September 14, 2016" "LOCAL" "Library Functions Manual"
|
2
2
|
.SH
|
3
3
|
NAME
|
4
4
|
.PP
|
@@ -27,37 +27,31 @@ Node Structure
|
|
27
27
|
.RS 0n
|
28
28
|
typedef enum {
|
29
29
|
/* Error status */
|
30
|
-
CMARK_NODE_NONE,
|
30
|
+
CMARK_NODE_NONE = 0x0000,
|
31
31
|
|
32
32
|
/* Block */
|
33
|
-
CMARK_NODE_DOCUMENT,
|
34
|
-
CMARK_NODE_BLOCK_QUOTE,
|
35
|
-
CMARK_NODE_LIST,
|
36
|
-
CMARK_NODE_ITEM,
|
37
|
-
CMARK_NODE_CODE_BLOCK,
|
38
|
-
CMARK_NODE_HTML_BLOCK,
|
39
|
-
CMARK_NODE_CUSTOM_BLOCK,
|
40
|
-
CMARK_NODE_PARAGRAPH,
|
41
|
-
CMARK_NODE_HEADING,
|
42
|
-
CMARK_NODE_THEMATIC_BREAK,
|
43
|
-
|
44
|
-
CMARK_NODE_FIRST_BLOCK = CMARK_NODE_DOCUMENT,
|
45
|
-
CMARK_NODE_LAST_BLOCK = CMARK_NODE_THEMATIC_BREAK,
|
33
|
+
CMARK_NODE_DOCUMENT = CMARK_NODE_TYPE_BLOCK | 0x0001,
|
34
|
+
CMARK_NODE_BLOCK_QUOTE = CMARK_NODE_TYPE_BLOCK | 0x0002,
|
35
|
+
CMARK_NODE_LIST = CMARK_NODE_TYPE_BLOCK | 0x0003,
|
36
|
+
CMARK_NODE_ITEM = CMARK_NODE_TYPE_BLOCK | 0x0004,
|
37
|
+
CMARK_NODE_CODE_BLOCK = CMARK_NODE_TYPE_BLOCK | 0x0005,
|
38
|
+
CMARK_NODE_HTML_BLOCK = CMARK_NODE_TYPE_BLOCK | 0x0006,
|
39
|
+
CMARK_NODE_CUSTOM_BLOCK = CMARK_NODE_TYPE_BLOCK | 0x0007,
|
40
|
+
CMARK_NODE_PARAGRAPH = CMARK_NODE_TYPE_BLOCK | 0x0008,
|
41
|
+
CMARK_NODE_HEADING = CMARK_NODE_TYPE_BLOCK | 0x0009,
|
42
|
+
CMARK_NODE_THEMATIC_BREAK = CMARK_NODE_TYPE_BLOCK | 0x000a,
|
46
43
|
|
47
44
|
/* Inline */
|
48
|
-
CMARK_NODE_TEXT,
|
49
|
-
CMARK_NODE_SOFTBREAK,
|
50
|
-
CMARK_NODE_LINEBREAK,
|
51
|
-
CMARK_NODE_CODE,
|
52
|
-
CMARK_NODE_HTML_INLINE,
|
53
|
-
CMARK_NODE_CUSTOM_INLINE,
|
54
|
-
CMARK_NODE_EMPH,
|
55
|
-
CMARK_NODE_STRONG,
|
56
|
-
CMARK_NODE_LINK,
|
57
|
-
CMARK_NODE_IMAGE,
|
58
|
-
|
59
|
-
CMARK_NODE_FIRST_INLINE = CMARK_NODE_TEXT,
|
60
|
-
CMARK_NODE_LAST_INLINE = CMARK_NODE_IMAGE,
|
45
|
+
CMARK_NODE_TEXT = CMARK_NODE_TYPE_INLINE | 0x0001,
|
46
|
+
CMARK_NODE_SOFTBREAK = CMARK_NODE_TYPE_INLINE | 0x0002,
|
47
|
+
CMARK_NODE_LINEBREAK = CMARK_NODE_TYPE_INLINE | 0x0003,
|
48
|
+
CMARK_NODE_CODE = CMARK_NODE_TYPE_INLINE | 0x0004,
|
49
|
+
CMARK_NODE_HTML_INLINE = CMARK_NODE_TYPE_INLINE | 0x0005,
|
50
|
+
CMARK_NODE_CUSTOM_INLINE = CMARK_NODE_TYPE_INLINE | 0x0006,
|
51
|
+
CMARK_NODE_EMPH = CMARK_NODE_TYPE_INLINE | 0x0007,
|
52
|
+
CMARK_NODE_STRONG = CMARK_NODE_TYPE_INLINE | 0x0008,
|
53
|
+
CMARK_NODE_LINK = CMARK_NODE_TYPE_INLINE | 0x0009,
|
54
|
+
CMARK_NODE_IMAGE = CMARK_NODE_TYPE_INLINE | 0x000a,
|
61
55
|
} cmark_node_type;
|
62
56
|
.RE
|
63
57
|
\f[]
|
@@ -103,9 +97,9 @@ Custom memory allocator support
|
|
103
97
|
\fC
|
104
98
|
.RS 0n
|
105
99
|
typedef struct cmark_mem {
|
106
|
-
|
107
|
-
|
108
|
-
|
100
|
+
void *(*calloc)(size_t, size_t);
|
101
|
+
void *(*realloc)(void *, size_t);
|
102
|
+
void (*free)(void *);
|
109
103
|
} cmark_mem;
|
110
104
|
.RE
|
111
105
|
\f[]
|
@@ -115,6 +109,45 @@ typedef struct cmark_mem {
|
|
115
109
|
Defines the memory allocation functions to be used by CMark when parsing
|
116
110
|
and allocating a document tree
|
117
111
|
|
112
|
+
.SS
|
113
|
+
Linked list
|
114
|
+
|
115
|
+
.PP
|
116
|
+
.nf
|
117
|
+
\fC
|
118
|
+
.RS 0n
|
119
|
+
typedef struct _cmark_llist
|
120
|
+
{
|
121
|
+
struct _cmark_llist *next;
|
122
|
+
void *data;
|
123
|
+
} cmark_llist;
|
124
|
+
.RE
|
125
|
+
\f[]
|
126
|
+
.fi
|
127
|
+
|
128
|
+
.PP
|
129
|
+
A generic singly linked list.
|
130
|
+
|
131
|
+
.PP
|
132
|
+
\fIcmark_llist *\f[] \fBcmark_llist_append\f[](\fIcmark_llist * head\f[], \fIvoid * data\f[])
|
133
|
+
|
134
|
+
.PP
|
135
|
+
Append an element to the linked list, return the possibly modified head
|
136
|
+
of the list.
|
137
|
+
|
138
|
+
.PP
|
139
|
+
\fIvoid\f[] \fBcmark_llist_free_full\f[](\fIcmark_llist * head\f[], \fIcmark_free_func free_func\f[])
|
140
|
+
|
141
|
+
.PP
|
142
|
+
Free the list starting with \f[I]head\f[], calling \f[I]free_func\f[]
|
143
|
+
with the data pointer of each of its elements
|
144
|
+
|
145
|
+
.PP
|
146
|
+
\fIvoid\f[] \fBcmark_llist_free\f[](\fIcmark_llist * head\f[])
|
147
|
+
|
148
|
+
.PP
|
149
|
+
Free the list starting with \f[I]head\f[]
|
150
|
+
|
118
151
|
.SS
|
119
152
|
Creating and Destroying Nodes
|
120
153
|
|
@@ -313,6 +346,12 @@ Returns the user data of \f[I]node\f[].
|
|
313
346
|
Sets arbitrary user data for \f[I]node\f[]. Returns 1 on success, 0 on
|
314
347
|
failure.
|
315
348
|
|
349
|
+
.PP
|
350
|
+
\fIint\f[] \fBcmark_node_set_user_data_free_func\f[](\fIcmark_node *node\f[], \fIcmark_free_func free_func\f[])
|
351
|
+
|
352
|
+
.PP
|
353
|
+
Set free function for user data */
|
354
|
+
|
316
355
|
.PP
|
317
356
|
\fIcmark_node_type\f[] \fBcmark_node_get_type\f[](\fIcmark_node *node\f[])
|
318
357
|
|
@@ -421,6 +460,18 @@ Returns the info string from a fenced code block.
|
|
421
460
|
Sets the info string in a fenced code block, returning 1 on success
|
422
461
|
and 0 on failure.
|
423
462
|
|
463
|
+
.PP
|
464
|
+
\fIint\f[] \fBcmark_node_set_fenced\f[](\fIcmark_node * node\f[], \fIint fenced\f[], \fIint length\f[], \fIint offset\f[], \fIchar character\f[])
|
465
|
+
|
466
|
+
.PP
|
467
|
+
Sets code blocks fencing details
|
468
|
+
|
469
|
+
.PP
|
470
|
+
\fIint\f[] \fBcmark_node_get_fenced\f[](\fIcmark_node *node\f[], \fIint *length\f[], \fIint *offset\f[], \fIchar *character\f[])
|
471
|
+
|
472
|
+
.PP
|
473
|
+
Returns code blocks fencing details
|
474
|
+
|
424
475
|
.PP
|
425
476
|
\fIconst char *\f[] \fBcmark_node_get_url\f[](\fIcmark_node *node\f[])
|
426
477
|
|
@@ -642,7 +693,7 @@ Render a \f[I]node\f[] tree as XML. It is the caller's responsibility to
|
|
642
693
|
free the returned buffer.
|
643
694
|
|
644
695
|
.PP
|
645
|
-
\fIchar *\f[] \fBcmark_render_html\f[](\fIcmark_node *root\f[], \fIint options\f[])
|
696
|
+
\fIchar *\f[] \fBcmark_render_html\f[](\fIcmark_node *root\f[], \fIint options\f[], \fIcmark_llist *extensions\f[])
|
646
697
|
|
647
698
|
.PP
|
648
699
|
Render a \f[I]node\f[] tree as an HTML fragment. It is up to the user to
|
@@ -740,6 +791,19 @@ HTML comment. Unsafe links are replaced by empty strings.
|
|
740
791
|
.PP
|
741
792
|
Render \f[C]softbreak\f[] elements as spaces.
|
742
793
|
|
794
|
+
.PP
|
795
|
+
.nf
|
796
|
+
\fC
|
797
|
+
.RS 0n
|
798
|
+
#define CMARK_OPT_CODELANG (1 << 5)
|
799
|
+
.RE
|
800
|
+
\f[]
|
801
|
+
.fi
|
802
|
+
|
803
|
+
.PP
|
804
|
+
Render code blocks' language information in the \f[C]lang' attribute of
|
805
|
+
the\f[]pre' tag instead of a class on the `code' tag.
|
806
|
+
|
743
807
|
.SS
|
744
808
|
Options affecting parsing
|
745
809
|
|
@@ -785,7 +849,7 @@ dashes.
|
|
785
849
|
Version information
|
786
850
|
|
787
851
|
.PP
|
788
|
-
\fIint\f[] \fBcmark_version\f[](\
|
852
|
+
\fIint\f[] \fBcmark_version\f[](\fIvoid\f[])
|
789
853
|
|
790
854
|
.PP
|
791
855
|
The library version as integer for runtime checks. Also available as
|
@@ -800,7 +864,7 @@ Bits 0\-7 contain the patchlevel.
|
|
800
864
|
In hexadecimal format, the number 0x010203 represents version 1.2.3.
|
801
865
|
|
802
866
|
.PP
|
803
|
-
\fIconst char *\f[] \fBcmark_version_string\f[](\
|
867
|
+
\fIconst char *\f[] \fBcmark_version_string\f[](\fIvoid\f[])
|
804
868
|
|
805
869
|
.PP
|
806
870
|
The library version string for runtime checks. Also available as macro
|
@@ -3,6 +3,7 @@ set(LIBRARY "libcmark")
|
|
3
3
|
set(STATICLIBRARY "libcmark_static")
|
4
4
|
set(HEADERS
|
5
5
|
cmark.h
|
6
|
+
cmark_extension_api.h
|
6
7
|
parser.h
|
7
8
|
buffer.h
|
8
9
|
node.h
|
@@ -15,6 +16,9 @@ set(HEADERS
|
|
15
16
|
houdini.h
|
16
17
|
cmark_ctype.h
|
17
18
|
render.h
|
19
|
+
registry.h
|
20
|
+
syntax_extension.h
|
21
|
+
plugin.h
|
18
22
|
)
|
19
23
|
set(LIBRARY_SOURCES
|
20
24
|
cmark.c
|
@@ -37,12 +41,15 @@ set(LIBRARY_SOURCES
|
|
37
41
|
houdini_html_e.c
|
38
42
|
houdini_html_u.c
|
39
43
|
cmark_ctype.c
|
44
|
+
linked_list.c
|
45
|
+
syntax_extension.c
|
46
|
+
registry.c
|
47
|
+
plugin.c
|
40
48
|
${HEADERS}
|
41
49
|
)
|
42
50
|
|
43
51
|
set(PROGRAM "cmark")
|
44
52
|
set(PROGRAM_SOURCES
|
45
|
-
${LIBRARY_SOURCES}
|
46
53
|
main.c
|
47
54
|
)
|
48
55
|
|
@@ -70,6 +77,11 @@ include (GenerateExportHeader)
|
|
70
77
|
add_executable(${PROGRAM} ${PROGRAM_SOURCES})
|
71
78
|
add_compiler_export_flags()
|
72
79
|
|
80
|
+
target_link_libraries(${PROGRAM} libcmark)
|
81
|
+
|
82
|
+
add_dependencies(${PROGRAM} libcmarkextensions_static)
|
83
|
+
target_link_libraries(${PROGRAM} libcmarkextensions_static)
|
84
|
+
|
73
85
|
# Disable the PUBLIC declarations when compiling the executable:
|
74
86
|
set_target_properties(${PROGRAM} PROPERTIES
|
75
87
|
COMPILE_FLAGS -DCMARK_STATIC_DEFINE)
|
@@ -81,6 +93,8 @@ set(CMAKE_LINKER_DEBUG "${CMAKE_LINKER_FLAGS_DEBUG}")
|
|
81
93
|
set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE} -pg")
|
82
94
|
set(CMAKE_LINKER_PROFILE "${CMAKE_LINKER_FLAGS_RELEASE} -pg")
|
83
95
|
|
96
|
+
add_definitions(-DLIBDIR=\"${CMAKE_BINARY_DIR}\")
|
97
|
+
|
84
98
|
if (${CMAKE_MAJOR_VERSION} GREATER 1 AND ${CMAKE_MINOR_VERSION} GREATER 8)
|
85
99
|
set(CMAKE_C_VISIBILITY_PRESET hidden)
|
86
100
|
set(CMAKE_VISIBILITY_INLINES_HIDDEN 1)
|
@@ -134,6 +148,7 @@ install(TARGETS ${PROGRAM} ${LIBRARY} ${STATICLIBRARY}
|
|
134
148
|
|
135
149
|
install(FILES
|
136
150
|
cmark.h
|
151
|
+
cmark_extension_api.h
|
137
152
|
${CMAKE_CURRENT_BINARY_DIR}/cmark_export.h
|
138
153
|
${CMAKE_CURRENT_BINARY_DIR}/cmark_version.h
|
139
154
|
DESTINATION include
|
@@ -10,6 +10,7 @@
|
|
10
10
|
#include <stdio.h>
|
11
11
|
|
12
12
|
#include "cmark_ctype.h"
|
13
|
+
#include "syntax_extension.h"
|
13
14
|
#include "config.h"
|
14
15
|
#include "parser.h"
|
15
16
|
#include "cmark.h"
|
@@ -80,30 +81,57 @@ static cmark_node *make_document(cmark_mem *mem) {
|
|
80
81
|
return e;
|
81
82
|
}
|
82
83
|
|
83
|
-
cmark_parser *
|
84
|
-
|
85
|
-
parser->
|
84
|
+
int cmark_parser_attach_syntax_extension(cmark_parser *parser,
|
85
|
+
cmark_syntax_extension *extension) {
|
86
|
+
parser->syntax_extensions = cmark_llist_append(parser->syntax_extensions, extension);
|
87
|
+
if (extension->match_inline || extension->insert_inline_from_delim) {
|
88
|
+
parser->inline_syntax_extensions = cmark_llist_append(
|
89
|
+
parser->inline_syntax_extensions, extension);
|
90
|
+
}
|
86
91
|
|
87
|
-
|
92
|
+
return 1;
|
93
|
+
}
|
94
|
+
|
95
|
+
static void cmark_parser_dispose(cmark_parser *parser) {
|
96
|
+
if (parser->root)
|
97
|
+
cmark_node_free(parser->root);
|
88
98
|
|
89
|
-
|
90
|
-
|
99
|
+
if (parser->refmap)
|
100
|
+
cmark_reference_map_free(parser->refmap);
|
101
|
+
}
|
91
102
|
|
92
|
-
|
103
|
+
static void cmark_parser_reset(cmark_parser *parser) {
|
104
|
+
cmark_llist *saved_exts = parser->syntax_extensions;
|
105
|
+
cmark_llist *saved_inline_exts = parser->inline_syntax_extensions;
|
106
|
+
int saved_options = parser->options;
|
107
|
+
cmark_mem *saved_mem = parser->mem;
|
108
|
+
|
109
|
+
cmark_parser_dispose(parser);
|
110
|
+
|
111
|
+
memset(parser, 0, sizeof(cmark_parser));
|
112
|
+
parser->mem = saved_mem;
|
113
|
+
|
114
|
+
cmark_strbuf_init(parser->mem, &parser->curline, 256);
|
115
|
+
cmark_strbuf_init(parser->mem, &parser->linebuf, 0);
|
116
|
+
|
117
|
+
cmark_node *document = make_document(parser->mem);
|
118
|
+
|
119
|
+
parser->refmap = cmark_reference_map_new(parser->mem);
|
93
120
|
parser->root = document;
|
94
121
|
parser->current = document;
|
95
|
-
|
96
|
-
parser->offset = 0;
|
97
|
-
parser->column = 0;
|
98
|
-
parser->first_nonspace = 0;
|
99
|
-
parser->first_nonspace_column = 0;
|
100
|
-
parser->indent = 0;
|
101
|
-
parser->blank = false;
|
102
|
-
parser->partially_consumed_tab = false;
|
103
|
-
parser->last_line_length = 0;
|
104
|
-
parser->options = options;
|
122
|
+
|
105
123
|
parser->last_buffer_ended_with_cr = false;
|
106
124
|
|
125
|
+
parser->syntax_extensions = saved_exts;
|
126
|
+
parser->inline_syntax_extensions = saved_inline_exts;
|
127
|
+
parser->options = saved_options;
|
128
|
+
}
|
129
|
+
|
130
|
+
cmark_parser *cmark_parser_new_with_mem(int options, cmark_mem *mem) {
|
131
|
+
cmark_parser *parser = (cmark_parser *)mem->calloc(1, sizeof(cmark_parser));
|
132
|
+
parser->mem = mem;
|
133
|
+
parser->options = options;
|
134
|
+
cmark_parser_reset(parser);
|
107
135
|
return parser;
|
108
136
|
}
|
109
137
|
|
@@ -114,9 +142,11 @@ cmark_parser *cmark_parser_new(int options) {
|
|
114
142
|
|
115
143
|
void cmark_parser_free(cmark_parser *parser) {
|
116
144
|
cmark_mem *mem = parser->mem;
|
145
|
+
cmark_parser_dispose(parser);
|
117
146
|
cmark_strbuf_free(&parser->curline);
|
118
147
|
cmark_strbuf_free(&parser->linebuf);
|
119
|
-
|
148
|
+
cmark_llist_free(parser->syntax_extensions);
|
149
|
+
cmark_llist_free(parser->inline_syntax_extensions);
|
120
150
|
mem->free(parser);
|
121
151
|
}
|
122
152
|
|
@@ -143,23 +173,19 @@ static bool is_blank(cmark_strbuf *s, bufsize_t offset) {
|
|
143
173
|
return true;
|
144
174
|
}
|
145
175
|
|
146
|
-
static CMARK_INLINE bool can_contain(cmark_node_type parent_type,
|
147
|
-
cmark_node_type child_type) {
|
148
|
-
return (parent_type == CMARK_NODE_DOCUMENT ||
|
149
|
-
parent_type == CMARK_NODE_BLOCK_QUOTE ||
|
150
|
-
parent_type == CMARK_NODE_ITEM ||
|
151
|
-
(parent_type == CMARK_NODE_LIST && child_type == CMARK_NODE_ITEM));
|
152
|
-
}
|
153
|
-
|
154
176
|
static CMARK_INLINE bool accepts_lines(cmark_node_type block_type) {
|
155
177
|
return (block_type == CMARK_NODE_PARAGRAPH ||
|
156
178
|
block_type == CMARK_NODE_HEADING ||
|
157
179
|
block_type == CMARK_NODE_CODE_BLOCK);
|
158
180
|
}
|
159
181
|
|
160
|
-
static CMARK_INLINE bool contains_inlines(
|
161
|
-
|
162
|
-
|
182
|
+
static CMARK_INLINE bool contains_inlines(cmark_node *node) {
|
183
|
+
if (node->extension && node->extension->contains_inlines_func) {
|
184
|
+
return node->extension->contains_inlines_func(node->extension, node);
|
185
|
+
}
|
186
|
+
|
187
|
+
return (node->type == CMARK_NODE_PARAGRAPH ||
|
188
|
+
node->type == CMARK_NODE_HEADING);
|
163
189
|
}
|
164
190
|
|
165
191
|
static void add_line(cmark_node *node, cmark_chunk *ch, cmark_parser *parser) {
|
@@ -340,7 +366,7 @@ static cmark_node *add_child(cmark_parser *parser, cmark_node *parent,
|
|
340
366
|
|
341
367
|
// if 'parent' isn't the kind of node that can accept this child,
|
342
368
|
// then back up til we hit a node that can.
|
343
|
-
while (!
|
369
|
+
while (!cmark_node_can_contain_type(parent, block_type)) {
|
344
370
|
parent = finalize(parser, parent);
|
345
371
|
}
|
346
372
|
|
@@ -359,23 +385,42 @@ static cmark_node *add_child(cmark_parser *parser, cmark_node *parent,
|
|
359
385
|
return child;
|
360
386
|
}
|
361
387
|
|
388
|
+
static void manage_extensions_special_characters(cmark_parser *parser, bool add) {
|
389
|
+
cmark_llist *tmp_ext;
|
390
|
+
|
391
|
+
for (tmp_ext = parser->inline_syntax_extensions; tmp_ext; tmp_ext=tmp_ext->next) {
|
392
|
+
cmark_syntax_extension *ext = (cmark_syntax_extension *) tmp_ext->data;
|
393
|
+
cmark_llist *tmp_char;
|
394
|
+
for (tmp_char = ext->special_inline_chars; tmp_char; tmp_char=tmp_char->next) {
|
395
|
+
unsigned char c = (unsigned char) (unsigned long) tmp_char->data;
|
396
|
+
if (add)
|
397
|
+
cmark_inlines_add_special_character(c);
|
398
|
+
else
|
399
|
+
cmark_inlines_remove_special_character(c);
|
400
|
+
}
|
401
|
+
}
|
402
|
+
}
|
403
|
+
|
362
404
|
// Walk through node and all children, recursively, parsing
|
363
405
|
// string content into inline content where appropriate.
|
364
|
-
static void process_inlines(
|
365
|
-
|
366
|
-
cmark_iter *iter = cmark_iter_new(root);
|
406
|
+
static void process_inlines(cmark_parser *parser, cmark_reference_map *refmap, int options) {
|
407
|
+
cmark_iter *iter = cmark_iter_new(parser->root);
|
367
408
|
cmark_node *cur;
|
368
409
|
cmark_event_type ev_type;
|
369
410
|
|
411
|
+
manage_extensions_special_characters(parser, true);
|
412
|
+
|
370
413
|
while ((ev_type = cmark_iter_next(iter)) != CMARK_EVENT_DONE) {
|
371
414
|
cur = cmark_iter_get_node(iter);
|
372
415
|
if (ev_type == CMARK_EVENT_ENTER) {
|
373
|
-
if (contains_inlines(
|
374
|
-
cmark_parse_inlines(
|
416
|
+
if (contains_inlines(cur)) {
|
417
|
+
cmark_parse_inlines(parser, cur, refmap, options);
|
375
418
|
}
|
376
419
|
}
|
377
420
|
}
|
378
421
|
|
422
|
+
manage_extensions_special_characters(parser, false);
|
423
|
+
|
379
424
|
cmark_iter_free(iter);
|
380
425
|
}
|
381
426
|
|
@@ -482,7 +527,7 @@ static cmark_node *finalize_document(cmark_parser *parser) {
|
|
482
527
|
}
|
483
528
|
|
484
529
|
finalize(parser, parser->root);
|
485
|
-
process_inlines(parser
|
530
|
+
process_inlines(parser, parser->refmap, parser->options);
|
486
531
|
|
487
532
|
return parser->root;
|
488
533
|
}
|
@@ -521,6 +566,19 @@ void cmark_parser_feed(cmark_parser *parser, const char *buffer, size_t len) {
|
|
521
566
|
S_parser_feed(parser, (const unsigned char *)buffer, len, false);
|
522
567
|
}
|
523
568
|
|
569
|
+
void cmark_parser_feed_reentrant(cmark_parser *parser, const char *buffer, size_t len) {
|
570
|
+
cmark_strbuf saved_linebuf;
|
571
|
+
|
572
|
+
cmark_strbuf_init(parser->mem, &saved_linebuf, 0);
|
573
|
+
cmark_strbuf_puts(&saved_linebuf, cmark_strbuf_cstr(&parser->linebuf));
|
574
|
+
cmark_strbuf_clear(&parser->linebuf);
|
575
|
+
|
576
|
+
S_parser_feed(parser, (const unsigned char *)buffer, len, true);
|
577
|
+
|
578
|
+
cmark_strbuf_sets(&parser->linebuf, cmark_strbuf_cstr(&saved_linebuf));
|
579
|
+
cmark_strbuf_free(&saved_linebuf);
|
580
|
+
}
|
581
|
+
|
524
582
|
static void S_parser_feed(cmark_parser *parser, const unsigned char *buffer,
|
525
583
|
size_t len, bool eof) {
|
526
584
|
const unsigned char *end = buffer + len;
|
@@ -778,6 +836,21 @@ static bool parse_html_block_prefix(cmark_parser *parser,
|
|
778
836
|
return res;
|
779
837
|
}
|
780
838
|
|
839
|
+
static bool parse_extension_block(cmark_parser *parser,
|
840
|
+
cmark_node *container,
|
841
|
+
cmark_chunk *input)
|
842
|
+
{
|
843
|
+
bool res = false;
|
844
|
+
|
845
|
+
if (container->extension->last_block_matches) {
|
846
|
+
if (container->extension->last_block_matches(
|
847
|
+
container->extension, parser, input->data, input->len, container))
|
848
|
+
res = true;
|
849
|
+
}
|
850
|
+
|
851
|
+
return res;
|
852
|
+
}
|
853
|
+
|
781
854
|
/**
|
782
855
|
* For each containing node, try to parse the associated line start.
|
783
856
|
*
|
@@ -799,6 +872,12 @@ static cmark_node *check_open_blocks(cmark_parser *parser, cmark_chunk *input,
|
|
799
872
|
|
800
873
|
S_find_first_nonspace(parser, input);
|
801
874
|
|
875
|
+
if (container->extension) {
|
876
|
+
if (!parse_extension_block(parser, container, input))
|
877
|
+
goto done;
|
878
|
+
continue;
|
879
|
+
}
|
880
|
+
|
802
881
|
switch (cont_type) {
|
803
882
|
case CMARK_NODE_BLOCK_QUOTE:
|
804
883
|
if (!parse_block_quote_prefix(parser, input))
|
@@ -999,9 +1078,27 @@ static void open_new_blocks(cmark_parser *parser, cmark_node **container,
|
|
999
1078
|
(*container)->as.code.fence_length = 0;
|
1000
1079
|
(*container)->as.code.fence_offset = 0;
|
1001
1080
|
(*container)->as.code.info = cmark_chunk_literal("");
|
1002
|
-
|
1003
1081
|
} else {
|
1004
|
-
|
1082
|
+
cmark_llist *tmp;
|
1083
|
+
cmark_node *new_container = NULL;
|
1084
|
+
|
1085
|
+
for (tmp = parser->syntax_extensions; tmp; tmp=tmp->next) {
|
1086
|
+
cmark_syntax_extension *ext = (cmark_syntax_extension *) tmp->data;
|
1087
|
+
|
1088
|
+
if (ext->try_opening_block) {
|
1089
|
+
new_container = ext->try_opening_block(
|
1090
|
+
ext, indented, parser, *container, input->data, input->len);
|
1091
|
+
|
1092
|
+
if (new_container) {
|
1093
|
+
*container = new_container;
|
1094
|
+
break;
|
1095
|
+
}
|
1096
|
+
}
|
1097
|
+
}
|
1098
|
+
|
1099
|
+
if (!new_container) {
|
1100
|
+
break;
|
1101
|
+
}
|
1005
1102
|
}
|
1006
1103
|
|
1007
1104
|
if (accepts_lines(S_type(*container))) {
|
@@ -1134,6 +1231,9 @@ static void S_process_line(cmark_parser *parser, const unsigned char *buffer,
|
|
1134
1231
|
bool all_matched = true;
|
1135
1232
|
cmark_node *container;
|
1136
1233
|
cmark_chunk input;
|
1234
|
+
cmark_node *current;
|
1235
|
+
|
1236
|
+
cmark_strbuf_clear(&parser->curline);
|
1137
1237
|
|
1138
1238
|
if (parser->options & CMARK_OPT_VALIDATE_UTF8)
|
1139
1239
|
cmark_utf8proc_check(&parser->curline, buffer, bytes);
|
@@ -1161,9 +1261,13 @@ static void S_process_line(cmark_parser *parser, const unsigned char *buffer,
|
|
1161
1261
|
|
1162
1262
|
container = last_matched_container;
|
1163
1263
|
|
1264
|
+
current = parser->current;
|
1265
|
+
|
1164
1266
|
open_new_blocks(parser, &container, &input, all_matched);
|
1165
1267
|
|
1166
|
-
|
1268
|
+
/* parser->current might have changed if feed_reentrant was called */
|
1269
|
+
if (current == parser->current)
|
1270
|
+
add_text_to_container(parser, container, last_matched_container, &input);
|
1167
1271
|
|
1168
1272
|
finished:
|
1169
1273
|
parser->last_line_length = input.len;
|
@@ -1178,6 +1282,13 @@ finished:
|
|
1178
1282
|
}
|
1179
1283
|
|
1180
1284
|
cmark_node *cmark_parser_finish(cmark_parser *parser) {
|
1285
|
+
cmark_node *res;
|
1286
|
+
cmark_llist *extensions;
|
1287
|
+
|
1288
|
+
/* Parser was already finished once */
|
1289
|
+
if (parser->root == NULL)
|
1290
|
+
return NULL;
|
1291
|
+
|
1181
1292
|
if (parser->linebuf.size) {
|
1182
1293
|
S_process_line(parser, parser->linebuf.ptr, parser->linebuf.size);
|
1183
1294
|
cmark_strbuf_clear(&parser->linebuf);
|
@@ -1190,11 +1301,79 @@ cmark_node *cmark_parser_finish(cmark_parser *parser) {
|
|
1190
1301
|
}
|
1191
1302
|
|
1192
1303
|
cmark_strbuf_free(&parser->curline);
|
1304
|
+
cmark_strbuf_free(&parser->linebuf);
|
1193
1305
|
|
1194
1306
|
#if CMARK_DEBUG_NODES
|
1195
1307
|
if (cmark_node_check(parser->root, stderr)) {
|
1196
1308
|
abort();
|
1197
1309
|
}
|
1198
1310
|
#endif
|
1199
|
-
|
1311
|
+
|
1312
|
+
res = parser->root;
|
1313
|
+
parser->root = NULL;
|
1314
|
+
|
1315
|
+
cmark_parser_reset(parser);
|
1316
|
+
|
1317
|
+
for (extensions = parser->syntax_extensions; extensions; extensions = extensions->next) {
|
1318
|
+
cmark_syntax_extension *ext = (cmark_syntax_extension *) extensions->data;
|
1319
|
+
if (ext->postprocess_func) {
|
1320
|
+
cmark_node *processed = ext->postprocess_func(ext, res);
|
1321
|
+
if (processed)
|
1322
|
+
res = processed;
|
1323
|
+
}
|
1324
|
+
}
|
1325
|
+
|
1326
|
+
return res;
|
1327
|
+
}
|
1328
|
+
|
1329
|
+
int cmark_parser_get_line_number(cmark_parser *parser) {
|
1330
|
+
return parser->line_number;
|
1331
|
+
}
|
1332
|
+
|
1333
|
+
bufsize_t cmark_parser_get_offset(cmark_parser *parser) {
|
1334
|
+
return parser->offset;
|
1335
|
+
}
|
1336
|
+
|
1337
|
+
bufsize_t cmark_parser_get_column(cmark_parser *parser) {
|
1338
|
+
return parser->column;
|
1339
|
+
}
|
1340
|
+
|
1341
|
+
int cmark_parser_get_first_nonspace(cmark_parser *parser) {
|
1342
|
+
return parser->first_nonspace;
|
1343
|
+
}
|
1344
|
+
|
1345
|
+
int cmark_parser_get_first_nonspace_column(cmark_parser *parser) {
|
1346
|
+
return parser->first_nonspace_column;
|
1347
|
+
}
|
1348
|
+
|
1349
|
+
int cmark_parser_get_indent(cmark_parser *parser) {
|
1350
|
+
return parser->indent;
|
1351
|
+
}
|
1352
|
+
|
1353
|
+
int cmark_parser_is_blank(cmark_parser *parser) {
|
1354
|
+
return parser->blank;
|
1355
|
+
}
|
1356
|
+
|
1357
|
+
int cmark_parser_has_partially_consumed_tab(cmark_parser *parser) {
|
1358
|
+
return parser->partially_consumed_tab;
|
1359
|
+
}
|
1360
|
+
|
1361
|
+
int cmark_parser_get_last_line_length(cmark_parser *parser) {
|
1362
|
+
return parser->last_line_length;
|
1363
|
+
}
|
1364
|
+
|
1365
|
+
cmark_node *cmark_parser_add_child(cmark_parser *parser,
|
1366
|
+
cmark_node *parent,
|
1367
|
+
cmark_node_type block_type,
|
1368
|
+
int start_column) {
|
1369
|
+
return add_child(parser, parent, block_type, start_column);
|
1370
|
+
}
|
1371
|
+
|
1372
|
+
void cmark_parser_advance_offset(cmark_parser *parser,
|
1373
|
+
const char *input,
|
1374
|
+
int count,
|
1375
|
+
int columns) {
|
1376
|
+
cmark_chunk input_chunk = cmark_chunk_literal(input);
|
1377
|
+
|
1378
|
+
S_advance_offset(parser, &input_chunk, count, columns);
|
1200
1379
|
}
|