commonmarker 0.3.0 → 0.4.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.

Files changed (78) hide show
  1. checksums.yaml +4 -4
  2. data/ext/commonmarker/cmark/CMakeLists.txt +10 -4
  3. data/ext/commonmarker/cmark/Makefile +5 -5
  4. data/ext/commonmarker/cmark/api_test/CMakeLists.txt +1 -1
  5. data/ext/commonmarker/cmark/api_test/main.c +16 -0
  6. data/ext/commonmarker/cmark/build/CMakeCache.txt +3 -4
  7. data/ext/commonmarker/cmark/build/CMakeFiles/2.8.10.1/CMakeSystem.cmake +4 -4
  8. data/ext/commonmarker/cmark/build/CMakeFiles/CMakeError.log +12 -12
  9. data/ext/commonmarker/cmark/build/CMakeFiles/CMakeOutput.log +97 -142
  10. data/ext/commonmarker/cmark/build/CMakeFiles/Makefile.cmake +0 -1
  11. data/ext/commonmarker/cmark/build/api_test/CMakeFiles/api_test.dir/build.make +1 -1
  12. data/ext/commonmarker/cmark/build/api_test/CMakeFiles/api_test.dir/link.txt +1 -1
  13. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark.dir/DependInfo.cmake +1 -1
  14. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark.dir/build.make +23 -23
  15. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark.dir/cmake_clean.cmake +2 -2
  16. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark.dir/link.txt +1 -1
  17. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/blocks.c.o +0 -0
  18. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/buffer.c.o +0 -0
  19. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/cmark.c.o +0 -0
  20. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/commonmark.c.o +0 -0
  21. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/houdini_html_u.c.o +0 -0
  22. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/html.c.o +0 -0
  23. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/inlines.c.o +0 -0
  24. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/node.c.o +0 -0
  25. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/references.c.o +0 -0
  26. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/render.c.o +0 -0
  27. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/scanners.c.o +0 -0
  28. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/utf8.c.o +0 -0
  29. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/xml.c.o +0 -0
  30. data/ext/commonmarker/cmark/build/src/cmake_install.cmake +3 -3
  31. data/ext/commonmarker/cmark/build/src/cmark_version.h +2 -2
  32. data/ext/commonmarker/cmark/build/src/config.h +6 -6
  33. data/ext/commonmarker/cmark/build/src/libcmark.a +0 -0
  34. data/ext/commonmarker/cmark/build/src/libcmark.pc +1 -1
  35. data/ext/commonmarker/cmark/build/testdir/CTestTestfile.cmake +4 -4
  36. data/ext/commonmarker/cmark/changelog.txt +46 -0
  37. data/ext/commonmarker/cmark/man/man3/cmark.3 +21 -20
  38. data/ext/commonmarker/cmark/src/CMakeLists.txt +4 -6
  39. data/ext/commonmarker/cmark/src/bench.h +8 -8
  40. data/ext/commonmarker/cmark/src/blocks.c +917 -947
  41. data/ext/commonmarker/cmark/src/buffer.c +213 -288
  42. data/ext/commonmarker/cmark/src/buffer.h +19 -21
  43. data/ext/commonmarker/cmark/src/chunk.h +78 -82
  44. data/ext/commonmarker/cmark/src/cmark.c +9 -17
  45. data/ext/commonmarker/cmark/src/cmark.h +113 -157
  46. data/ext/commonmarker/cmark/src/cmark_ctype.c +24 -35
  47. data/ext/commonmarker/cmark/src/commonmark.c +390 -425
  48. data/ext/commonmarker/cmark/src/config.h.in +6 -6
  49. data/ext/commonmarker/cmark/src/houdini.h +21 -15
  50. data/ext/commonmarker/cmark/src/houdini_href_e.c +50 -57
  51. data/ext/commonmarker/cmark/src/houdini_html_e.c +36 -51
  52. data/ext/commonmarker/cmark/src/houdini_html_u.c +119 -124
  53. data/ext/commonmarker/cmark/src/html.c +289 -307
  54. data/ext/commonmarker/cmark/src/inlines.c +976 -1030
  55. data/ext/commonmarker/cmark/src/inlines.h +4 -2
  56. data/ext/commonmarker/cmark/src/iterator.c +96 -126
  57. data/ext/commonmarker/cmark/src/iterator.h +5 -5
  58. data/ext/commonmarker/cmark/src/latex.c +379 -401
  59. data/ext/commonmarker/cmark/src/main.c +168 -175
  60. data/ext/commonmarker/cmark/src/man.c +212 -226
  61. data/ext/commonmarker/cmark/src/node.c +746 -839
  62. data/ext/commonmarker/cmark/src/node.h +47 -48
  63. data/ext/commonmarker/cmark/src/parser.h +14 -14
  64. data/ext/commonmarker/cmark/src/references.c +101 -111
  65. data/ext/commonmarker/cmark/src/references.h +10 -8
  66. data/ext/commonmarker/cmark/src/render.c +144 -167
  67. data/ext/commonmarker/cmark/src/render.h +22 -41
  68. data/ext/commonmarker/cmark/src/scanners.c +27695 -20903
  69. data/ext/commonmarker/cmark/src/scanners.h +2 -1
  70. data/ext/commonmarker/cmark/src/scanners.re +1 -1
  71. data/ext/commonmarker/cmark/src/utf8.c +276 -419
  72. data/ext/commonmarker/cmark/src/utf8.h +6 -6
  73. data/ext/commonmarker/cmark/src/xml.c +129 -144
  74. data/ext/commonmarker/cmark/test/CMakeLists.txt +4 -4
  75. data/ext/commonmarker/cmark/test/smart_punct.txt +8 -0
  76. data/ext/commonmarker/cmark/test/spec.txt +109 -47
  77. data/lib/commonmarker/version.rb +1 -1
  78. metadata +2 -2
