commonmarker 0.6.0 → 0.7.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/ext/commonmarker/cmark/CMakeLists.txt +2 -2
- data/ext/commonmarker/cmark/api_test/main.c +98 -90
- data/ext/commonmarker/cmark/build/CMakeCache.txt +82 -59
- data/ext/commonmarker/cmark/build/CMakeFiles/3.3.2/CMakeCCompiler.cmake +6 -6
- data/ext/commonmarker/cmark/build/CMakeFiles/3.3.2/CMakeCXXCompiler.cmake +6 -6
- data/ext/commonmarker/cmark/build/CMakeFiles/3.3.2/CMakeDetermineCompilerABI_C.bin +0 -0
- data/ext/commonmarker/cmark/build/CMakeFiles/3.3.2/CMakeDetermineCompilerABI_CXX.bin +0 -0
- data/ext/commonmarker/cmark/build/CMakeFiles/3.3.2/CMakeSystem.cmake +4 -4
- data/ext/commonmarker/cmark/build/CMakeFiles/3.3.2/CompilerIdC/a.out +0 -0
- data/ext/commonmarker/cmark/build/CMakeFiles/3.3.2/CompilerIdCXX/a.out +0 -0
- data/ext/commonmarker/cmark/build/CMakeFiles/CMakeError.log +6 -7
- data/ext/commonmarker/cmark/build/CMakeFiles/CMakeOutput.log +216 -381
- data/ext/commonmarker/cmark/build/CMakeFiles/Makefile.cmake +69 -0
- data/ext/commonmarker/cmark/build/CMakeFiles/feature_tests.bin +0 -0
- data/ext/commonmarker/cmark/build/Makefile +1 -1
- data/ext/commonmarker/cmark/build/api_test/CMakeFiles/api_test.dir/build.make +10 -10
- data/ext/commonmarker/cmark/build/api_test/CMakeFiles/api_test.dir/flags.make +2 -2
- data/ext/commonmarker/cmark/build/api_test/CMakeFiles/api_test.dir/link.txt +1 -1
- data/ext/commonmarker/cmark/build/api_test/Makefile +1 -1
- data/ext/commonmarker/cmark/build/man/Makefile +1 -1
- data/ext/commonmarker/cmark/build/src/CMakeFiles/cmark.dir/build.make +60 -60
- 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/libcmark.dir/DependInfo.cmake +1 -1
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark.dir/build.make +80 -80
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark.dir/cmake_clean.cmake +1 -1
- 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_static.dir/C.includecache +4 -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 +57 -57
- 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/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/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 +2 -2
- 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/render.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/xml.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/Makefile +1 -1
- data/ext/commonmarker/cmark/build/src/cmake_install.cmake +5 -5
- data/ext/commonmarker/cmark/build/src/cmark_version.h +2 -2
- data/ext/commonmarker/cmark/build/src/config.h +51 -0
- data/ext/commonmarker/cmark/build/src/libcmark.a +0 -0
- data/ext/commonmarker/cmark/build/src/libcmark.pc +1 -1
- data/ext/commonmarker/cmark/build/testdir/Makefile +1 -1
- data/ext/commonmarker/cmark/changelog.txt +54 -0
- data/ext/commonmarker/cmark/man/make_man_page.py +3 -1
- data/ext/commonmarker/cmark/man/man3/cmark.3 +114 -15
- data/ext/commonmarker/cmark/src/blocks.c +1 -5
- data/ext/commonmarker/cmark/src/chunk.h +4 -4
- data/ext/commonmarker/cmark/src/cmark.h +13 -7
- data/ext/commonmarker/cmark/src/commonmark.c +45 -27
- data/ext/commonmarker/cmark/src/config.h.in +51 -0
- data/ext/commonmarker/cmark/src/html.c +9 -7
- data/ext/commonmarker/cmark/src/iterator.c +3 -0
- data/ext/commonmarker/cmark/src/latex.c +4 -2
- data/ext/commonmarker/cmark/src/man.c +3 -2
- data/ext/commonmarker/cmark/src/node.c +10 -2
- data/ext/commonmarker/cmark/src/render.c +17 -5
- data/ext/commonmarker/cmark/src/scanners.c +10457 -16407
- data/ext/commonmarker/cmark/src/scanners.re +3 -3
- data/ext/commonmarker/cmark/src/xml.c +10 -7
- data/ext/commonmarker/cmark/test/smart_punct.txt +30 -30
- data/ext/commonmarker/cmark/test/spec.txt +2152 -1440
- data/ext/commonmarker/cmark/test/spec_tests.py +21 -17
- data/ext/commonmarker/cmark/wrappers/wrapper.py +1 -1
- data/lib/commonmarker/version.rb +1 -1
- data/test/test_helper.rb +23 -21
- data/test/test_smartpunct.rb +1 -1
- data/test/test_spec.rb +1 -1
- metadata +2 -11
- data/ext/commonmarker/cmark/build/CMakeFiles/2.8.10.1/CMakeCCompiler.cmake +0 -55
- data/ext/commonmarker/cmark/build/CMakeFiles/2.8.10.1/CMakeCXXCompiler.cmake +0 -56
- data/ext/commonmarker/cmark/build/CMakeFiles/2.8.10.1/CMakeDetermineCompilerABI_C.bin +0 -0
- data/ext/commonmarker/cmark/build/CMakeFiles/2.8.10.1/CMakeDetermineCompilerABI_CXX.bin +0 -0
- data/ext/commonmarker/cmark/build/CMakeFiles/2.8.10.1/CMakeSystem.cmake +0 -15
- data/ext/commonmarker/cmark/build/CMakeFiles/2.8.10.1/CompilerIdC/CMakeCCompilerId.c +0 -393
- data/ext/commonmarker/cmark/build/CMakeFiles/2.8.10.1/CompilerIdC/a.out +0 -0
- data/ext/commonmarker/cmark/build/CMakeFiles/2.8.10.1/CompilerIdCXX/CMakeCXXCompilerId.cpp +0 -375
- data/ext/commonmarker/cmark/build/CMakeFiles/2.8.10.1/CompilerIdCXX/a.out +0 -0
@@ -1,3 +1,10 @@
|
|
1
|
+
#ifndef CMARK_CONFIG_H
|
2
|
+
#define CMARK_CONFIG_H
|
3
|
+
|
4
|
+
#ifdef __cplusplus
|
5
|
+
extern "C" {
|
6
|
+
#endif
|
7
|
+
|
1
8
|
#define HAVE_STDBOOL_H
|
2
9
|
|
3
10
|
#ifdef HAVE_STDBOOL_H
|
@@ -23,3 +30,47 @@
|
|
23
30
|
#define CMARK_INLINE inline
|
24
31
|
#endif
|
25
32
|
#endif
|
33
|
+
|
34
|
+
/* snprintf and vsnprintf fallbacks for MSVC before 2015,
|
35
|
+
due to Valentin Milea http://stackoverflow.com/questions/2915672/
|
36
|
+
*/
|
37
|
+
|
38
|
+
#if defined(_MSC_VER) && _MSC_VER < 1900
|
39
|
+
|
40
|
+
#include <stdio.h>
|
41
|
+
#include <stdarg.h>
|
42
|
+
|
43
|
+
#define snprintf c99_snprintf
|
44
|
+
#define vsnprintf c99_vsnprintf
|
45
|
+
|
46
|
+
CMARK_INLINE int c99_vsnprintf(char *outBuf, size_t size, const char *format, va_list ap)
|
47
|
+
{
|
48
|
+
int count = -1;
|
49
|
+
|
50
|
+
if (size != 0)
|
51
|
+
count = _vsnprintf_s(outBuf, size, _TRUNCATE, format, ap);
|
52
|
+
if (count == -1)
|
53
|
+
count = _vscprintf(format, ap);
|
54
|
+
|
55
|
+
return count;
|
56
|
+
}
|
57
|
+
|
58
|
+
CMARK_INLINE int c99_snprintf(char *outBuf, size_t size, const char *format, ...)
|
59
|
+
{
|
60
|
+
int count;
|
61
|
+
va_list ap;
|
62
|
+
|
63
|
+
va_start(ap, format);
|
64
|
+
count = c99_vsnprintf(outBuf, size, format, ap);
|
65
|
+
va_end(ap);
|
66
|
+
|
67
|
+
return count;
|
68
|
+
}
|
69
|
+
|
70
|
+
#endif
|
71
|
+
|
72
|
+
#ifdef __cplusplus
|
73
|
+
}
|
74
|
+
#endif
|
75
|
+
|
76
|
+
#endif
|
Binary file
|
@@ -81,7 +81,7 @@ install/local/fast: install/local
|
|
81
81
|
# Special rule for the target edit_cache
|
82
82
|
edit_cache:
|
83
83
|
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running CMake cache editor..."
|
84
|
-
/usr/local/Cellar/cmake/
|
84
|
+
/usr/local/Cellar/cmake/3.3.2/bin/ccmake -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)
|
85
85
|
.PHONY : edit_cache
|
86
86
|
|
87
87
|
# Special rule for the target edit_cache
|
@@ -1,3 +1,57 @@
|
|
1
|
+
[0.24.1]
|
2
|
+
|
3
|
+
* Commonmark renderer:
|
4
|
+
+ Use HTML comment, not two blank lines, to separate a list
|
5
|
+
item from a following code block or list. This makes the
|
6
|
+
output more portable, since the "two blank lines" rule is
|
7
|
+
unique to CommonMark. Also, it allows us to break out of
|
8
|
+
a sublist without breaking out of all levels of nesting.
|
9
|
+
+ `is_autolink` - handle case where link has no children,
|
10
|
+
which previously caused a segfault.
|
11
|
+
+ Use 4-space indent for bullet lists, for increased portability.
|
12
|
+
+ Use 2-space + newline for line break for increased portability (#90).
|
13
|
+
+ Improved punctuation escaping. Previously all `)` and
|
14
|
+
`.` characters after digits were escaped; now they are
|
15
|
+
only escaped if they are genuinely in a position where
|
16
|
+
they'd cause a list item. This is achieved by changes in
|
17
|
+
`render.c`: (a) `renderer->begin_content` is only set to
|
18
|
+
false after a string of digits at the beginning of the
|
19
|
+
line, and (b) we never break a line before a digit.
|
20
|
+
Also, `begin_content` is properly initialized to true.
|
21
|
+
* Handle NULL root in `consolidate_text_nodes`.
|
22
|
+
|
23
|
+
[0.24.0]
|
24
|
+
|
25
|
+
* [API change] Added `cmark_node_replace(oldnode, newnode)`.
|
26
|
+
* Updated spec.txt to 0.24.
|
27
|
+
* Fixed edge case with escaped parens in link destination (#97).
|
28
|
+
This was also checked against the #82 case with asan.
|
29
|
+
* Removed unnecessary check for `fenced` in `cmark_render_html`.
|
30
|
+
It's sufficient to check that the info string is empty.
|
31
|
+
Indeed, those who use the API may well create a code block
|
32
|
+
with an info string without explicitly setting `fenced`.
|
33
|
+
* Updated format of `test/smart_punct.txt`.
|
34
|
+
* Updated `test/spec.txt`, `test/smart_punct.txt`, and
|
35
|
+
`spec_tests.py` to new format.
|
36
|
+
* Fixed `get_containing_block` logic in `src/commonmark.c`.
|
37
|
+
This did not allow for the possibility that a node might have no
|
38
|
+
containing block, causing the commonmark renderer to segfault if
|
39
|
+
passed an inline node with no block parent.
|
40
|
+
* Fixed string representations of `CUSTOM_BLOCK`,
|
41
|
+
`CUSTOM_INLINE`. The old versions `raw_inline` and
|
42
|
+
`raw_block` were being used, and this led to incorrect xml output.
|
43
|
+
* Use default opts in python sample wrapper.
|
44
|
+
* Allow multiline setext header content, as per spec.
|
45
|
+
* Don't allow spaces in link destinations, even with pointy brackets.
|
46
|
+
Conforms to latest change in spec.
|
47
|
+
* Updated `scheme` scanner according to spec change. We no longer use
|
48
|
+
a whitelist of valid schemes.
|
49
|
+
* Allow any kind of nodes as children of `CUSTOM_BLOCK` (#96).
|
50
|
+
* `cmark.h`: moved typedefs for iterator into iterator section.
|
51
|
+
This just moves some code around so it makes more sense
|
52
|
+
to read, and in the man page.
|
53
|
+
* Fixed `make_man_page.py` so it includes typedefs again.
|
54
|
+
|
1
55
|
[0.23.0]
|
2
56
|
|
3
57
|
* [API change] Added `CUSTOM_BLOCK` and `CUSTOM_INLINE` node types.
|
@@ -83,9 +83,11 @@ with open(sourcefile, 'r') as cmarkh:
|
|
83
83
|
state = 'default'
|
84
84
|
elif typedef and typedef_end_re.match(line):
|
85
85
|
typedef = False
|
86
|
+
elif typedef_start_re.match(line):
|
87
|
+
typedef = True
|
88
|
+
state = 'signature'
|
86
89
|
elif state == 'man':
|
87
90
|
state = 'signature'
|
88
|
-
typedef = typedef_start_re.match(line)
|
89
91
|
|
90
92
|
# handle line
|
91
93
|
if state == 'man':
|
@@ -1,4 +1,4 @@
|
|
1
|
-
.TH cmark 3 "
|
1
|
+
.TH cmark 3 "January 11, 2016" "LOCAL" "Library Functions Manual"
|
2
2
|
.SH
|
3
3
|
NAME
|
4
4
|
.PP
|
@@ -20,6 +20,80 @@ null\-terminated, UTF\-8\-encoded string.
|
|
20
20
|
.SS
|
21
21
|
Node Structure
|
22
22
|
|
23
|
+
.PP
|
24
|
+
.nf
|
25
|
+
\fC
|
26
|
+
.RS 0n
|
27
|
+
typedef enum {
|
28
|
+
/* Error status */
|
29
|
+
CMARK_NODE_NONE,
|
30
|
+
|
31
|
+
/* Block */
|
32
|
+
CMARK_NODE_DOCUMENT,
|
33
|
+
CMARK_NODE_BLOCK_QUOTE,
|
34
|
+
CMARK_NODE_LIST,
|
35
|
+
CMARK_NODE_ITEM,
|
36
|
+
CMARK_NODE_CODE_BLOCK,
|
37
|
+
CMARK_NODE_HTML_BLOCK,
|
38
|
+
CMARK_NODE_CUSTOM_BLOCK,
|
39
|
+
CMARK_NODE_PARAGRAPH,
|
40
|
+
CMARK_NODE_HEADING,
|
41
|
+
CMARK_NODE_THEMATIC_BREAK,
|
42
|
+
|
43
|
+
CMARK_NODE_FIRST_BLOCK = CMARK_NODE_DOCUMENT,
|
44
|
+
CMARK_NODE_LAST_BLOCK = CMARK_NODE_THEMATIC_BREAK,
|
45
|
+
|
46
|
+
/* Inline */
|
47
|
+
CMARK_NODE_TEXT,
|
48
|
+
CMARK_NODE_SOFTBREAK,
|
49
|
+
CMARK_NODE_LINEBREAK,
|
50
|
+
CMARK_NODE_CODE,
|
51
|
+
CMARK_NODE_HTML_INLINE,
|
52
|
+
CMARK_NODE_CUSTOM_INLINE,
|
53
|
+
CMARK_NODE_EMPH,
|
54
|
+
CMARK_NODE_STRONG,
|
55
|
+
CMARK_NODE_LINK,
|
56
|
+
CMARK_NODE_IMAGE,
|
57
|
+
|
58
|
+
CMARK_NODE_FIRST_INLINE = CMARK_NODE_TEXT,
|
59
|
+
CMARK_NODE_LAST_INLINE = CMARK_NODE_IMAGE,
|
60
|
+
} cmark_node_type;
|
61
|
+
.RE
|
62
|
+
\f[]
|
63
|
+
.fi
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
.PP
|
68
|
+
.nf
|
69
|
+
\fC
|
70
|
+
.RS 0n
|
71
|
+
typedef enum {
|
72
|
+
CMARK_NO_LIST,
|
73
|
+
CMARK_BULLET_LIST,
|
74
|
+
CMARK_ORDERED_LIST
|
75
|
+
} cmark_list_type;
|
76
|
+
.RE
|
77
|
+
\f[]
|
78
|
+
.fi
|
79
|
+
|
80
|
+
|
81
|
+
|
82
|
+
.PP
|
83
|
+
.nf
|
84
|
+
\fC
|
85
|
+
.RS 0n
|
86
|
+
typedef enum {
|
87
|
+
CMARK_NO_DELIM,
|
88
|
+
CMARK_PERIOD_DELIM,
|
89
|
+
CMARK_PAREN_DELIM
|
90
|
+
} cmark_delim_type;
|
91
|
+
.RE
|
92
|
+
\f[]
|
93
|
+
.fi
|
94
|
+
|
95
|
+
|
96
|
+
|
23
97
|
.SS
|
24
98
|
Creating and Destroying Nodes
|
25
99
|
|
@@ -28,8 +102,8 @@ Creating and Destroying Nodes
|
|
28
102
|
|
29
103
|
.PP
|
30
104
|
Creates a new node of type \f[I]type\f[]. Note that the node may have
|
31
|
-
other required properties, which it is the caller
|
32
|
-
assign.
|
105
|
+
other required properties, which it is the caller\[cq]s responsibility
|
106
|
+
to assign.
|
33
107
|
|
34
108
|
.PP
|
35
109
|
\fIvoid\f[] \fBcmark_node_free\f[](\fIcmark_node *node\f[])
|
@@ -129,6 +203,22 @@ CMARK_NODE_HTML_INLINE
|
|
129
203
|
Nodes must only be modified after an \f[C]EXIT\f[] event, or an
|
130
204
|
\f[C]ENTER\f[] event for leaf nodes.
|
131
205
|
|
206
|
+
.PP
|
207
|
+
.nf
|
208
|
+
\fC
|
209
|
+
.RS 0n
|
210
|
+
typedef enum {
|
211
|
+
CMARK_EVENT_NONE,
|
212
|
+
CMARK_EVENT_DONE,
|
213
|
+
CMARK_EVENT_ENTER,
|
214
|
+
CMARK_EVENT_EXIT
|
215
|
+
} cmark_event_type;
|
216
|
+
.RE
|
217
|
+
\f[]
|
218
|
+
.fi
|
219
|
+
|
220
|
+
|
221
|
+
|
132
222
|
.PP
|
133
223
|
\fIcmark_iter *\f[] \fBcmark_iter_new\f[](\fIcmark_node *root\f[])
|
134
224
|
|
@@ -286,7 +376,8 @@ Returns 1 if \f[I]node\f[] is a tight list, 0 otherwise.
|
|
286
376
|
\fIint\f[] \fBcmark_node_set_list_tight\f[](\fIcmark_node *node\f[], \fIint tight\f[])
|
287
377
|
|
288
378
|
.PP
|
289
|
-
Sets the
|
379
|
+
Sets the \[lq]tightness\[rq] of a list. Returns 1 on success, 0 on
|
380
|
+
failure.
|
290
381
|
|
291
382
|
.PP
|
292
383
|
\fIconst char *\f[] \fBcmark_node_get_fence_info\f[](\fIcmark_node *node\f[])
|
@@ -333,31 +424,31 @@ on failure.
|
|
333
424
|
\fIconst char *\f[] \fBcmark_node_get_on_enter\f[](\fIcmark_node *node\f[])
|
334
425
|
|
335
426
|
.PP
|
336
|
-
Returns the literal
|
337
|
-
empty string if no on_enter is set.
|
427
|
+
Returns the literal \[lq]on enter\[rq] text for a custom \f[I]node\f[],
|
428
|
+
or an empty string if no on_enter is set.
|
338
429
|
|
339
430
|
.PP
|
340
431
|
\fIint\f[] \fBcmark_node_set_on_enter\f[](\fIcmark_node *node\f[], \fIconst char *on_enter\f[])
|
341
432
|
|
342
433
|
.PP
|
343
|
-
Sets the literal text to render
|
344
|
-
Any children of the node will be rendered after this
|
345
|
-
success 0 on failure.
|
434
|
+
Sets the literal text to render \[lq]on enter\[rq] for a custom
|
435
|
+
\f[I]node\f[]. Any children of the node will be rendered after this
|
436
|
+
text. Returns 1 on success 0 on failure.
|
346
437
|
|
347
438
|
.PP
|
348
439
|
\fIconst char *\f[] \fBcmark_node_get_on_exit\f[](\fIcmark_node *node\f[])
|
349
440
|
|
350
441
|
.PP
|
351
|
-
Returns the literal
|
352
|
-
empty string if no on_exit is set.
|
442
|
+
Returns the literal \[lq]on exit\[rq] text for a custom \f[I]node\f[],
|
443
|
+
or an empty string if no on_exit is set.
|
353
444
|
|
354
445
|
.PP
|
355
446
|
\fIint\f[] \fBcmark_node_set_on_exit\f[](\fIcmark_node *node\f[], \fIconst char *on_exit\f[])
|
356
447
|
|
357
448
|
.PP
|
358
|
-
Sets the literal text to render
|
359
|
-
Any children of the node will be rendered before this
|
360
|
-
success 0 on failure.
|
449
|
+
Sets the literal text to render \[lq]on exit\[rq] for a custom
|
450
|
+
\f[I]node\f[]. Any children of the node will be rendered before this
|
451
|
+
text. Returns 1 on success 0 on failure.
|
361
452
|
|
362
453
|
.PP
|
363
454
|
\fIint\f[] \fBcmark_node_get_start_line\f[](\fIcmark_node *node\f[])
|
@@ -407,6 +498,14 @@ on failure.
|
|
407
498
|
Inserts \f[I]sibling\f[] after \f[I]node\f[]. Returns 1 on success, 0 on
|
408
499
|
failure.
|
409
500
|
|
501
|
+
.PP
|
502
|
+
\fIint\f[] \fBcmark_node_replace\f[](\fIcmark_node *oldnode\f[], \fIcmark_node *newnode\f[])
|
503
|
+
|
504
|
+
.PP
|
505
|
+
Replaces \f[I]oldnode\f[] with \f[I]newnode\f[] and unlinks
|
506
|
+
\f[I]oldnode\f[] (but does not free its memory). Returns 1 on success, 0
|
507
|
+
on failure.
|
508
|
+
|
410
509
|
.PP
|
411
510
|
\fIint\f[] \fBcmark_node_prepend_child\f[](\fIcmark_node *node\f[], \fIcmark_node *child\f[])
|
412
511
|
|
@@ -624,7 +723,7 @@ with the replacement character U+FFFD.
|
|
624
723
|
.fi
|
625
724
|
|
626
725
|
.PP
|
627
|
-
Convert straight quotes to curly,
|
726
|
+
Convert straight quotes to curly, \[em] to em dashes, \[en] to en
|
628
727
|
dashes.
|
629
728
|
|
630
729
|
.SS
|
@@ -800,11 +800,7 @@ static void S_process_line(cmark_parser *parser, const unsigned char *buffer,
|
|
800
800
|
|
801
801
|
} else if (!indented && container->type == CMARK_NODE_PARAGRAPH &&
|
802
802
|
(lev =
|
803
|
-
scan_setext_heading_line(&input, parser->first_nonspace))
|
804
|
-
// check that there is only one line in the paragraph:
|
805
|
-
(cmark_strbuf_strrchr(
|
806
|
-
&container->string_content, '\n',
|
807
|
-
cmark_strbuf_len(&container->string_content) - 2) < 0)) {
|
803
|
+
scan_setext_heading_line(&input, parser->first_nonspace))) {
|
808
804
|
|
809
805
|
container->type = CMARK_NODE_HEADING;
|
810
806
|
container->as.heading.level = lev;
|
@@ -48,8 +48,8 @@ static CMARK_INLINE void cmark_chunk_trim(cmark_chunk *c) {
|
|
48
48
|
cmark_chunk_rtrim(c);
|
49
49
|
}
|
50
50
|
|
51
|
-
static CMARK_INLINE bufsize_t
|
52
|
-
|
51
|
+
static CMARK_INLINE bufsize_t cmark_chunk_strchr(cmark_chunk *ch, int c,
|
52
|
+
bufsize_t offset) {
|
53
53
|
const unsigned char *p =
|
54
54
|
(unsigned char *)memchr(ch->data + offset, c, ch->len - offset);
|
55
55
|
return p ? (bufsize_t)(p - ch->data) : ch->len;
|
@@ -96,8 +96,8 @@ static CMARK_INLINE cmark_chunk cmark_chunk_literal(const char *data) {
|
|
96
96
|
return c;
|
97
97
|
}
|
98
98
|
|
99
|
-
static CMARK_INLINE cmark_chunk
|
100
|
-
|
99
|
+
static CMARK_INLINE cmark_chunk cmark_chunk_dup(const cmark_chunk *ch,
|
100
|
+
bufsize_t pos, bufsize_t len) {
|
101
101
|
cmark_chunk c = {ch->data + pos, len, 0};
|
102
102
|
return c;
|
103
103
|
}
|
@@ -86,13 +86,6 @@ typedef struct cmark_node cmark_node;
|
|
86
86
|
typedef struct cmark_parser cmark_parser;
|
87
87
|
typedef struct cmark_iter cmark_iter;
|
88
88
|
|
89
|
-
typedef enum {
|
90
|
-
CMARK_EVENT_NONE,
|
91
|
-
CMARK_EVENT_DONE,
|
92
|
-
CMARK_EVENT_ENTER,
|
93
|
-
CMARK_EVENT_EXIT
|
94
|
-
} cmark_event_type;
|
95
|
-
|
96
89
|
/**
|
97
90
|
* ## Creating and Destroying Nodes
|
98
91
|
*/
|
@@ -178,6 +171,13 @@ CMARK_EXPORT cmark_node *cmark_node_last_child(cmark_node *node);
|
|
178
171
|
* leaf nodes.
|
179
172
|
*/
|
180
173
|
|
174
|
+
typedef enum {
|
175
|
+
CMARK_EVENT_NONE,
|
176
|
+
CMARK_EVENT_DONE,
|
177
|
+
CMARK_EVENT_ENTER,
|
178
|
+
CMARK_EVENT_EXIT
|
179
|
+
} cmark_event_type;
|
180
|
+
|
181
181
|
/** Creates a new iterator starting at 'root'. The current node and event
|
182
182
|
* type are undefined until `cmark_iter_next` is called for the first time.
|
183
183
|
*/
|
@@ -387,6 +387,12 @@ CMARK_EXPORT int cmark_node_insert_before(cmark_node *node,
|
|
387
387
|
*/
|
388
388
|
CMARK_EXPORT int cmark_node_insert_after(cmark_node *node, cmark_node *sibling);
|
389
389
|
|
390
|
+
/** Replaces 'oldnode' with 'newnode' and unlinks 'oldnode' (but does
|
391
|
+
* not free its memory).
|
392
|
+
* Returns 1 on success, 0 on failure.
|
393
|
+
*/
|
394
|
+
CMARK_EXPORT int cmark_node_replace(cmark_node *oldnode, cmark_node *newnode);
|
395
|
+
|
390
396
|
/** Adds 'child' to the beginning of the children of 'node'.
|
391
397
|
* Returns 1 on success, 0 on failure.
|
392
398
|
*/
|
@@ -23,7 +23,11 @@
|
|
23
23
|
static inline void outc(cmark_renderer *renderer, cmark_escaping escape,
|
24
24
|
int32_t c, unsigned char nextc) {
|
25
25
|
bool needs_escaping = false;
|
26
|
-
|
26
|
+
bool follows_digit =
|
27
|
+
renderer->buffer->size > 0 &&
|
28
|
+
cmark_isdigit(renderer->buffer->ptr[renderer->buffer->size - 1]);
|
29
|
+
const size_t ENCODED_SIZE = 20;
|
30
|
+
char encoded[ENCODED_SIZE];
|
27
31
|
|
28
32
|
needs_escaping =
|
29
33
|
escape != LITERAL &&
|
@@ -31,9 +35,12 @@ static inline void outc(cmark_renderer *renderer, cmark_escaping escape,
|
|
31
35
|
(c == '*' || c == '_' || c == '[' || c == ']' || c == '#' || c == '<' ||
|
32
36
|
c == '>' || c == '\\' || c == '`' || c == '!' ||
|
33
37
|
(c == '&' && isalpha(nextc)) || (c == '!' && nextc == '[') ||
|
34
|
-
(renderer->begin_content && (c == '-' || c == '+' || c == '=')
|
35
|
-
|
36
|
-
|
38
|
+
(renderer->begin_content && (c == '-' || c == '+' || c == '=') &&
|
39
|
+
// begin_content doesn't get set to false til we've passed digits
|
40
|
+
// at the beginning of line, so...
|
41
|
+
!follows_digit) ||
|
42
|
+
(renderer->begin_content && (c == '.' || c == ')') && follows_digit &&
|
43
|
+
(nextc == 0 || cmark_isspace(nextc))))) ||
|
37
44
|
(escape == URL && (c == '`' || c == '<' || c == '>' || isspace(c) ||
|
38
45
|
c == '\\' || c == ')' || c == '(')) ||
|
39
46
|
(escape == TITLE &&
|
@@ -42,7 +49,7 @@ static inline void outc(cmark_renderer *renderer, cmark_escaping escape,
|
|
42
49
|
if (needs_escaping) {
|
43
50
|
if (isspace(c)) {
|
44
51
|
// use percent encoding for spaces
|
45
|
-
|
52
|
+
snprintf(encoded, ENCODED_SIZE, "%%%2x", c);
|
46
53
|
cmark_strbuf_puts(renderer->buffer, encoded);
|
47
54
|
renderer->column += 3;
|
48
55
|
} else {
|
@@ -121,6 +128,9 @@ static bool is_autolink(cmark_node *node) {
|
|
121
128
|
}
|
122
129
|
|
123
130
|
link_text = node->first_child;
|
131
|
+
if (link_text == NULL) {
|
132
|
+
return false;
|
133
|
+
}
|
124
134
|
cmark_consolidate_text_nodes(link_text);
|
125
135
|
realurl = (char *)url->data;
|
126
136
|
realurllen = url->len;
|
@@ -135,12 +145,17 @@ static bool is_autolink(cmark_node *node) {
|
|
135
145
|
|
136
146
|
// if node is a block node, returns node.
|
137
147
|
// otherwise returns first block-level node that is an ancestor of node.
|
148
|
+
// if there is no block-level ancestor, returns NULL.
|
138
149
|
static cmark_node *get_containing_block(cmark_node *node) {
|
139
|
-
while (node
|
140
|
-
|
141
|
-
|
150
|
+
while (node) {
|
151
|
+
if (node->type >= CMARK_NODE_FIRST_BLOCK &&
|
152
|
+
node->type <= CMARK_NODE_LAST_BLOCK) {
|
153
|
+
return node;
|
154
|
+
} else {
|
155
|
+
node = node->parent;
|
156
|
+
}
|
142
157
|
}
|
143
|
-
return
|
158
|
+
return NULL;
|
144
159
|
}
|
145
160
|
|
146
161
|
static int S_render_node(cmark_renderer *renderer, cmark_node *node,
|
@@ -153,7 +168,8 @@ static int S_render_node(cmark_renderer *renderer, cmark_node *node,
|
|
153
168
|
bool entering = (ev_type == CMARK_EVENT_ENTER);
|
154
169
|
const char *info, *code, *title;
|
155
170
|
size_t info_len, code_len;
|
156
|
-
|
171
|
+
const size_t LISTMARKER_SIZE = 20;
|
172
|
+
char listmarker[LISTMARKER_SIZE];
|
157
173
|
char *emph_delim;
|
158
174
|
bufsize_t marker_width;
|
159
175
|
|
@@ -163,10 +179,11 @@ static int S_render_node(cmark_renderer *renderer, cmark_node *node,
|
|
163
179
|
if (!(node->type == CMARK_NODE_ITEM && node->prev == NULL && entering)) {
|
164
180
|
tmp = get_containing_block(node);
|
165
181
|
renderer->in_tight_list_item =
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
182
|
+
tmp && // tmp might be NULL if there is no containing block
|
183
|
+
((tmp->type == CMARK_NODE_ITEM &&
|
184
|
+
cmark_node_get_list_tight(tmp->parent)) ||
|
185
|
+
(tmp && tmp->parent && tmp->parent->type == CMARK_NODE_ITEM &&
|
186
|
+
cmark_node_get_list_tight(tmp->parent->parent)));
|
170
187
|
}
|
171
188
|
|
172
189
|
switch (node->type) {
|
@@ -187,15 +204,17 @@ static int S_render_node(cmark_renderer *renderer, cmark_node *node,
|
|
187
204
|
case CMARK_NODE_LIST:
|
188
205
|
if (!entering && node->next && (node->next->type == CMARK_NODE_CODE_BLOCK ||
|
189
206
|
node->next->type == CMARK_NODE_LIST)) {
|
190
|
-
// this ensures
|
191
|
-
//
|
192
|
-
|
207
|
+
// this ensures that a following code block or list will be
|
208
|
+
// inteprereted correctly.
|
209
|
+
CR();
|
210
|
+
LIT("<!-- end list -->");
|
211
|
+
BLANKLINE();
|
193
212
|
}
|
194
213
|
break;
|
195
214
|
|
196
215
|
case CMARK_NODE_ITEM:
|
197
216
|
if (cmark_node_get_list_type(node->parent) == CMARK_BULLET_LIST) {
|
198
|
-
marker_width =
|
217
|
+
marker_width = 4;
|
199
218
|
} else {
|
200
219
|
list_number = cmark_node_get_list_start(node->parent);
|
201
220
|
list_delim = cmark_node_get_list_delim(node->parent);
|
@@ -207,22 +226,21 @@ static int S_render_node(cmark_renderer *renderer, cmark_node *node,
|
|
207
226
|
// we ensure a width of at least 4 so
|
208
227
|
// we get nice transition from single digits
|
209
228
|
// to double
|
210
|
-
|
211
|
-
|
212
|
-
|
229
|
+
snprintf(listmarker, LISTMARKER_SIZE, "%d%s%s", list_number,
|
230
|
+
list_delim == CMARK_PAREN_DELIM ? ")" : ".",
|
231
|
+
list_number < 10 ? " " : " ");
|
213
232
|
marker_width = safe_strlen(listmarker);
|
214
233
|
}
|
215
234
|
if (entering) {
|
216
235
|
if (cmark_node_get_list_type(node->parent) == CMARK_BULLET_LIST) {
|
217
|
-
LIT("
|
236
|
+
LIT(" - ");
|
218
237
|
renderer->begin_content = true;
|
219
|
-
cmark_strbuf_puts(renderer->prefix, " ");
|
220
238
|
} else {
|
221
239
|
LIT(listmarker);
|
222
240
|
renderer->begin_content = true;
|
223
|
-
|
224
|
-
|
225
|
-
|
241
|
+
}
|
242
|
+
for (i = marker_width; i--;) {
|
243
|
+
cmark_strbuf_putc(renderer->prefix, ' ');
|
226
244
|
}
|
227
245
|
} else {
|
228
246
|
cmark_strbuf_truncate(renderer->prefix,
|
@@ -314,7 +332,7 @@ static int S_render_node(cmark_renderer *renderer, cmark_node *node,
|
|
314
332
|
|
315
333
|
case CMARK_NODE_LINEBREAK:
|
316
334
|
if (!(CMARK_OPT_HARDBREAKS & options)) {
|
317
|
-
LIT("
|
335
|
+
LIT(" ");
|
318
336
|
}
|
319
337
|
CR();
|
320
338
|
break;
|