commonmarker 0.8.0 → 0.9.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/README.md +6 -1
- data/Rakefile +3 -3
- data/ext/commonmarker/cmark/build/CMakeCache.txt +8 -8
- data/ext/commonmarker/cmark/build/CMakeFiles/{3.5.1 → 3.5.2}/CMakeCCompiler.cmake +0 -0
- data/ext/commonmarker/cmark/build/CMakeFiles/{3.5.1 → 3.5.2}/CMakeCXXCompiler.cmake +0 -0
- data/ext/commonmarker/cmark/build/CMakeFiles/{3.5.1 → 3.5.2}/CMakeDetermineCompilerABI_C.bin +0 -0
- data/ext/commonmarker/cmark/build/CMakeFiles/{3.5.1 → 3.5.2}/CMakeDetermineCompilerABI_CXX.bin +0 -0
- data/ext/commonmarker/cmark/build/CMakeFiles/{3.5.1 → 3.5.2}/CMakeSystem.cmake +0 -0
- data/ext/commonmarker/cmark/build/CMakeFiles/{3.5.1 → 3.5.2}/CompilerIdC/CMakeCCompilerId.c +0 -0
- data/ext/commonmarker/cmark/build/CMakeFiles/{3.5.1 → 3.5.2}/CompilerIdC/a.out +0 -0
- data/ext/commonmarker/cmark/build/CMakeFiles/{3.5.1 → 3.5.2}/CompilerIdCXX/CMakeCXXCompilerId.cpp +0 -0
- data/ext/commonmarker/cmark/build/CMakeFiles/{3.5.1 → 3.5.2}/CompilerIdCXX/a.out +0 -0
- data/ext/commonmarker/cmark/build/CMakeFiles/CMakeError.log +6 -6
- data/ext/commonmarker/cmark/build/CMakeFiles/CMakeOutput.log +143 -143
- data/ext/commonmarker/cmark/build/CMakeFiles/Makefile.cmake +106 -106
- data/ext/commonmarker/cmark/build/CMakeFiles/Makefile2 +2 -2
- data/ext/commonmarker/cmark/build/Makefile +9 -9
- data/ext/commonmarker/cmark/build/api_test/CMakeFiles/api_test.dir/build.make +2 -2
- data/ext/commonmarker/cmark/build/api_test/Makefile +9 -9
- data/ext/commonmarker/cmark/build/man/Makefile +9 -9
- data/ext/commonmarker/cmark/build/src/CMakeFiles/cmark.dir/build.make +2 -2
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark.dir/build.make +2 -2
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/build.make +2 -2
- data/ext/commonmarker/cmark/build/src/Makefile +9 -9
- data/ext/commonmarker/cmark/build/src/libcmark.a +0 -0
- data/ext/commonmarker/cmark/build/testdir/Makefile +9 -9
- data/ext/commonmarker/commonmarker.c +579 -662
- data/ext/commonmarker/commonmarker.c.orig +1041 -0
- data/ext/commonmarker/commonmarker.h +1 -1
- data/lib/commonmarker.rb +1 -32
- data/lib/commonmarker/node.rb +45 -0
- data/lib/commonmarker/renderer.rb +2 -2
- data/lib/commonmarker/version.rb +1 -1
- data/test/test_basics.rb +1 -40
- data/test/test_node.rb +78 -0
- data/test/test_renderer.rb +13 -0
- metadata +17 -11
@@ -34,10 +34,10 @@ cmake_force:
|
|
34
34
|
SHELL = /bin/sh
|
35
35
|
|
36
36
|
# The CMake executable.
|
37
|
-
CMAKE_COMMAND = /usr/local/Cellar/cmake/3.5.
|
37
|
+
CMAKE_COMMAND = /usr/local/Cellar/cmake/3.5.2/bin/cmake
|
38
38
|
|
39
39
|
# The command to remove a file.
|
40
|
-
RM = /usr/local/Cellar/cmake/3.5.
|
40
|
+
RM = /usr/local/Cellar/cmake/3.5.2/bin/cmake -E remove -f
|
41
41
|
|
42
42
|
# Escaping for special characters.
|
43
43
|
EQUALS = =
|
@@ -34,10 +34,10 @@ cmake_force:
|
|
34
34
|
SHELL = /bin/sh
|
35
35
|
|
36
36
|
# The CMake executable.
|
37
|
-
CMAKE_COMMAND = /usr/local/Cellar/cmake/3.5.
|
37
|
+
CMAKE_COMMAND = /usr/local/Cellar/cmake/3.5.2/bin/cmake
|
38
38
|
|
39
39
|
# The command to remove a file.
|
40
|
-
RM = /usr/local/Cellar/cmake/3.5.
|
40
|
+
RM = /usr/local/Cellar/cmake/3.5.2/bin/cmake -E remove -f
|
41
41
|
|
42
42
|
# Escaping for special characters.
|
43
43
|
EQUALS = =
|
@@ -34,10 +34,10 @@ cmake_force:
|
|
34
34
|
SHELL = /bin/sh
|
35
35
|
|
36
36
|
# The CMake executable.
|
37
|
-
CMAKE_COMMAND = /usr/local/Cellar/cmake/3.5.
|
37
|
+
CMAKE_COMMAND = /usr/local/Cellar/cmake/3.5.2/bin/cmake
|
38
38
|
|
39
39
|
# The command to remove a file.
|
40
|
-
RM = /usr/local/Cellar/cmake/3.5.
|
40
|
+
RM = /usr/local/Cellar/cmake/3.5.2/bin/cmake -E remove -f
|
41
41
|
|
42
42
|
# Escaping for special characters.
|
43
43
|
EQUALS = =
|
@@ -39,10 +39,10 @@ cmake_force:
|
|
39
39
|
SHELL = /bin/sh
|
40
40
|
|
41
41
|
# The CMake executable.
|
42
|
-
CMAKE_COMMAND = /usr/local/Cellar/cmake/3.5.
|
42
|
+
CMAKE_COMMAND = /usr/local/Cellar/cmake/3.5.2/bin/cmake
|
43
43
|
|
44
44
|
# The command to remove a file.
|
45
|
-
RM = /usr/local/Cellar/cmake/3.5.
|
45
|
+
RM = /usr/local/Cellar/cmake/3.5.2/bin/cmake -E remove -f
|
46
46
|
|
47
47
|
# Escaping for special characters.
|
48
48
|
EQUALS = =
|
@@ -59,7 +59,7 @@ CMAKE_BINARY_DIR = /Users/gjtorikian/Development/commonmarker/ext/commonmarker/c
|
|
59
59
|
# Special rule for the target test
|
60
60
|
test:
|
61
61
|
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running tests..."
|
62
|
-
/usr/local/Cellar/cmake/3.5.
|
62
|
+
/usr/local/Cellar/cmake/3.5.2/bin/ctest --force-new-ctest-process $(ARGS)
|
63
63
|
.PHONY : test
|
64
64
|
|
65
65
|
# Special rule for the target test
|
@@ -70,7 +70,7 @@ test/fast: test
|
|
70
70
|
# Special rule for the target install/local
|
71
71
|
install/local: preinstall
|
72
72
|
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Installing only the local directory..."
|
73
|
-
/usr/local/Cellar/cmake/3.5.
|
73
|
+
/usr/local/Cellar/cmake/3.5.2/bin/cmake -DCMAKE_INSTALL_LOCAL_ONLY=1 -P cmake_install.cmake
|
74
74
|
.PHONY : install/local
|
75
75
|
|
76
76
|
# Special rule for the target install/local
|
@@ -91,19 +91,19 @@ list_install_components/fast: list_install_components
|
|
91
91
|
# Special rule for the target install
|
92
92
|
install: preinstall
|
93
93
|
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Install the project..."
|
94
|
-
/usr/local/Cellar/cmake/3.5.
|
94
|
+
/usr/local/Cellar/cmake/3.5.2/bin/cmake -P cmake_install.cmake
|
95
95
|
.PHONY : install
|
96
96
|
|
97
97
|
# Special rule for the target install
|
98
98
|
install/fast: preinstall/fast
|
99
99
|
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Install the project..."
|
100
|
-
/usr/local/Cellar/cmake/3.5.
|
100
|
+
/usr/local/Cellar/cmake/3.5.2/bin/cmake -P cmake_install.cmake
|
101
101
|
.PHONY : install/fast
|
102
102
|
|
103
103
|
# Special rule for the target install/strip
|
104
104
|
install/strip: preinstall
|
105
105
|
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Installing the project stripped..."
|
106
|
-
/usr/local/Cellar/cmake/3.5.
|
106
|
+
/usr/local/Cellar/cmake/3.5.2/bin/cmake -DCMAKE_INSTALL_DO_STRIP=1 -P cmake_install.cmake
|
107
107
|
.PHONY : install/strip
|
108
108
|
|
109
109
|
# Special rule for the target install/strip
|
@@ -114,7 +114,7 @@ install/strip/fast: install/strip
|
|
114
114
|
# Special rule for the target rebuild_cache
|
115
115
|
rebuild_cache:
|
116
116
|
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running CMake to regenerate build system..."
|
117
|
-
/usr/local/Cellar/cmake/3.5.
|
117
|
+
/usr/local/Cellar/cmake/3.5.2/bin/cmake -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)
|
118
118
|
.PHONY : rebuild_cache
|
119
119
|
|
120
120
|
# Special rule for the target rebuild_cache
|
@@ -125,7 +125,7 @@ rebuild_cache/fast: rebuild_cache
|
|
125
125
|
# Special rule for the target edit_cache
|
126
126
|
edit_cache:
|
127
127
|
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running CMake cache editor..."
|
128
|
-
/usr/local/Cellar/cmake/3.5.
|
128
|
+
/usr/local/Cellar/cmake/3.5.2/bin/ccmake -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)
|
129
129
|
.PHONY : edit_cache
|
130
130
|
|
131
131
|
# Special rule for the target edit_cache
|
Binary file
|
@@ -39,10 +39,10 @@ cmake_force:
|
|
39
39
|
SHELL = /bin/sh
|
40
40
|
|
41
41
|
# The CMake executable.
|
42
|
-
CMAKE_COMMAND = /usr/local/Cellar/cmake/3.5.
|
42
|
+
CMAKE_COMMAND = /usr/local/Cellar/cmake/3.5.2/bin/cmake
|
43
43
|
|
44
44
|
# The command to remove a file.
|
45
|
-
RM = /usr/local/Cellar/cmake/3.5.
|
45
|
+
RM = /usr/local/Cellar/cmake/3.5.2/bin/cmake -E remove -f
|
46
46
|
|
47
47
|
# Escaping for special characters.
|
48
48
|
EQUALS = =
|
@@ -59,7 +59,7 @@ CMAKE_BINARY_DIR = /Users/gjtorikian/Development/commonmarker/ext/commonmarker/c
|
|
59
59
|
# Special rule for the target test
|
60
60
|
test:
|
61
61
|
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running tests..."
|
62
|
-
/usr/local/Cellar/cmake/3.5.
|
62
|
+
/usr/local/Cellar/cmake/3.5.2/bin/ctest --force-new-ctest-process $(ARGS)
|
63
63
|
.PHONY : test
|
64
64
|
|
65
65
|
# Special rule for the target test
|
@@ -70,7 +70,7 @@ test/fast: test
|
|
70
70
|
# Special rule for the target install/local
|
71
71
|
install/local: preinstall
|
72
72
|
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Installing only the local directory..."
|
73
|
-
/usr/local/Cellar/cmake/3.5.
|
73
|
+
/usr/local/Cellar/cmake/3.5.2/bin/cmake -DCMAKE_INSTALL_LOCAL_ONLY=1 -P cmake_install.cmake
|
74
74
|
.PHONY : install/local
|
75
75
|
|
76
76
|
# Special rule for the target install/local
|
@@ -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/3.5.
|
84
|
+
/usr/local/Cellar/cmake/3.5.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
|
@@ -92,7 +92,7 @@ edit_cache/fast: edit_cache
|
|
92
92
|
# Special rule for the target rebuild_cache
|
93
93
|
rebuild_cache:
|
94
94
|
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running CMake to regenerate build system..."
|
95
|
-
/usr/local/Cellar/cmake/3.5.
|
95
|
+
/usr/local/Cellar/cmake/3.5.2/bin/cmake -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)
|
96
96
|
.PHONY : rebuild_cache
|
97
97
|
|
98
98
|
# Special rule for the target rebuild_cache
|
@@ -113,19 +113,19 @@ list_install_components/fast: list_install_components
|
|
113
113
|
# Special rule for the target install
|
114
114
|
install: preinstall
|
115
115
|
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Install the project..."
|
116
|
-
/usr/local/Cellar/cmake/3.5.
|
116
|
+
/usr/local/Cellar/cmake/3.5.2/bin/cmake -P cmake_install.cmake
|
117
117
|
.PHONY : install
|
118
118
|
|
119
119
|
# Special rule for the target install
|
120
120
|
install/fast: preinstall/fast
|
121
121
|
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Install the project..."
|
122
|
-
/usr/local/Cellar/cmake/3.5.
|
122
|
+
/usr/local/Cellar/cmake/3.5.2/bin/cmake -P cmake_install.cmake
|
123
123
|
.PHONY : install/fast
|
124
124
|
|
125
125
|
# Special rule for the target install/strip
|
126
126
|
install/strip: preinstall
|
127
127
|
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Installing the project stripped..."
|
128
|
-
/usr/local/Cellar/cmake/3.5.
|
128
|
+
/usr/local/Cellar/cmake/3.5.2/bin/cmake -DCMAKE_INSTALL_DO_STRIP=1 -P cmake_install.cmake
|
129
129
|
.PHONY : install/strip
|
130
130
|
|
131
131
|
# Special rule for the target install/strip
|
@@ -1,7 +1,7 @@
|
|
1
1
|
#include "commonmarker.h"
|
2
2
|
#include "cmark.h"
|
3
|
-
#include "node.h"
|
4
3
|
#include "houdini.h"
|
4
|
+
#include "node.h"
|
5
5
|
|
6
6
|
static VALUE rb_mNodeError;
|
7
7
|
static VALUE rb_mNode;
|
@@ -28,110 +28,92 @@ static VALUE sym_image;
|
|
28
28
|
static VALUE sym_bullet_list;
|
29
29
|
static VALUE sym_ordered_list;
|
30
30
|
|
31
|
-
static void
|
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
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
return (VALUE)user_data;
|
85
|
-
|
86
|
-
/* Only free tree roots. */
|
87
|
-
free_func = cmark_node_parent(node)
|
88
|
-
? NULL
|
89
|
-
: rb_free_c_struct;
|
90
|
-
val = Data_Wrap_Struct(rb_mNode, rb_mark_c_struct, free_func,
|
91
|
-
node);
|
92
|
-
cmark_node_set_user_data(node, (void *)val);
|
93
|
-
|
94
|
-
return val;
|
31
|
+
static void rb_mark_c_struct(void *data) {
|
32
|
+
cmark_node *node = data;
|
33
|
+
cmark_node *child;
|
34
|
+
|
35
|
+
/* Mark the parent to make sure that the tree won't be freed as
|
36
|
+
long as a child node is referenced. */
|
37
|
+
cmark_node *parent = cmark_node_parent(node);
|
38
|
+
if (parent) {
|
39
|
+
void *user_data = cmark_node_get_user_data(parent);
|
40
|
+
if (!user_data) {
|
41
|
+
/* This should never happen. Child can nodes can only
|
42
|
+
be returned from parents that already are
|
43
|
+
associated with a Ruby object. */
|
44
|
+
fprintf(stderr, "parent without user_data\n");
|
45
|
+
abort();
|
46
|
+
}
|
47
|
+
rb_gc_mark((VALUE)user_data);
|
48
|
+
}
|
49
|
+
|
50
|
+
/* Mark all children to make sure their cached Ruby objects won't
|
51
|
+
be freed. */
|
52
|
+
for (child = cmark_node_first_child(node); child != NULL;
|
53
|
+
child = cmark_node_next(child)) {
|
54
|
+
void *user_data = cmark_node_get_user_data(child);
|
55
|
+
if (user_data)
|
56
|
+
rb_gc_mark((VALUE)user_data);
|
57
|
+
}
|
58
|
+
}
|
59
|
+
|
60
|
+
static void rb_free_c_struct(void *data) {
|
61
|
+
/* It's important that the `free` function does not inspect the
|
62
|
+
node data, as it may be part of a tree that was already freed. */
|
63
|
+
cmark_node_free(data);
|
64
|
+
}
|
65
|
+
|
66
|
+
static VALUE rb_node_to_value(cmark_node *node) {
|
67
|
+
void *user_data;
|
68
|
+
RUBY_DATA_FUNC free_func;
|
69
|
+
VALUE val;
|
70
|
+
|
71
|
+
if (node == NULL)
|
72
|
+
return Qnil;
|
73
|
+
|
74
|
+
user_data = cmark_node_get_user_data(node);
|
75
|
+
if (user_data)
|
76
|
+
return (VALUE)user_data;
|
77
|
+
|
78
|
+
/* Only free tree roots. */
|
79
|
+
free_func = cmark_node_parent(node) ? NULL : rb_free_c_struct;
|
80
|
+
val = Data_Wrap_Struct(rb_mNode, rb_mark_c_struct, free_func, node);
|
81
|
+
cmark_node_set_user_data(node, (void *)val);
|
82
|
+
|
83
|
+
return val;
|
95
84
|
}
|
96
85
|
|
97
86
|
/* If the node structure is changed, the finalizers must be updated. */
|
98
87
|
|
99
|
-
static void
|
100
|
-
rb_parent_added(VALUE val)
|
101
|
-
{
|
102
|
-
RDATA(val)->dfree = NULL;
|
103
|
-
}
|
88
|
+
static void rb_parent_added(VALUE val) { RDATA(val)->dfree = NULL; }
|
104
89
|
|
105
|
-
static void
|
106
|
-
|
107
|
-
{
|
108
|
-
RDATA(val)->dfree = rb_free_c_struct;
|
90
|
+
static void rb_parent_removed(VALUE val) {
|
91
|
+
RDATA(val)->dfree = rb_free_c_struct;
|
109
92
|
}
|
110
93
|
|
111
94
|
/*
|
112
95
|
* Internal: Parses a Markdown string into an HTML string.
|
113
96
|
*
|
114
97
|
*/
|
115
|
-
static VALUE
|
116
|
-
|
117
|
-
|
118
|
-
char *str;
|
119
|
-
int len, options;
|
98
|
+
static VALUE rb_markdown_to_html(VALUE self, VALUE rb_text, VALUE rb_options) {
|
99
|
+
char *str;
|
100
|
+
int len, options;
|
120
101
|
|
121
|
-
|
122
|
-
|
102
|
+
Check_Type(rb_text, T_STRING);
|
103
|
+
Check_Type(rb_options, T_FIXNUM);
|
123
104
|
|
124
|
-
|
125
|
-
|
126
|
-
|
105
|
+
str = (char *)RSTRING_PTR(rb_text);
|
106
|
+
len = RSTRING_LEN(rb_text);
|
107
|
+
options = FIX2INT(rb_options);
|
127
108
|
|
128
|
-
|
109
|
+
return rb_str_new2(cmark_markdown_to_html(str, len, options));
|
129
110
|
}
|
130
111
|
|
131
112
|
/*
|
132
113
|
* Internal: Creates a node based on a node type.
|
133
114
|
*
|
134
|
-
* type - A {Symbol} representing the node to be created. Must be one of the
|
115
|
+
* type - A {Symbol} representing the node to be created. Must be one of the
|
116
|
+
* following:
|
135
117
|
* - `:document`
|
136
118
|
* - `:blockquote`
|
137
119
|
* - `:list`
|
@@ -151,85 +133,82 @@ rb_markdown_to_html(VALUE self, VALUE rb_text, VALUE rb_options)
|
|
151
133
|
* - `:link`
|
152
134
|
* - `:image`
|
153
135
|
*/
|
154
|
-
static VALUE
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
return rb_node_to_value(node);
|
136
|
+
static VALUE rb_node_new(VALUE self, VALUE type) {
|
137
|
+
cmark_node_type node_type = 0;
|
138
|
+
cmark_node *node;
|
139
|
+
|
140
|
+
Check_Type(type, T_SYMBOL);
|
141
|
+
|
142
|
+
if (type == sym_document)
|
143
|
+
node_type = CMARK_NODE_DOCUMENT;
|
144
|
+
else if (type == sym_blockquote)
|
145
|
+
node_type = CMARK_NODE_BLOCK_QUOTE;
|
146
|
+
else if (type == sym_list)
|
147
|
+
node_type = CMARK_NODE_LIST;
|
148
|
+
else if (type == sym_list_item)
|
149
|
+
node_type = CMARK_NODE_ITEM;
|
150
|
+
else if (type == sym_code_block)
|
151
|
+
node_type = CMARK_NODE_CODE_BLOCK;
|
152
|
+
else if (type == sym_html)
|
153
|
+
node_type = CMARK_NODE_HTML;
|
154
|
+
else if (type == sym_paragraph)
|
155
|
+
node_type = CMARK_NODE_PARAGRAPH;
|
156
|
+
else if (type == sym_header)
|
157
|
+
node_type = CMARK_NODE_HEADER;
|
158
|
+
else if (type == sym_hrule)
|
159
|
+
node_type = CMARK_NODE_HRULE;
|
160
|
+
else if (type == sym_text)
|
161
|
+
node_type = CMARK_NODE_TEXT;
|
162
|
+
else if (type == sym_softbreak)
|
163
|
+
node_type = CMARK_NODE_SOFTBREAK;
|
164
|
+
else if (type == sym_linebreak)
|
165
|
+
node_type = CMARK_NODE_LINEBREAK;
|
166
|
+
else if (type == sym_code)
|
167
|
+
node_type = CMARK_NODE_CODE;
|
168
|
+
else if (type == sym_inline_html)
|
169
|
+
node_type = CMARK_NODE_INLINE_HTML;
|
170
|
+
else if (type == sym_emph)
|
171
|
+
node_type = CMARK_NODE_EMPH;
|
172
|
+
else if (type == sym_strong)
|
173
|
+
node_type = CMARK_NODE_STRONG;
|
174
|
+
else if (type == sym_link)
|
175
|
+
node_type = CMARK_NODE_LINK;
|
176
|
+
else if (type == sym_image)
|
177
|
+
node_type = CMARK_NODE_IMAGE;
|
178
|
+
else
|
179
|
+
rb_raise(rb_mNodeError, "invalid node of type %d", node_type);
|
180
|
+
|
181
|
+
node = cmark_node_new(node_type);
|
182
|
+
if (node == NULL) {
|
183
|
+
rb_raise(rb_mNodeError, "could not create node of type %d", node_type);
|
184
|
+
}
|
185
|
+
|
186
|
+
return rb_node_to_value(node);
|
207
187
|
}
|
208
188
|
|
209
189
|
/*
|
210
190
|
* Internal: Parses a Markdown string into a document.
|
211
191
|
*
|
212
192
|
*/
|
213
|
-
static VALUE
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
return rb_node_to_value(doc);
|
193
|
+
static VALUE rb_parse_document(VALUE self, VALUE rb_text, VALUE rb_len,
|
194
|
+
VALUE rb_options) {
|
195
|
+
char *text;
|
196
|
+
int len, options;
|
197
|
+
cmark_node *doc;
|
198
|
+
Check_Type(rb_text, T_STRING);
|
199
|
+
Check_Type(rb_len, T_FIXNUM);
|
200
|
+
Check_Type(rb_options, T_FIXNUM);
|
201
|
+
|
202
|
+
text = (char *)RSTRING_PTR(rb_text);
|
203
|
+
len = FIX2INT(rb_len);
|
204
|
+
options = FIX2INT(rb_options);
|
205
|
+
|
206
|
+
doc = cmark_parse_document(text, len, options);
|
207
|
+
if (doc == NULL) {
|
208
|
+
rb_raise(rb_mNodeError, "error parsing document");
|
209
|
+
}
|
210
|
+
|
211
|
+
return rb_node_to_value(doc);
|
233
212
|
}
|
234
213
|
|
235
214
|
/*
|
@@ -237,19 +216,17 @@ rb_parse_document(VALUE self, VALUE rb_text, VALUE rb_len, VALUE rb_options)
|
|
237
216
|
*
|
238
217
|
* Returns a {String}.
|
239
218
|
*/
|
240
|
-
static VALUE
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
return rb_str_new2(text);
|
219
|
+
static VALUE rb_node_get_string_content(VALUE self) {
|
220
|
+
const char *text;
|
221
|
+
cmark_node *node;
|
222
|
+
Data_Get_Struct(self, cmark_node, node);
|
223
|
+
|
224
|
+
text = cmark_node_get_literal(node);
|
225
|
+
if (text == NULL) {
|
226
|
+
rb_raise(rb_mNodeError, "could not get string content");
|
227
|
+
}
|
228
|
+
|
229
|
+
return rb_str_new2(text);
|
253
230
|
}
|
254
231
|
|
255
232
|
/*
|
@@ -259,21 +236,19 @@ rb_node_get_string_content(VALUE self)
|
|
259
236
|
*
|
260
237
|
* Raises NodeError if the string content can't be set.
|
261
238
|
*/
|
262
|
-
static VALUE
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
cmark_node *node;
|
267
|
-
Check_Type(s, T_STRING);
|
239
|
+
static VALUE rb_node_set_string_content(VALUE self, VALUE s) {
|
240
|
+
char *text;
|
241
|
+
cmark_node *node;
|
242
|
+
Check_Type(s, T_STRING);
|
268
243
|
|
269
|
-
|
270
|
-
|
244
|
+
Data_Get_Struct(self, cmark_node, node);
|
245
|
+
text = StringValueCStr(s);
|
271
246
|
|
272
|
-
|
273
|
-
|
274
|
-
|
247
|
+
if (!cmark_node_set_literal(node, text)) {
|
248
|
+
rb_raise(rb_mNodeError, "could not set string content");
|
249
|
+
}
|
275
250
|
|
276
|
-
|
251
|
+
return Qnil;
|
277
252
|
}
|
278
253
|
|
279
254
|
/*
|
@@ -281,78 +256,76 @@ rb_node_set_string_content(VALUE self, VALUE s)
|
|
281
256
|
*
|
282
257
|
* Returns a {Symbol} representing the node's type.
|
283
258
|
*/
|
284
|
-
static VALUE
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
return symbol;
|
259
|
+
static VALUE rb_node_get_type(VALUE self) {
|
260
|
+
int node_type;
|
261
|
+
cmark_node *node;
|
262
|
+
VALUE symbol;
|
263
|
+
|
264
|
+
Data_Get_Struct(self, cmark_node, node);
|
265
|
+
|
266
|
+
node_type = cmark_node_get_type(node);
|
267
|
+
symbol = Qnil;
|
268
|
+
|
269
|
+
switch (node_type) {
|
270
|
+
case CMARK_NODE_DOCUMENT:
|
271
|
+
symbol = sym_document;
|
272
|
+
break;
|
273
|
+
case CMARK_NODE_BLOCK_QUOTE:
|
274
|
+
symbol = sym_blockquote;
|
275
|
+
break;
|
276
|
+
case CMARK_NODE_LIST:
|
277
|
+
symbol = sym_list;
|
278
|
+
break;
|
279
|
+
case CMARK_NODE_ITEM:
|
280
|
+
symbol = sym_list_item;
|
281
|
+
break;
|
282
|
+
case CMARK_NODE_CODE_BLOCK:
|
283
|
+
symbol = sym_code_block;
|
284
|
+
break;
|
285
|
+
case CMARK_NODE_HTML:
|
286
|
+
symbol = sym_html;
|
287
|
+
break;
|
288
|
+
case CMARK_NODE_PARAGRAPH:
|
289
|
+
symbol = sym_paragraph;
|
290
|
+
break;
|
291
|
+
case CMARK_NODE_HEADER:
|
292
|
+
symbol = sym_header;
|
293
|
+
break;
|
294
|
+
case CMARK_NODE_HRULE:
|
295
|
+
symbol = sym_hrule;
|
296
|
+
break;
|
297
|
+
case CMARK_NODE_TEXT:
|
298
|
+
symbol = sym_text;
|
299
|
+
break;
|
300
|
+
case CMARK_NODE_SOFTBREAK:
|
301
|
+
symbol = sym_softbreak;
|
302
|
+
break;
|
303
|
+
case CMARK_NODE_LINEBREAK:
|
304
|
+
symbol = sym_linebreak;
|
305
|
+
break;
|
306
|
+
case CMARK_NODE_CODE:
|
307
|
+
symbol = sym_code;
|
308
|
+
break;
|
309
|
+
case CMARK_NODE_INLINE_HTML:
|
310
|
+
symbol = sym_inline_html;
|
311
|
+
break;
|
312
|
+
case CMARK_NODE_EMPH:
|
313
|
+
symbol = sym_emph;
|
314
|
+
break;
|
315
|
+
case CMARK_NODE_STRONG:
|
316
|
+
symbol = sym_strong;
|
317
|
+
break;
|
318
|
+
case CMARK_NODE_LINK:
|
319
|
+
symbol = sym_link;
|
320
|
+
break;
|
321
|
+
case CMARK_NODE_IMAGE:
|
322
|
+
symbol = sym_image;
|
323
|
+
break;
|
324
|
+
default:
|
325
|
+
rb_raise(rb_mNodeError, "invalid node type %d", node_type);
|
326
|
+
}
|
327
|
+
|
328
|
+
return symbol;
|
356
329
|
}
|
357
330
|
|
358
331
|
/*
|
@@ -360,27 +333,25 @@ rb_node_get_type(VALUE self)
|
|
360
333
|
*
|
361
334
|
* Returns a {Hash} containing {Symbol} keys of the positions.
|
362
335
|
*/
|
363
|
-
static VALUE
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
return result;
|
336
|
+
static VALUE rb_node_get_sourcepos(VALUE self) {
|
337
|
+
int start_line, start_column, end_line, end_column;
|
338
|
+
VALUE result;
|
339
|
+
|
340
|
+
cmark_node *node;
|
341
|
+
Data_Get_Struct(self, cmark_node, node);
|
342
|
+
|
343
|
+
start_line = cmark_node_get_start_line(node);
|
344
|
+
start_column = cmark_node_get_start_column(node);
|
345
|
+
end_line = cmark_node_get_end_line(node);
|
346
|
+
end_column = cmark_node_get_end_column(node);
|
347
|
+
|
348
|
+
result = rb_hash_new();
|
349
|
+
rb_hash_aset(result, CSTR2SYM("start_line"), INT2NUM(start_line));
|
350
|
+
rb_hash_aset(result, CSTR2SYM("start_column"), INT2NUM(start_column));
|
351
|
+
rb_hash_aset(result, CSTR2SYM("end_line"), INT2NUM(end_line));
|
352
|
+
rb_hash_aset(result, CSTR2SYM("end_column"), INT2NUM(end_column));
|
353
|
+
|
354
|
+
return result;
|
384
355
|
}
|
385
356
|
|
386
357
|
/*
|
@@ -388,60 +359,52 @@ rb_node_get_sourcepos(VALUE self)
|
|
388
359
|
*
|
389
360
|
* Returns a {String}.
|
390
361
|
*/
|
391
|
-
static VALUE
|
392
|
-
|
393
|
-
|
394
|
-
cmark_node *node;
|
395
|
-
Data_Get_Struct(self, cmark_node, node);
|
362
|
+
static VALUE rb_node_get_type_string(VALUE self) {
|
363
|
+
cmark_node *node;
|
364
|
+
Data_Get_Struct(self, cmark_node, node);
|
396
365
|
|
397
|
-
|
366
|
+
return rb_str_new2(cmark_node_get_type_string(node));
|
398
367
|
}
|
399
368
|
|
400
369
|
/*
|
401
370
|
* Internal: Unlinks the node from the tree (fixing pointers in
|
402
371
|
* parents and siblings appropriately).
|
403
372
|
*/
|
404
|
-
static VALUE
|
405
|
-
|
406
|
-
|
407
|
-
cmark_node *node;
|
408
|
-
Data_Get_Struct(self, cmark_node, node);
|
373
|
+
static VALUE rb_node_unlink(VALUE self) {
|
374
|
+
cmark_node *node;
|
375
|
+
Data_Get_Struct(self, cmark_node, node);
|
409
376
|
|
410
|
-
|
377
|
+
cmark_node_unlink(node);
|
411
378
|
|
412
|
-
|
379
|
+
rb_parent_removed(self);
|
413
380
|
|
414
|
-
|
381
|
+
return Qnil;
|
415
382
|
}
|
416
383
|
|
417
384
|
/* Public: Fetches the first child of the node.
|
418
385
|
*
|
419
386
|
* Returns a {Node} if a child exists, `nil` otherise.
|
420
387
|
*/
|
421
|
-
static VALUE
|
422
|
-
|
423
|
-
|
424
|
-
cmark_node *node, *child;
|
425
|
-
Data_Get_Struct(self, cmark_node, node);
|
388
|
+
static VALUE rb_node_first_child(VALUE self) {
|
389
|
+
cmark_node *node, *child;
|
390
|
+
Data_Get_Struct(self, cmark_node, node);
|
426
391
|
|
427
|
-
|
392
|
+
child = cmark_node_first_child(node);
|
428
393
|
|
429
|
-
|
394
|
+
return rb_node_to_value(child);
|
430
395
|
}
|
431
396
|
|
432
397
|
/* Public: Fetches the next sibling of the node.
|
433
398
|
*
|
434
399
|
* Returns a {Node} if a sibling exists, `nil` otherwise.
|
435
400
|
*/
|
436
|
-
static VALUE
|
437
|
-
|
438
|
-
|
439
|
-
cmark_node *node, *next;
|
440
|
-
Data_Get_Struct(self, cmark_node, node);
|
401
|
+
static VALUE rb_node_next(VALUE self) {
|
402
|
+
cmark_node *node, *next;
|
403
|
+
Data_Get_Struct(self, cmark_node, node);
|
441
404
|
|
442
|
-
|
405
|
+
next = cmark_node_next(node);
|
443
406
|
|
444
|
-
|
407
|
+
return rb_node_to_value(next);
|
445
408
|
}
|
446
409
|
|
447
410
|
/*
|
@@ -452,39 +415,35 @@ rb_node_next(VALUE self)
|
|
452
415
|
* Returns `true` if successful.
|
453
416
|
* Raises NodeError if the node can't be inserted.
|
454
417
|
*/
|
455
|
-
static VALUE
|
456
|
-
|
457
|
-
|
458
|
-
cmark_node *node1, *node2;
|
459
|
-
Data_Get_Struct(self, cmark_node, node1);
|
418
|
+
static VALUE rb_node_insert_before(VALUE self, VALUE sibling) {
|
419
|
+
cmark_node *node1, *node2;
|
420
|
+
Data_Get_Struct(self, cmark_node, node1);
|
460
421
|
|
461
|
-
|
422
|
+
Data_Get_Struct(sibling, cmark_node, node2);
|
462
423
|
|
463
|
-
|
464
|
-
|
465
|
-
|
424
|
+
if (!cmark_node_insert_before(node1, node2)) {
|
425
|
+
rb_raise(rb_mNodeError, "could not insert before");
|
426
|
+
}
|
466
427
|
|
467
|
-
|
428
|
+
rb_parent_added(sibling);
|
468
429
|
|
469
|
-
|
430
|
+
return Qtrue;
|
470
431
|
}
|
471
432
|
|
472
433
|
/* Internal: Convert the node to an HTML string.
|
473
434
|
*
|
474
435
|
* Returns a {String}.
|
475
436
|
*/
|
476
|
-
static VALUE
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
cmark_node *node;
|
481
|
-
Check_Type(rb_options, T_FIXNUM);
|
437
|
+
static VALUE rb_render_html(VALUE n, VALUE rb_options) {
|
438
|
+
int options;
|
439
|
+
cmark_node *node;
|
440
|
+
Check_Type(rb_options, T_FIXNUM);
|
482
441
|
|
483
|
-
|
442
|
+
options = FIX2INT(rb_options);
|
484
443
|
|
485
|
-
|
444
|
+
Data_Get_Struct(n, cmark_node, node);
|
486
445
|
|
487
|
-
|
446
|
+
return rb_str_new2(cmark_render_html(node, options));
|
488
447
|
}
|
489
448
|
|
490
449
|
/*
|
@@ -495,21 +454,19 @@ rb_render_html(VALUE n, VALUE rb_options)
|
|
495
454
|
* Returns `true` if successful.
|
496
455
|
* Raises NodeError if the node can't be inserted.
|
497
456
|
*/
|
498
|
-
static VALUE
|
499
|
-
|
500
|
-
|
501
|
-
cmark_node *node1, *node2;
|
502
|
-
Data_Get_Struct(self, cmark_node, node1);
|
457
|
+
static VALUE rb_node_insert_after(VALUE self, VALUE sibling) {
|
458
|
+
cmark_node *node1, *node2;
|
459
|
+
Data_Get_Struct(self, cmark_node, node1);
|
503
460
|
|
504
|
-
|
461
|
+
Data_Get_Struct(sibling, cmark_node, node2);
|
505
462
|
|
506
|
-
|
507
|
-
|
508
|
-
|
463
|
+
if (!cmark_node_insert_after(node1, node2)) {
|
464
|
+
rb_raise(rb_mNodeError, "could not insert after");
|
465
|
+
}
|
509
466
|
|
510
|
-
|
467
|
+
rb_parent_added(sibling);
|
511
468
|
|
512
|
-
|
469
|
+
return Qtrue;
|
513
470
|
}
|
514
471
|
|
515
472
|
/*
|
@@ -520,21 +477,19 @@ rb_node_insert_after(VALUE self, VALUE sibling)
|
|
520
477
|
* Returns `true` if successful.
|
521
478
|
* Raises NodeError if the node can't be inserted.
|
522
479
|
*/
|
523
|
-
static VALUE
|
524
|
-
|
525
|
-
|
526
|
-
cmark_node *node1, *node2;
|
527
|
-
Data_Get_Struct(self, cmark_node, node1);
|
480
|
+
static VALUE rb_node_prepend_child(VALUE self, VALUE child) {
|
481
|
+
cmark_node *node1, *node2;
|
482
|
+
Data_Get_Struct(self, cmark_node, node1);
|
528
483
|
|
529
|
-
|
484
|
+
Data_Get_Struct(child, cmark_node, node2);
|
530
485
|
|
531
|
-
|
532
|
-
|
533
|
-
|
486
|
+
if (!cmark_node_prepend_child(node1, node2)) {
|
487
|
+
rb_raise(rb_mNodeError, "could not prepend child");
|
488
|
+
}
|
534
489
|
|
535
|
-
|
490
|
+
rb_parent_added(child);
|
536
491
|
|
537
|
-
|
492
|
+
return Qtrue;
|
538
493
|
}
|
539
494
|
|
540
495
|
/*
|
@@ -545,66 +500,58 @@ rb_node_prepend_child(VALUE self, VALUE child)
|
|
545
500
|
* Returns `true` if successful.
|
546
501
|
* Raises NodeError if the node can't be inserted.
|
547
502
|
*/
|
548
|
-
static VALUE
|
549
|
-
|
550
|
-
|
551
|
-
cmark_node *node1, *node2;
|
552
|
-
Data_Get_Struct(self, cmark_node, node1);
|
503
|
+
static VALUE rb_node_append_child(VALUE self, VALUE child) {
|
504
|
+
cmark_node *node1, *node2;
|
505
|
+
Data_Get_Struct(self, cmark_node, node1);
|
553
506
|
|
554
|
-
|
507
|
+
Data_Get_Struct(child, cmark_node, node2);
|
555
508
|
|
556
|
-
|
557
|
-
|
558
|
-
|
509
|
+
if (!cmark_node_append_child(node1, node2)) {
|
510
|
+
rb_raise(rb_mNodeError, "could not append child");
|
511
|
+
}
|
559
512
|
|
560
|
-
|
513
|
+
rb_parent_added(child);
|
561
514
|
|
562
|
-
|
515
|
+
return Qtrue;
|
563
516
|
}
|
564
517
|
|
565
518
|
/* Public: Fetches the first child of the current node.
|
566
519
|
*
|
567
520
|
* Returns a {Node} if a child exists, `nil` otherise.
|
568
521
|
*/
|
569
|
-
static VALUE
|
570
|
-
|
571
|
-
|
572
|
-
cmark_node *node, *child;
|
573
|
-
Data_Get_Struct(self, cmark_node, node);
|
522
|
+
static VALUE rb_node_last_child(VALUE self) {
|
523
|
+
cmark_node *node, *child;
|
524
|
+
Data_Get_Struct(self, cmark_node, node);
|
574
525
|
|
575
|
-
|
526
|
+
child = cmark_node_last_child(node);
|
576
527
|
|
577
|
-
|
528
|
+
return rb_node_to_value(child);
|
578
529
|
}
|
579
530
|
|
580
531
|
/* Public: Fetches the parent of the current node.
|
581
532
|
*
|
582
533
|
* Returns a {Node} if a parent exists, `nil` otherise.
|
583
534
|
*/
|
584
|
-
static VALUE
|
585
|
-
|
586
|
-
|
587
|
-
cmark_node *node, *parent;
|
588
|
-
Data_Get_Struct(self, cmark_node, node);
|
535
|
+
static VALUE rb_node_parent(VALUE self) {
|
536
|
+
cmark_node *node, *parent;
|
537
|
+
Data_Get_Struct(self, cmark_node, node);
|
589
538
|
|
590
|
-
|
539
|
+
parent = cmark_node_parent(node);
|
591
540
|
|
592
|
-
|
541
|
+
return rb_node_to_value(parent);
|
593
542
|
}
|
594
543
|
|
595
544
|
/* Public: Fetches the previous sibling of the current node.
|
596
545
|
*
|
597
546
|
* Returns a {Node} if a parent exists, `nil` otherise.
|
598
547
|
*/
|
599
|
-
static VALUE
|
600
|
-
|
601
|
-
|
602
|
-
cmark_node *node, *previous;
|
603
|
-
Data_Get_Struct(self, cmark_node, node);
|
548
|
+
static VALUE rb_node_previous(VALUE self) {
|
549
|
+
cmark_node *node, *previous;
|
550
|
+
Data_Get_Struct(self, cmark_node, node);
|
604
551
|
|
605
|
-
|
552
|
+
previous = cmark_node_previous(node);
|
606
553
|
|
607
|
-
|
554
|
+
return rb_node_to_value(previous);
|
608
555
|
}
|
609
556
|
|
610
557
|
/*
|
@@ -613,19 +560,17 @@ rb_node_previous(VALUE self)
|
|
613
560
|
* Returns a {String}.
|
614
561
|
* Raises a NodeError if the URL can't be retrieved.
|
615
562
|
*/
|
616
|
-
static VALUE
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
-
|
622
|
-
|
623
|
-
|
624
|
-
|
625
|
-
|
626
|
-
|
627
|
-
|
628
|
-
return rb_str_new2(text);
|
563
|
+
static VALUE rb_node_get_url(VALUE self) {
|
564
|
+
const char *text;
|
565
|
+
cmark_node *node;
|
566
|
+
Data_Get_Struct(self, cmark_node, node);
|
567
|
+
|
568
|
+
text = cmark_node_get_url(node);
|
569
|
+
if (text == NULL) {
|
570
|
+
rb_raise(rb_mNodeError, "could not get url");
|
571
|
+
}
|
572
|
+
|
573
|
+
return rb_str_new2(text);
|
629
574
|
}
|
630
575
|
|
631
576
|
/*
|
@@ -635,21 +580,19 @@ rb_node_get_url(VALUE self)
|
|
635
580
|
*
|
636
581
|
* Raises a NodeError if the URL can't be set.
|
637
582
|
*/
|
638
|
-
static VALUE
|
639
|
-
|
640
|
-
|
641
|
-
|
642
|
-
char *text;
|
643
|
-
Check_Type(url, T_STRING);
|
583
|
+
static VALUE rb_node_set_url(VALUE self, VALUE url) {
|
584
|
+
cmark_node *node;
|
585
|
+
char *text;
|
586
|
+
Check_Type(url, T_STRING);
|
644
587
|
|
645
|
-
|
646
|
-
|
588
|
+
Data_Get_Struct(self, cmark_node, node);
|
589
|
+
text = StringValueCStr(url);
|
647
590
|
|
648
|
-
|
649
|
-
|
650
|
-
|
591
|
+
if (!cmark_node_set_url(node, text)) {
|
592
|
+
rb_raise(rb_mNodeError, "could not set url");
|
593
|
+
}
|
651
594
|
|
652
|
-
|
595
|
+
return Qnil;
|
653
596
|
}
|
654
597
|
|
655
598
|
/*
|
@@ -658,19 +601,17 @@ rb_node_set_url(VALUE self, VALUE url)
|
|
658
601
|
* Returns a {String}.
|
659
602
|
* Raises a NodeError if the title can't be retrieved.
|
660
603
|
*/
|
661
|
-
static VALUE
|
662
|
-
|
663
|
-
|
664
|
-
|
665
|
-
|
666
|
-
|
667
|
-
|
668
|
-
|
669
|
-
|
670
|
-
|
671
|
-
|
672
|
-
|
673
|
-
return rb_str_new2(text);
|
604
|
+
static VALUE rb_node_get_title(VALUE self) {
|
605
|
+
const char *text;
|
606
|
+
cmark_node *node;
|
607
|
+
Data_Get_Struct(self, cmark_node, node);
|
608
|
+
|
609
|
+
text = cmark_node_get_title(node);
|
610
|
+
if (text == NULL) {
|
611
|
+
rb_raise(rb_mNodeError, "could not get title");
|
612
|
+
}
|
613
|
+
|
614
|
+
return rb_str_new2(text);
|
674
615
|
}
|
675
616
|
|
676
617
|
/*
|
@@ -680,21 +621,19 @@ rb_node_get_title(VALUE self)
|
|
680
621
|
*
|
681
622
|
* Raises a NodeError if the title can't be set.
|
682
623
|
*/
|
683
|
-
static VALUE
|
684
|
-
|
685
|
-
|
686
|
-
|
687
|
-
cmark_node *node;
|
688
|
-
Check_Type(title, T_STRING);
|
624
|
+
static VALUE rb_node_set_title(VALUE self, VALUE title) {
|
625
|
+
char *text;
|
626
|
+
cmark_node *node;
|
627
|
+
Check_Type(title, T_STRING);
|
689
628
|
|
690
|
-
|
691
|
-
|
629
|
+
Data_Get_Struct(self, cmark_node, node);
|
630
|
+
text = StringValueCStr(title);
|
692
631
|
|
693
|
-
|
694
|
-
|
695
|
-
|
632
|
+
if (!cmark_node_set_title(node, text)) {
|
633
|
+
rb_raise(rb_mNodeError, "could not set title");
|
634
|
+
}
|
696
635
|
|
697
|
-
|
636
|
+
return Qnil;
|
698
637
|
}
|
699
638
|
|
700
639
|
/*
|
@@ -703,20 +642,18 @@ rb_node_set_title(VALUE self, VALUE title)
|
|
703
642
|
* Returns a {Number} representing the header level.
|
704
643
|
* Raises a NodeError if the header level can't be retrieved.
|
705
644
|
*/
|
706
|
-
static VALUE
|
707
|
-
|
708
|
-
|
709
|
-
|
710
|
-
cmark_node *node;
|
711
|
-
Data_Get_Struct(self, cmark_node, node);
|
645
|
+
static VALUE rb_node_get_header_level(VALUE self) {
|
646
|
+
int header_level;
|
647
|
+
cmark_node *node;
|
648
|
+
Data_Get_Struct(self, cmark_node, node);
|
712
649
|
|
713
|
-
|
650
|
+
header_level = cmark_node_get_header_level(node);
|
714
651
|
|
715
|
-
|
716
|
-
|
717
|
-
|
652
|
+
if (header_level == 0) {
|
653
|
+
rb_raise(rb_mNodeError, "could not get header_level");
|
654
|
+
}
|
718
655
|
|
719
|
-
|
656
|
+
return INT2NUM(header_level);
|
720
657
|
}
|
721
658
|
|
722
659
|
/*
|
@@ -726,21 +663,19 @@ rb_node_get_header_level(VALUE self)
|
|
726
663
|
*
|
727
664
|
* Raises a NodeError if the header level can't be set.
|
728
665
|
*/
|
729
|
-
static VALUE
|
730
|
-
|
731
|
-
|
732
|
-
|
733
|
-
cmark_node *node;
|
734
|
-
Check_Type(level, T_FIXNUM);
|
666
|
+
static VALUE rb_node_set_header_level(VALUE self, VALUE level) {
|
667
|
+
int l;
|
668
|
+
cmark_node *node;
|
669
|
+
Check_Type(level, T_FIXNUM);
|
735
670
|
|
736
|
-
|
737
|
-
|
671
|
+
Data_Get_Struct(self, cmark_node, node);
|
672
|
+
l = FIX2INT(level);
|
738
673
|
|
739
|
-
|
740
|
-
|
741
|
-
|
674
|
+
if (!cmark_node_set_header_level(node, l)) {
|
675
|
+
rb_raise(rb_mNodeError, "could not set header_level");
|
676
|
+
}
|
742
677
|
|
743
|
-
|
678
|
+
return Qnil;
|
744
679
|
}
|
745
680
|
|
746
681
|
/*
|
@@ -749,25 +684,23 @@ rb_node_set_header_level(VALUE self, VALUE level)
|
|
749
684
|
* Returns a {Symbol}.
|
750
685
|
* Raises a NodeError if the title can't be retrieved.
|
751
686
|
*/
|
752
|
-
static VALUE
|
753
|
-
|
754
|
-
|
755
|
-
|
756
|
-
|
757
|
-
|
758
|
-
|
759
|
-
|
760
|
-
|
761
|
-
|
762
|
-
|
763
|
-
|
764
|
-
|
765
|
-
|
766
|
-
|
767
|
-
|
768
|
-
|
769
|
-
|
770
|
-
return symbol;
|
687
|
+
static VALUE rb_node_get_list_type(VALUE self) {
|
688
|
+
int list_type;
|
689
|
+
cmark_node *node;
|
690
|
+
VALUE symbol;
|
691
|
+
Data_Get_Struct(self, cmark_node, node);
|
692
|
+
|
693
|
+
list_type = cmark_node_get_list_type(node);
|
694
|
+
|
695
|
+
if (list_type == CMARK_BULLET_LIST) {
|
696
|
+
symbol = sym_bullet_list;
|
697
|
+
} else if (list_type == CMARK_ORDERED_LIST) {
|
698
|
+
symbol = sym_ordered_list;
|
699
|
+
} else {
|
700
|
+
rb_raise(rb_mNodeError, "could not get list_type");
|
701
|
+
}
|
702
|
+
|
703
|
+
return symbol;
|
771
704
|
}
|
772
705
|
|
773
706
|
/*
|
@@ -777,74 +710,69 @@ rb_node_get_list_type(VALUE self)
|
|
777
710
|
*
|
778
711
|
* Raises a NodeError if the list type can't be set.
|
779
712
|
*/
|
780
|
-
static VALUE
|
781
|
-
|
782
|
-
|
783
|
-
|
784
|
-
|
785
|
-
|
786
|
-
|
787
|
-
|
788
|
-
|
789
|
-
|
790
|
-
|
791
|
-
|
792
|
-
|
793
|
-
|
794
|
-
|
795
|
-
|
796
|
-
|
797
|
-
|
798
|
-
|
799
|
-
|
800
|
-
|
801
|
-
return Qnil;
|
713
|
+
static VALUE rb_node_set_list_type(VALUE self, VALUE list_type) {
|
714
|
+
int type = 0;
|
715
|
+
cmark_node *node;
|
716
|
+
Check_Type(list_type, T_SYMBOL);
|
717
|
+
|
718
|
+
Data_Get_Struct(self, cmark_node, node);
|
719
|
+
|
720
|
+
if (list_type == sym_bullet_list) {
|
721
|
+
type = CMARK_BULLET_LIST;
|
722
|
+
} else if (list_type == sym_ordered_list) {
|
723
|
+
type = CMARK_ORDERED_LIST;
|
724
|
+
} else {
|
725
|
+
rb_raise(rb_mNodeError, "invalid list_type");
|
726
|
+
}
|
727
|
+
|
728
|
+
if (!cmark_node_set_list_type(node, type)) {
|
729
|
+
rb_raise(rb_mNodeError, "could not set list_type");
|
730
|
+
}
|
731
|
+
|
732
|
+
return Qnil;
|
802
733
|
}
|
803
734
|
|
804
735
|
/*
|
805
|
-
* Public: Gets the starting number the current node (must be an
|
736
|
+
* Public: Gets the starting number the current node (must be an
|
737
|
+
* `:ordered_list`).
|
806
738
|
*
|
807
739
|
* Returns a {Number} representing the starting number.
|
808
740
|
* Raises a NodeError if the starting number can't be retrieved.
|
809
741
|
*/
|
810
|
-
static VALUE
|
811
|
-
|
812
|
-
|
813
|
-
|
814
|
-
|
815
|
-
|
816
|
-
|
817
|
-
|
818
|
-
|
819
|
-
|
820
|
-
|
821
|
-
}
|
822
|
-
|
823
|
-
return INT2NUM(cmark_node_get_list_start(node));
|
742
|
+
static VALUE rb_node_get_list_start(VALUE self) {
|
743
|
+
cmark_node *node;
|
744
|
+
Data_Get_Struct(self, cmark_node, node);
|
745
|
+
|
746
|
+
if (cmark_node_get_type(node) != CMARK_NODE_LIST ||
|
747
|
+
cmark_node_get_list_type(node) != CMARK_ORDERED_LIST) {
|
748
|
+
rb_raise(rb_mNodeError, "can't get list_start for non-ordered list %d",
|
749
|
+
cmark_node_get_list_type(node));
|
750
|
+
}
|
751
|
+
|
752
|
+
return INT2NUM(cmark_node_get_list_start(node));
|
824
753
|
}
|
825
754
|
|
826
755
|
/*
|
827
|
-
* Public: Sets the starting number of the current node (must be an
|
756
|
+
* Public: Sets the starting number of the current node (must be an
|
757
|
+
* `:ordered_list`).
|
828
758
|
*
|
829
759
|
* level - A {Number} representing the new starting number
|
830
760
|
*
|
831
761
|
* Raises a NodeError if the starting number can't be set.
|
832
762
|
*/
|
833
|
-
static VALUE
|
834
|
-
|
835
|
-
|
836
|
-
|
837
|
-
cmark_node *node;
|
838
|
-
Check_Type(start, T_FIXNUM);
|
763
|
+
static VALUE rb_node_set_list_start(VALUE self, VALUE start) {
|
764
|
+
int s;
|
765
|
+
cmark_node *node;
|
766
|
+
Check_Type(start, T_FIXNUM);
|
839
767
|
|
840
|
-
|
841
|
-
|
768
|
+
Data_Get_Struct(self, cmark_node, node);
|
769
|
+
s = FIX2INT(start);
|
842
770
|
|
843
|
-
|
844
|
-
|
845
|
-
|
771
|
+
if (!cmark_node_set_list_start(node, s)) {
|
772
|
+
rb_raise(rb_mNodeError, "could not set list_start");
|
773
|
+
}
|
846
774
|
|
847
|
-
|
775
|
+
return Qnil;
|
848
776
|
}
|
849
777
|
|
850
778
|
/*
|
@@ -853,21 +781,18 @@ rb_node_set_list_start(VALUE self, VALUE start)
|
|
853
781
|
* Returns a `true` if the list is tight, `false` otherwise.
|
854
782
|
* Raises a NodeError if the starting number can't be retrieved.
|
855
783
|
*/
|
856
|
-
static VALUE
|
857
|
-
|
858
|
-
|
859
|
-
|
860
|
-
cmark_node *node;
|
861
|
-
Data_Get_Struct(self, cmark_node, node);
|
784
|
+
static VALUE rb_node_get_list_tight(VALUE self) {
|
785
|
+
int flag;
|
786
|
+
cmark_node *node;
|
787
|
+
Data_Get_Struct(self, cmark_node, node);
|
862
788
|
|
863
|
-
|
864
|
-
|
865
|
-
|
866
|
-
}
|
789
|
+
if (cmark_node_get_type(node) != CMARK_NODE_LIST) {
|
790
|
+
rb_raise(rb_mNodeError, "can't get list_tight for non-list");
|
791
|
+
}
|
867
792
|
|
868
|
-
|
793
|
+
flag = cmark_node_get_list_tight(node);
|
869
794
|
|
870
|
-
|
795
|
+
return flag ? Qtrue : Qfalse;
|
871
796
|
}
|
872
797
|
|
873
798
|
/*
|
@@ -877,19 +802,17 @@ rb_node_get_list_tight(VALUE self)
|
|
877
802
|
*
|
878
803
|
* Raises a NodeError if the tightness can't be set.
|
879
804
|
*/
|
880
|
-
static VALUE
|
881
|
-
|
882
|
-
|
883
|
-
|
884
|
-
|
885
|
-
|
886
|
-
|
887
|
-
|
888
|
-
|
889
|
-
|
890
|
-
|
891
|
-
|
892
|
-
return Qnil;
|
805
|
+
static VALUE rb_node_set_list_tight(VALUE self, VALUE tight) {
|
806
|
+
int t;
|
807
|
+
cmark_node *node;
|
808
|
+
Data_Get_Struct(self, cmark_node, node);
|
809
|
+
t = RTEST(tight);
|
810
|
+
|
811
|
+
if (!cmark_node_set_list_tight(node, t)) {
|
812
|
+
rb_raise(rb_mNodeError, "could not set list_tight");
|
813
|
+
}
|
814
|
+
|
815
|
+
return Qnil;
|
893
816
|
}
|
894
817
|
|
895
818
|
/*
|
@@ -898,20 +821,18 @@ rb_node_set_list_tight(VALUE self, VALUE tight)
|
|
898
821
|
* Returns a {String} representing the fence info.
|
899
822
|
* Raises a NodeError if the fence info can't be retrieved.
|
900
823
|
*/
|
901
|
-
static VALUE
|
902
|
-
|
903
|
-
|
904
|
-
|
905
|
-
cmark_node *node;
|
906
|
-
Data_Get_Struct(self, cmark_node, node);
|
824
|
+
static VALUE rb_node_get_fence_info(VALUE self) {
|
825
|
+
const char *fence_info;
|
826
|
+
cmark_node *node;
|
827
|
+
Data_Get_Struct(self, cmark_node, node);
|
907
828
|
|
908
|
-
|
829
|
+
fence_info = cmark_node_get_fence_info(node);
|
909
830
|
|
910
|
-
|
911
|
-
|
912
|
-
|
831
|
+
if (fence_info == NULL) {
|
832
|
+
rb_raise(rb_mNodeError, "could not get fence_info");
|
833
|
+
}
|
913
834
|
|
914
|
-
|
835
|
+
return rb_str_new2(fence_info);
|
915
836
|
}
|
916
837
|
|
917
838
|
/*
|
@@ -921,121 +842,117 @@ rb_node_get_fence_info(VALUE self)
|
|
921
842
|
*
|
922
843
|
* Raises a NodeError if the fence info can't be set.
|
923
844
|
*/
|
924
|
-
static VALUE
|
925
|
-
|
926
|
-
|
927
|
-
|
928
|
-
cmark_node *node;
|
929
|
-
Check_Type(info, T_STRING);
|
845
|
+
static VALUE rb_node_set_fence_info(VALUE self, VALUE info) {
|
846
|
+
char *text;
|
847
|
+
cmark_node *node;
|
848
|
+
Check_Type(info, T_STRING);
|
930
849
|
|
931
|
-
|
932
|
-
|
850
|
+
Data_Get_Struct(self, cmark_node, node);
|
851
|
+
text = StringValueCStr(info);
|
933
852
|
|
934
|
-
|
935
|
-
|
936
|
-
|
853
|
+
if (!cmark_node_set_fence_info(node, text)) {
|
854
|
+
rb_raise(rb_mNodeError, "could not set fence_info");
|
855
|
+
}
|
937
856
|
|
938
|
-
|
857
|
+
return Qnil;
|
939
858
|
}
|
940
859
|
|
941
860
|
/* Internal: Escapes href URLs safely. */
|
942
|
-
static VALUE
|
943
|
-
|
944
|
-
|
945
|
-
char *result;
|
946
|
-
cmark_strbuf buf = GH_BUF_INIT;
|
861
|
+
static VALUE rb_html_escape_href(VALUE self, VALUE rb_text) {
|
862
|
+
char *result;
|
863
|
+
cmark_strbuf buf = GH_BUF_INIT;
|
947
864
|
|
948
|
-
|
865
|
+
Check_Type(rb_text, T_STRING);
|
949
866
|
|
950
|
-
|
951
|
-
|
952
|
-
|
953
|
-
|
954
|
-
|
955
|
-
return rb_text;
|
867
|
+
if (houdini_escape_href(&buf, (const uint8_t *)RSTRING_PTR(rb_text),
|
868
|
+
RSTRING_LEN(rb_text))) {
|
869
|
+
result = (char *)cmark_strbuf_detach(&buf);
|
870
|
+
return rb_str_new2(result);
|
871
|
+
}
|
956
872
|
|
873
|
+
return rb_text;
|
957
874
|
}
|
958
875
|
|
959
876
|
/* Internal: Escapes HTML content safely. */
|
960
|
-
static VALUE
|
961
|
-
|
962
|
-
|
963
|
-
|
964
|
-
|
965
|
-
|
966
|
-
|
967
|
-
|
968
|
-
|
969
|
-
|
970
|
-
|
971
|
-
|
972
|
-
|
973
|
-
|
974
|
-
|
975
|
-
|
976
|
-
|
977
|
-
|
978
|
-
|
979
|
-
|
980
|
-
|
981
|
-
|
982
|
-
|
983
|
-
|
984
|
-
|
985
|
-
|
986
|
-
|
987
|
-
|
988
|
-
|
989
|
-
|
990
|
-
|
991
|
-
|
992
|
-
|
993
|
-
|
994
|
-
|
995
|
-
|
996
|
-
|
997
|
-
|
998
|
-
|
999
|
-
|
1000
|
-
|
1001
|
-
|
1002
|
-
|
1003
|
-
|
1004
|
-
|
1005
|
-
|
1006
|
-
|
1007
|
-
|
1008
|
-
|
1009
|
-
|
1010
|
-
|
1011
|
-
|
1012
|
-
|
1013
|
-
|
1014
|
-
|
1015
|
-
|
1016
|
-
|
1017
|
-
|
1018
|
-
|
1019
|
-
|
1020
|
-
|
1021
|
-
|
1022
|
-
|
1023
|
-
|
1024
|
-
|
1025
|
-
|
1026
|
-
|
1027
|
-
|
1028
|
-
|
1029
|
-
|
1030
|
-
|
1031
|
-
|
1032
|
-
|
1033
|
-
|
1034
|
-
|
1035
|
-
|
1036
|
-
|
1037
|
-
|
1038
|
-
|
1039
|
-
|
1040
|
-
|
877
|
+
static VALUE rb_html_escape_html(VALUE self, VALUE rb_text) {
|
878
|
+
char *result;
|
879
|
+
cmark_strbuf buf = GH_BUF_INIT;
|
880
|
+
|
881
|
+
Check_Type(rb_text, T_STRING);
|
882
|
+
|
883
|
+
if (houdini_escape_html0(&buf, (const uint8_t *)RSTRING_PTR(rb_text),
|
884
|
+
RSTRING_LEN(rb_text), 0)) {
|
885
|
+
result = (char *)cmark_strbuf_detach(&buf);
|
886
|
+
return rb_str_new2(result);
|
887
|
+
}
|
888
|
+
|
889
|
+
return rb_text;
|
890
|
+
}
|
891
|
+
|
892
|
+
__attribute__((visibility("default"))) void Init_commonmarker() {
|
893
|
+
VALUE module;
|
894
|
+
sym_document = ID2SYM(rb_intern("document"));
|
895
|
+
sym_blockquote = ID2SYM(rb_intern("blockquote"));
|
896
|
+
sym_list = ID2SYM(rb_intern("list"));
|
897
|
+
sym_list_item = ID2SYM(rb_intern("list_item"));
|
898
|
+
sym_code_block = ID2SYM(rb_intern("code_block"));
|
899
|
+
sym_html = ID2SYM(rb_intern("html"));
|
900
|
+
sym_paragraph = ID2SYM(rb_intern("paragraph"));
|
901
|
+
sym_header = ID2SYM(rb_intern("header"));
|
902
|
+
sym_hrule = ID2SYM(rb_intern("hrule"));
|
903
|
+
sym_text = ID2SYM(rb_intern("text"));
|
904
|
+
sym_softbreak = ID2SYM(rb_intern("softbreak"));
|
905
|
+
sym_linebreak = ID2SYM(rb_intern("linebreak"));
|
906
|
+
sym_code = ID2SYM(rb_intern("code"));
|
907
|
+
sym_inline_html = ID2SYM(rb_intern("inline_html"));
|
908
|
+
sym_emph = ID2SYM(rb_intern("emph"));
|
909
|
+
sym_strong = ID2SYM(rb_intern("strong"));
|
910
|
+
sym_link = ID2SYM(rb_intern("link"));
|
911
|
+
sym_image = ID2SYM(rb_intern("image"));
|
912
|
+
|
913
|
+
sym_bullet_list = ID2SYM(rb_intern("bullet_list"));
|
914
|
+
sym_ordered_list = ID2SYM(rb_intern("ordered_list"));
|
915
|
+
|
916
|
+
module = rb_define_module("CommonMarker");
|
917
|
+
rb_mNodeError = rb_define_class_under(module, "NodeError", rb_eStandardError);
|
918
|
+
rb_mNode = rb_define_class_under(module, "Node", rb_cObject);
|
919
|
+
rb_define_singleton_method(rb_mNode, "markdown_to_html", rb_markdown_to_html,
|
920
|
+
2);
|
921
|
+
rb_define_singleton_method(rb_mNode, "new", rb_node_new, 1);
|
922
|
+
rb_define_singleton_method(rb_mNode, "parse_document", rb_parse_document, 3);
|
923
|
+
rb_define_method(rb_mNode, "string_content", rb_node_get_string_content, 0);
|
924
|
+
rb_define_method(rb_mNode, "string_content=", rb_node_set_string_content, 1);
|
925
|
+
rb_define_method(rb_mNode, "type", rb_node_get_type, 0);
|
926
|
+
rb_define_method(rb_mNode, "type_string", rb_node_get_type_string, 0);
|
927
|
+
rb_define_method(rb_mNode, "sourcepos", rb_node_get_sourcepos, 0);
|
928
|
+
rb_define_method(rb_mNode, "delete", rb_node_unlink, 0);
|
929
|
+
rb_define_method(rb_mNode, "first_child", rb_node_first_child, 0);
|
930
|
+
rb_define_method(rb_mNode, "next", rb_node_next, 0);
|
931
|
+
rb_define_method(rb_mNode, "insert_before", rb_node_insert_before, 1);
|
932
|
+
rb_define_method(rb_mNode, "_render_html", rb_render_html, 1);
|
933
|
+
rb_define_method(rb_mNode, "insert_after", rb_node_insert_after, 1);
|
934
|
+
rb_define_method(rb_mNode, "prepend_child", rb_node_prepend_child, 1);
|
935
|
+
rb_define_method(rb_mNode, "append_child", rb_node_append_child, 1);
|
936
|
+
rb_define_method(rb_mNode, "last_child", rb_node_last_child, 0);
|
937
|
+
rb_define_method(rb_mNode, "parent", rb_node_parent, 0);
|
938
|
+
rb_define_method(rb_mNode, "previous", rb_node_previous, 0);
|
939
|
+
rb_define_method(rb_mNode, "url", rb_node_get_url, 0);
|
940
|
+
rb_define_method(rb_mNode, "url=", rb_node_set_url, 1);
|
941
|
+
rb_define_method(rb_mNode, "title", rb_node_get_title, 0);
|
942
|
+
rb_define_method(rb_mNode, "title=", rb_node_set_title, 1);
|
943
|
+
rb_define_method(rb_mNode, "header_level", rb_node_get_header_level, 0);
|
944
|
+
rb_define_method(rb_mNode, "header_level=", rb_node_set_header_level, 1);
|
945
|
+
rb_define_method(rb_mNode, "list_type", rb_node_get_list_type, 0);
|
946
|
+
rb_define_method(rb_mNode, "list_type=", rb_node_set_list_type, 1);
|
947
|
+
rb_define_method(rb_mNode, "list_start", rb_node_get_list_start, 0);
|
948
|
+
rb_define_method(rb_mNode, "list_start=", rb_node_set_list_start, 1);
|
949
|
+
rb_define_method(rb_mNode, "list_tight", rb_node_get_list_tight, 0);
|
950
|
+
rb_define_method(rb_mNode, "list_tight=", rb_node_set_list_tight, 1);
|
951
|
+
rb_define_method(rb_mNode, "fence_info", rb_node_get_fence_info, 0);
|
952
|
+
rb_define_method(rb_mNode, "fence_info=", rb_node_set_fence_info, 1);
|
953
|
+
|
954
|
+
rb_define_singleton_method(rb_mNode, "html_escape_href", rb_html_escape_href,
|
955
|
+
1);
|
956
|
+
rb_define_singleton_method(rb_mNode, "html_escape_html", rb_html_escape_html,
|
957
|
+
1);
|
1041
958
|
}
|