@@ -16,234 +16,220 @@
16
16
  #define BLANKLINE() renderer->blankline(renderer)
17
17
 
18
18
  // Functions to convert cmark_nodes to groff man strings.
19
- static
20
- void S_outc(cmark_renderer *renderer,
21
- cmark_escaping escape,
22
- int32_t c,
23
- unsigned char nextc)
24
- {
25
- (void)(nextc);
26
-
27
- if (escape == LITERAL) {
28
- cmark_render_code_point(renderer, c);
29
- return;
30
- }
31
-
32
- switch(c) {
33
- case 46:
34
- if (renderer->begin_line) {
35
- cmark_render_ascii(renderer, "\\&.");
36
- } else {
37
- cmark_render_code_point(renderer, c);
38
- }
39
- break;
40
- case 39:
41
- if (renderer->begin_line) {
42
- cmark_render_ascii(renderer, "\\&'");
43
- } else {
44
- cmark_render_code_point(renderer, c);
45
- }
46
- break;
47
- case 45:
48
- cmark_render_ascii(renderer, "\\-");
49
- break;
50
- case 92:
51
- cmark_render_ascii(renderer, "\\e");
52
- break;
53
- case 8216: // left single quote
54
- cmark_render_ascii(renderer, "\\[oq]");
55
- break;
56
- case 8217: // right single quote
57
- cmark_render_ascii(renderer, "\\[cq]");
58
- break;
59
- case 8220: // left double quote
60
- cmark_render_ascii(renderer, "\\[lq]");
61
- break;
62
- case 8221: // right double quote
63
- cmark_render_ascii(renderer, "\\[rq]");
64
- break;
65
- case 8212: // em dash
66
- cmark_render_ascii(renderer, "\\[em]");
67
- break;
68
- case 8211: // en dash
69
- cmark_render_ascii(renderer, "\\[en]");
70
- break;
71
- default:
72
- cmark_render_code_point(renderer, c);
73
- }
19
+ static void S_outc(cmark_renderer *renderer, cmark_escaping escape, int32_t c,
20
+ unsigned char nextc) {
21
+ (void)(nextc);
22
+
23
+ if (escape == LITERAL) {
24
+ cmark_render_code_point(renderer, c);
25
+ return;
26
+ }
27
+
28
+ switch (c) {
29
+ case 46:
30
+ if (renderer->begin_line) {
31
+ cmark_render_ascii(renderer, "\\&.");
32
+ } else {
33
+ cmark_render_code_point(renderer, c);
34
+ }
35
+ break;
36
+ case 39:
37
+ if (renderer->begin_line) {
38
+ cmark_render_ascii(renderer, "\\&'");
39
+ } else {
40
+ cmark_render_code_point(renderer, c);
41
+ }
42
+ break;
43
+ case 45:
44
+ cmark_render_ascii(renderer, "\\-");
45
+ break;
46
+ case 92:
47
+ cmark_render_ascii(renderer, "\\e");
48
+ break;
49
+ case 8216: // left single quote
50
+ cmark_render_ascii(renderer, "\\[oq]");
51
+ break;
52
+ case 8217: // right single quote
53
+ cmark_render_ascii(renderer, "\\[cq]");
54
+ break;
55
+ case 8220: // left double quote
56
+ cmark_render_ascii(renderer, "\\[lq]");
57
+ break;
58
+ case 8221: // right double quote
59
+ cmark_render_ascii(renderer, "\\[rq]");
60
+ break;
61
+ case 8212: // em dash
62
+ cmark_render_ascii(renderer, "\\[em]");
63
+ break;
64
+ case 8211: // en dash
65
+ cmark_render_ascii(renderer, "\\[en]");
66
+ break;
67
+ default:
68
+ cmark_render_code_point(renderer, c);
69
+ }
74
70
  }
75
71
 
76
- static int
77
- S_render_node(cmark_renderer *renderer,
78
- cmark_node *node,
79
- cmark_event_type ev_type,
80
- int options)
81
- {
82
- cmark_node *tmp;
83
- int list_number;
84
- bool entering = (ev_type == CMARK_EVENT_ENTER);
85
-
86
- // avoid unused parameter error:
87
- (void)(options);
88
-
89
- switch (node->type) {
90
- case CMARK_NODE_DOCUMENT:
91
- break;
92
-
93
- case CMARK_NODE_BLOCK_QUOTE:
94
- if (entering) {
95
- CR();
96
- LIT(".RS");
97
- CR();
98
- } else {
99
- CR();
100
- LIT(".RE");
101
- CR();
102
- }
103
- break;
104
-
105
- case CMARK_NODE_LIST:
106
- break;
107
-
108
- case CMARK_NODE_ITEM:
109
- if (entering) {
110
- CR();
111
- LIT(".IP ");
112
- if (cmark_node_get_list_type(node->parent) ==
113
- CMARK_BULLET_LIST) {
114
- LIT("\\[bu] 2");
115
- } else {
116
- list_number = cmark_node_get_list_start(node->parent);
117
- tmp = node;
118
- while (tmp->prev) {
119
- tmp = tmp->prev;
120
- list_number += 1;
121
- }
122
- char list_number_s[20];
123
- sprintf(list_number_s, "\"%d.\" 4", list_number);
124
- LIT(list_number_s);
125
- }
126
- CR();
127
- } else {
128
- CR();
129
- }
130
- break;
131
-
132
- case CMARK_NODE_HEADER:
133
- if (entering) {
134
- CR();
135
- LIT(cmark_node_get_header_level(node) == 1 ?
136
- ".SH" : ".SS");
137
- CR();
138
- } else {
139
- CR();
140
- }
141
- break;
142
-
143
- case CMARK_NODE_CODE_BLOCK:
144
- CR();
145
- LIT(".IP\n.nf\n\\f[C]\n");
146
- OUT(cmark_node_get_literal(node),
147
- false,
148
- NORMAL);
149
- CR();
150
- LIT("\\f[]\n.fi");
151
- CR();
152
- break;
153
-
154
- case CMARK_NODE_HTML:
155
- break;
156
-
157
- case CMARK_NODE_HRULE:
158
- CR();
159
- LIT(".PP\n * * * * *");
160
- CR();
161
- break;
162
-
163
- case CMARK_NODE_PARAGRAPH:
164
- if (entering) {
165
- // no blank line if first paragraph in list:
166
- if (node->parent &&
167
- node->parent->type == CMARK_NODE_ITEM &&
168
- node->prev == NULL) {
169
- // no blank line or .PP
170
- } else {
171
- CR();
172
- LIT(".PP");
173
- CR();
174
- }
175
- } else {
176
- CR();
177
- }
178
- break;
179
-
180
- case CMARK_NODE_TEXT:
181
- OUT(cmark_node_get_literal(node), true, NORMAL);
182
- break;
183
-
184
- case CMARK_NODE_LINEBREAK:
185
- LIT(".PD 0\n.P\n.PD");
186
- CR();
187
- break;
188
-
189
- case CMARK_NODE_SOFTBREAK:
190
- if (renderer->width == 0) {
191
- CR();
192
- } else {
193
- OUT(" ", true, LITERAL);
194
- }
195
- break;
196
-
197
- case CMARK_NODE_CODE:
198
- LIT("\\f[C]");
199
- OUT(cmark_node_get_literal(node), true, NORMAL);
200
- LIT("\\f[]");
201
- break;
202
-
203
- case CMARK_NODE_INLINE_HTML:
204
- break;
205
-
206
- case CMARK_NODE_STRONG:
207
- if (entering) {
208
- LIT("\\f[B]");
209
- } else {
210
- LIT("\\f[]");
211
- }
212
- break;
213
-
214
- case CMARK_NODE_EMPH:
215
- if (entering) {
216
- LIT("\\f[I]");
217
- } else {
218
- LIT("\\f[]");
219
- }
220
- break;
221
-
222
- case CMARK_NODE_LINK:
223
- if (!entering) {
224
- LIT(" (");
225
- OUT(cmark_node_get_url(node), true, URL);
226
- LIT(")");
227
- }
228
- break;
229
-
230
- case CMARK_NODE_IMAGE:
231
- if (entering) {
232
- LIT("[IMAGE: ");
233
- } else {
234
- LIT("]");
235
- }
236
- break;
237
-
238
- default:
239
- assert(false);
240
- break;
241
- }
242
-
243
- return 1;
72
+ static int S_render_node(cmark_renderer *renderer, cmark_node *node,
73
+ cmark_event_type ev_type, int options) {
74
+ cmark_node *tmp;
75
+ int list_number;
76
+ bool entering = (ev_type == CMARK_EVENT_ENTER);
77
+
78
+ // avoid unused parameter error:
79
+ (void)(options);
80
+
81
+ switch (node->type) {
82
+ case CMARK_NODE_DOCUMENT:
83
+ break;
84
+
85
+ case CMARK_NODE_BLOCK_QUOTE:
86
+ if (entering) {
87
+ CR();
88
+ LIT(".RS");
89
+ CR();
90
+ } else {
91
+ CR();
92
+ LIT(".RE");
93
+ CR();
94
+ }
95
+ break;
96
+
97
+ case CMARK_NODE_LIST:
98
+ break;
99
+
100
+ case CMARK_NODE_ITEM:
101
+ if (entering) {
102
+ CR();
103
+ LIT(".IP ");
104
+ if (cmark_node_get_list_type(node->parent) == CMARK_BULLET_LIST) {
105
+ LIT("\\[bu] 2");
106
+ } else {
107
+ list_number = cmark_node_get_list_start(node->parent);
108
+ tmp = node;
109
+ while (tmp->prev) {
110
+ tmp = tmp->prev;
111
+ list_number += 1;
112
+ }
113
+ char list_number_s[20];
114
+ sprintf(list_number_s, "\"%d.\" 4", list_number);
115
+ LIT(list_number_s);
116
+ }
117
+ CR();
118
+ } else {
119
+ CR();
120
+ }
121
+ break;
122
+
123
+ case CMARK_NODE_HEADER:
124
+ if (entering) {
125
+ CR();
126
+ LIT(cmark_node_get_header_level(node) == 1 ? ".SH" : ".SS");
127
+ CR();
128
+ } else {
129
+ CR();
130
+ }
131
+ break;
132
+
133
+ case CMARK_NODE_CODE_BLOCK:
134
+ CR();
135
+ LIT(".IP\n.nf\n\\f[C]\n");
136
+ OUT(cmark_node_get_literal(node), false, NORMAL);
137
+ CR();
138
+ LIT("\\f[]\n.fi");
139
+ CR();
140
+ break;
141
+
142
+ case CMARK_NODE_HTML:
143
+ break;
144
+
145
+ case CMARK_NODE_HRULE:
146
+ CR();
147
+ LIT(".PP\n * * * * *");
148
+ CR();
149
+ break;
150
+
151
+ case CMARK_NODE_PARAGRAPH:
152
+ if (entering) {
153
+ // no blank line if first paragraph in list:
154
+ if (node->parent && node->parent->type == CMARK_NODE_ITEM &&
155
+ node->prev == NULL) {
156
+ // no blank line or .PP
157
+ } else {
158
+ CR();
159
+ LIT(".PP");
160
+ CR();
161
+ }
162
+ } else {
163
+ CR();
164
+ }
165
+ break;
166
+
167
+ case CMARK_NODE_TEXT:
168
+ OUT(cmark_node_get_literal(node), true, NORMAL);
169
+ break;
170
+
171
+ case CMARK_NODE_LINEBREAK:
172
+ LIT(".PD 0\n.P\n.PD");
173
+ CR();
174
+ break;
175
+
176
+ case CMARK_NODE_SOFTBREAK:
177
+ if (renderer->width == 0) {
178
+ CR();
179
+ } else {
180
+ OUT(" ", true, LITERAL);
181
+ }
182
+ break;
183
+
184
+ case CMARK_NODE_CODE:
185
+ LIT("\\f[C]");
186
+ OUT(cmark_node_get_literal(node), true, NORMAL);
187
+ LIT("\\f[]");
188
+ break;
189
+
190
+ case CMARK_NODE_INLINE_HTML:
191
+ break;
192
+
193
+ case CMARK_NODE_STRONG:
194
+ if (entering) {
195
+ LIT("\\f[B]");
196
+ } else {
197
+ LIT("\\f[]");
198
+ }
199
+ break;
200
+
201
+ case CMARK_NODE_EMPH:
202
+ if (entering) {
203
+ LIT("\\f[I]");
204
+ } else {
205
+ LIT("\\f[]");
206
+ }
207
+ break;
208
+
209
+ case CMARK_NODE_LINK:
210
+ if (!entering) {
211
+ LIT(" (");
212
+ OUT(cmark_node_get_url(node), true, URL);
213
+ LIT(")");
214
+ }
215
+ break;
216
+
217
+ case CMARK_NODE_IMAGE:
218
+ if (entering) {
219
+ LIT("[IMAGE: ");
220
+ } else {
221
+ LIT("]");
222
+ }
223
+ break;
224
+
225
+ default:
226
+ assert(false);
227
+ break;
228
+ }
229
+
230
+ return 1;
244
231
  }
245
232
 
246
- char *cmark_render_man(cmark_node *root, int options, int width)
247
- {
248
- return cmark_render(root, options, width, S_outc, S_render_node);
233
+ char *cmark_render_man(cmark_node *root, int options, int width) {
234
+ return cmark_render(root, options, width, S_outc, S_render_node);
249
235
  }