commonmarker 0.23.7.pre1 → 1.0.0.pre.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (89) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +70 -212
  3. data/commonmarker.gemspec +34 -31
  4. data/ext/commonmarker/Cargo.toml +12 -0
  5. data/ext/commonmarker/_util.rb +102 -0
  6. data/ext/commonmarker/extconf.rb +4 -5
  7. data/ext/commonmarker/src/comrak_options.rs +136 -0
  8. data/ext/commonmarker/src/lib.rs +29 -0
  9. data/lib/commonmarker/config.rb +57 -38
  10. data/lib/commonmarker/extension.rb +14 -0
  11. data/lib/commonmarker/renderer.rb +1 -127
  12. data/lib/commonmarker/version.rb +2 -2
  13. data/lib/commonmarker.rb +14 -29
  14. metadata +34 -178
  15. data/Rakefile +0 -109
  16. data/bin/commonmarker +0 -118
  17. data/ext/commonmarker/arena.c +0 -103
  18. data/ext/commonmarker/autolink.c +0 -456
  19. data/ext/commonmarker/autolink.h +0 -8
  20. data/ext/commonmarker/blocks.c +0 -1596
  21. data/ext/commonmarker/buffer.c +0 -278
  22. data/ext/commonmarker/buffer.h +0 -116
  23. data/ext/commonmarker/case_fold_switch.inc +0 -4327
  24. data/ext/commonmarker/chunk.h +0 -135
  25. data/ext/commonmarker/cmark-gfm-core-extensions.h +0 -54
  26. data/ext/commonmarker/cmark-gfm-extension_api.h +0 -736
  27. data/ext/commonmarker/cmark-gfm-extensions_export.h +0 -42
  28. data/ext/commonmarker/cmark-gfm.h +0 -817
  29. data/ext/commonmarker/cmark-gfm_export.h +0 -42
  30. data/ext/commonmarker/cmark-gfm_version.h +0 -7
  31. data/ext/commonmarker/cmark.c +0 -55
  32. data/ext/commonmarker/cmark_ctype.c +0 -44
  33. data/ext/commonmarker/cmark_ctype.h +0 -33
  34. data/ext/commonmarker/commonmark.c +0 -529
  35. data/ext/commonmarker/commonmarker.c +0 -1307
  36. data/ext/commonmarker/commonmarker.h +0 -16
  37. data/ext/commonmarker/config.h +0 -76
  38. data/ext/commonmarker/core-extensions.c +0 -27
  39. data/ext/commonmarker/entities.inc +0 -2138
  40. data/ext/commonmarker/ext_scanners.c +0 -879
  41. data/ext/commonmarker/ext_scanners.h +0 -24
  42. data/ext/commonmarker/footnotes.c +0 -63
  43. data/ext/commonmarker/footnotes.h +0 -27
  44. data/ext/commonmarker/houdini.h +0 -57
  45. data/ext/commonmarker/houdini_href_e.c +0 -100
  46. data/ext/commonmarker/houdini_html_e.c +0 -66
  47. data/ext/commonmarker/houdini_html_u.c +0 -149
  48. data/ext/commonmarker/html.c +0 -486
  49. data/ext/commonmarker/html.h +0 -27
  50. data/ext/commonmarker/inlines.c +0 -1716
  51. data/ext/commonmarker/inlines.h +0 -29
  52. data/ext/commonmarker/iterator.c +0 -159
  53. data/ext/commonmarker/iterator.h +0 -26
  54. data/ext/commonmarker/latex.c +0 -466
  55. data/ext/commonmarker/linked_list.c +0 -37
  56. data/ext/commonmarker/man.c +0 -278
  57. data/ext/commonmarker/map.c +0 -122
  58. data/ext/commonmarker/map.h +0 -41
  59. data/ext/commonmarker/node.c +0 -979
  60. data/ext/commonmarker/node.h +0 -125
  61. data/ext/commonmarker/parser.h +0 -58
  62. data/ext/commonmarker/plaintext.c +0 -235
  63. data/ext/commonmarker/plugin.c +0 -36
  64. data/ext/commonmarker/plugin.h +0 -34
  65. data/ext/commonmarker/references.c +0 -42
  66. data/ext/commonmarker/references.h +0 -26
  67. data/ext/commonmarker/registry.c +0 -63
  68. data/ext/commonmarker/registry.h +0 -24
  69. data/ext/commonmarker/render.c +0 -205
  70. data/ext/commonmarker/render.h +0 -62
  71. data/ext/commonmarker/scanners.c +0 -10508
  72. data/ext/commonmarker/scanners.h +0 -62
  73. data/ext/commonmarker/scanners.re +0 -341
  74. data/ext/commonmarker/strikethrough.c +0 -167
  75. data/ext/commonmarker/strikethrough.h +0 -9
  76. data/ext/commonmarker/syntax_extension.c +0 -149
  77. data/ext/commonmarker/syntax_extension.h +0 -34
  78. data/ext/commonmarker/table.c +0 -848
  79. data/ext/commonmarker/table.h +0 -12
  80. data/ext/commonmarker/tagfilter.c +0 -60
  81. data/ext/commonmarker/tagfilter.h +0 -8
  82. data/ext/commonmarker/tasklist.c +0 -156
  83. data/ext/commonmarker/tasklist.h +0 -8
  84. data/ext/commonmarker/utf8.c +0 -317
  85. data/ext/commonmarker/utf8.h +0 -35
  86. data/ext/commonmarker/xml.c +0 -181
  87. data/lib/commonmarker/node/inspect.rb +0 -47
  88. data/lib/commonmarker/node.rb +0 -83
  89. data/lib/commonmarker/renderer/html_renderer.rb +0 -252
@@ -1,486 +0,0 @@
1
- #include <stdlib.h>
2
- #include <stdio.h>
3
- #include <string.h>
4
- #include <assert.h>
5
- #include "cmark_ctype.h"
6
- #include "config.h"
7
- #include "cmark-gfm.h"
8
- #include "houdini.h"
9
- #include "scanners.h"
10
- #include "syntax_extension.h"
11
- #include "html.h"
12
- #include "render.h"
13
-
14
- // Functions to convert cmark_nodes to HTML strings.
15
-
16
- static void escape_html(cmark_strbuf *dest, const unsigned char *source,
17
- bufsize_t length) {
18
- houdini_escape_html0(dest, source, length, 0);
19
- }
20
-
21
- static void filter_html_block(cmark_html_renderer *renderer, uint8_t *data, size_t len) {
22
- cmark_strbuf *html = renderer->html;
23
- cmark_llist *it;
24
- cmark_syntax_extension *ext;
25
- bool filtered;
26
- uint8_t *match;
27
-
28
- while (len) {
29
- match = (uint8_t *) memchr(data, '<', len);
30
- if (!match)
31
- break;
32
-
33
- if (match != data) {
34
- cmark_strbuf_put(html, data, (bufsize_t)(match - data));
35
- len -= (match - data);
36
- data = match;
37
- }
38
-
39
- filtered = false;
40
- for (it = renderer->filter_extensions; it; it = it->next) {
41
- ext = ((cmark_syntax_extension *) it->data);
42
- if (!ext->html_filter_func(ext, data, len)) {
43
- filtered = true;
44
- break;
45
- }
46
- }
47
-
48
- if (!filtered) {
49
- cmark_strbuf_putc(html, '<');
50
- } else {
51
- cmark_strbuf_puts(html, "&lt;");
52
- }
53
-
54
- ++data;
55
- --len;
56
- }
57
-
58
- if (len)
59
- cmark_strbuf_put(html, data, (bufsize_t)len);
60
- }
61
-
62
- static bool S_put_footnote_backref(cmark_html_renderer *renderer, cmark_strbuf *html, cmark_node *node) {
63
- if (renderer->written_footnote_ix >= renderer->footnote_ix)
64
- return false;
65
- renderer->written_footnote_ix = renderer->footnote_ix;
66
-
67
- cmark_strbuf_puts(html, "<a href=\"#fnref-");
68
- houdini_escape_href(html, node->as.literal.data, node->as.literal.len);
69
- cmark_strbuf_puts(html, "\" class=\"footnote-backref\" data-footnote-backref aria-label=\"Back to content\">↩</a>");
70
-
71
- if (node->footnote.def_count > 1)
72
- {
73
- for(int i = 2; i <= node->footnote.def_count; i++) {
74
- char n[32];
75
- snprintf(n, sizeof(n), "%d", i);
76
-
77
- cmark_strbuf_puts(html, " <a href=\"#fnref-");
78
- houdini_escape_href(html, node->as.literal.data, node->as.literal.len);
79
- cmark_strbuf_puts(html, "-");
80
- cmark_strbuf_puts(html, n);
81
- cmark_strbuf_puts(html, "\" class=\"footnote-backref\" data-footnote-backref aria-label=\"Back to content\">↩<sup class=\"footnote-ref\">");
82
- cmark_strbuf_puts(html, n);
83
- cmark_strbuf_puts(html, "</sup></a>");
84
- }
85
- }
86
-
87
- return true;
88
- }
89
-
90
- static int S_render_node(cmark_html_renderer *renderer, cmark_node *node,
91
- cmark_event_type ev_type, int options) {
92
- cmark_node *parent;
93
- cmark_node *grandparent;
94
- cmark_strbuf *html = renderer->html;
95
- cmark_llist *it;
96
- cmark_syntax_extension *ext;
97
- char start_heading[] = "<h0";
98
- char end_heading[] = "</h0";
99
- bool tight;
100
- bool filtered;
101
- char buffer[BUFFER_SIZE];
102
-
103
- bool entering = (ev_type == CMARK_EVENT_ENTER);
104
-
105
- if (renderer->plain == node) { // back at original node
106
- renderer->plain = NULL;
107
- }
108
-
109
- if (renderer->plain != NULL) {
110
- switch (node->type) {
111
- case CMARK_NODE_TEXT:
112
- case CMARK_NODE_CODE:
113
- case CMARK_NODE_HTML_INLINE:
114
- escape_html(html, node->as.literal.data, node->as.literal.len);
115
- break;
116
-
117
- case CMARK_NODE_LINEBREAK:
118
- case CMARK_NODE_SOFTBREAK:
119
- cmark_strbuf_putc(html, ' ');
120
- break;
121
-
122
- default:
123
- break;
124
- }
125
- return 1;
126
- }
127
-
128
- if (node->extension && node->extension->html_render_func) {
129
- node->extension->html_render_func(node->extension, renderer, node, ev_type, options);
130
- return 1;
131
- }
132
-
133
- switch (node->type) {
134
- case CMARK_NODE_DOCUMENT:
135
- break;
136
-
137
- case CMARK_NODE_BLOCK_QUOTE:
138
- if (entering) {
139
- cmark_html_render_cr(html);
140
- cmark_strbuf_puts(html, "<blockquote");
141
- cmark_html_render_sourcepos(node, html, options);
142
- cmark_strbuf_puts(html, ">\n");
143
- } else {
144
- cmark_html_render_cr(html);
145
- cmark_strbuf_puts(html, "</blockquote>\n");
146
- }
147
- break;
148
-
149
- case CMARK_NODE_LIST: {
150
- cmark_list_type list_type = node->as.list.list_type;
151
- int start = node->as.list.start;
152
-
153
- if (entering) {
154
- cmark_html_render_cr(html);
155
- if (list_type == CMARK_BULLET_LIST) {
156
- cmark_strbuf_puts(html, "<ul");
157
- cmark_html_render_sourcepos(node, html, options);
158
- cmark_strbuf_puts(html, ">\n");
159
- } else if (start == 1) {
160
- cmark_strbuf_puts(html, "<ol");
161
- cmark_html_render_sourcepos(node, html, options);
162
- cmark_strbuf_puts(html, ">\n");
163
- } else {
164
- snprintf(buffer, BUFFER_SIZE, "<ol start=\"%d\"", start);
165
- cmark_strbuf_puts(html, buffer);
166
- cmark_html_render_sourcepos(node, html, options);
167
- cmark_strbuf_puts(html, ">\n");
168
- }
169
- } else {
170
- cmark_strbuf_puts(html,
171
- list_type == CMARK_BULLET_LIST ? "</ul>\n" : "</ol>\n");
172
- }
173
- break;
174
- }
175
-
176
- case CMARK_NODE_ITEM:
177
- if (entering) {
178
- cmark_html_render_cr(html);
179
- cmark_strbuf_puts(html, "<li");
180
- cmark_html_render_sourcepos(node, html, options);
181
- cmark_strbuf_putc(html, '>');
182
- } else {
183
- cmark_strbuf_puts(html, "</li>\n");
184
- }
185
- break;
186
-
187
- case CMARK_NODE_HEADING:
188
- if (entering) {
189
- cmark_html_render_cr(html);
190
- start_heading[2] = (char)('0' + node->as.heading.level);
191
- cmark_strbuf_puts(html, start_heading);
192
- cmark_html_render_sourcepos(node, html, options);
193
- cmark_strbuf_putc(html, '>');
194
- } else {
195
- end_heading[3] = (char)('0' + node->as.heading.level);
196
- cmark_strbuf_puts(html, end_heading);
197
- cmark_strbuf_puts(html, ">\n");
198
- }
199
- break;
200
-
201
- case CMARK_NODE_CODE_BLOCK:
202
- cmark_html_render_cr(html);
203
-
204
- if (node->as.code.info.len == 0) {
205
- cmark_strbuf_puts(html, "<pre");
206
- cmark_html_render_sourcepos(node, html, options);
207
- cmark_strbuf_puts(html, "><code>");
208
- } else {
209
- bufsize_t first_tag = 0;
210
- while (first_tag < node->as.code.info.len &&
211
- !cmark_isspace(node->as.code.info.data[first_tag])) {
212
- first_tag += 1;
213
- }
214
-
215
- if (options & CMARK_OPT_GITHUB_PRE_LANG) {
216
- cmark_strbuf_puts(html, "<pre");
217
- cmark_html_render_sourcepos(node, html, options);
218
- cmark_strbuf_puts(html, " lang=\"");
219
- escape_html(html, node->as.code.info.data, first_tag);
220
- if (first_tag < node->as.code.info.len && (options & CMARK_OPT_FULL_INFO_STRING)) {
221
- cmark_strbuf_puts(html, "\" data-meta=\"");
222
- escape_html(html, node->as.code.info.data + first_tag + 1, node->as.code.info.len - first_tag - 1);
223
- }
224
- cmark_strbuf_puts(html, "\"><code>");
225
- } else {
226
- cmark_strbuf_puts(html, "<pre");
227
- cmark_html_render_sourcepos(node, html, options);
228
- cmark_strbuf_puts(html, "><code class=\"language-");
229
- escape_html(html, node->as.code.info.data, first_tag);
230
- if (first_tag < node->as.code.info.len && (options & CMARK_OPT_FULL_INFO_STRING)) {
231
- cmark_strbuf_puts(html, "\" data-meta=\"");
232
- escape_html(html, node->as.code.info.data + first_tag + 1, node->as.code.info.len - first_tag - 1);
233
- }
234
- cmark_strbuf_puts(html, "\">");
235
- }
236
- }
237
-
238
- escape_html(html, node->as.code.literal.data, node->as.code.literal.len);
239
- cmark_strbuf_puts(html, "</code></pre>\n");
240
- break;
241
-
242
- case CMARK_NODE_HTML_BLOCK:
243
- cmark_html_render_cr(html);
244
- if (!(options & CMARK_OPT_UNSAFE)) {
245
- cmark_strbuf_puts(html, "<!-- raw HTML omitted -->");
246
- } else if (renderer->filter_extensions) {
247
- filter_html_block(renderer, node->as.literal.data, node->as.literal.len);
248
- } else {
249
- cmark_strbuf_put(html, node->as.literal.data, node->as.literal.len);
250
- }
251
- cmark_html_render_cr(html);
252
- break;
253
-
254
- case CMARK_NODE_CUSTOM_BLOCK:
255
- cmark_html_render_cr(html);
256
- if (entering) {
257
- cmark_strbuf_put(html, node->as.custom.on_enter.data,
258
- node->as.custom.on_enter.len);
259
- } else {
260
- cmark_strbuf_put(html, node->as.custom.on_exit.data,
261
- node->as.custom.on_exit.len);
262
- }
263
- cmark_html_render_cr(html);
264
- break;
265
-
266
- case CMARK_NODE_THEMATIC_BREAK:
267
- cmark_html_render_cr(html);
268
- cmark_strbuf_puts(html, "<hr");
269
- cmark_html_render_sourcepos(node, html, options);
270
- cmark_strbuf_puts(html, " />\n");
271
- break;
272
-
273
- case CMARK_NODE_PARAGRAPH:
274
- parent = cmark_node_parent(node);
275
- grandparent = cmark_node_parent(parent);
276
- if (grandparent != NULL && grandparent->type == CMARK_NODE_LIST) {
277
- tight = grandparent->as.list.tight;
278
- } else {
279
- tight = false;
280
- }
281
- if (!tight) {
282
- if (entering) {
283
- cmark_html_render_cr(html);
284
- cmark_strbuf_puts(html, "<p");
285
- cmark_html_render_sourcepos(node, html, options);
286
- cmark_strbuf_putc(html, '>');
287
- } else {
288
- if (parent->type == CMARK_NODE_FOOTNOTE_DEFINITION && node->next == NULL) {
289
- cmark_strbuf_putc(html, ' ');
290
- S_put_footnote_backref(renderer, html, parent);
291
- }
292
- cmark_strbuf_puts(html, "</p>\n");
293
- }
294
- }
295
- break;
296
-
297
- case CMARK_NODE_TEXT:
298
- escape_html(html, node->as.literal.data, node->as.literal.len);
299
- break;
300
-
301
- case CMARK_NODE_LINEBREAK:
302
- cmark_strbuf_puts(html, "<br />\n");
303
- break;
304
-
305
- case CMARK_NODE_SOFTBREAK:
306
- if (options & CMARK_OPT_HARDBREAKS) {
307
- cmark_strbuf_puts(html, "<br />\n");
308
- } else if (options & CMARK_OPT_NOBREAKS) {
309
- cmark_strbuf_putc(html, ' ');
310
- } else {
311
- cmark_strbuf_putc(html, '\n');
312
- }
313
- break;
314
-
315
- case CMARK_NODE_CODE:
316
- cmark_strbuf_puts(html, "<code>");
317
- escape_html(html, node->as.literal.data, node->as.literal.len);
318
- cmark_strbuf_puts(html, "</code>");
319
- break;
320
-
321
- case CMARK_NODE_HTML_INLINE:
322
- if (!(options & CMARK_OPT_UNSAFE)) {
323
- cmark_strbuf_puts(html, "<!-- raw HTML omitted -->");
324
- } else {
325
- filtered = false;
326
- for (it = renderer->filter_extensions; it; it = it->next) {
327
- ext = (cmark_syntax_extension *) it->data;
328
- if (!ext->html_filter_func(ext, node->as.literal.data, node->as.literal.len)) {
329
- filtered = true;
330
- break;
331
- }
332
- }
333
- if (!filtered) {
334
- cmark_strbuf_put(html, node->as.literal.data, node->as.literal.len);
335
- } else {
336
- cmark_strbuf_puts(html, "&lt;");
337
- cmark_strbuf_put(html, node->as.literal.data + 1, node->as.literal.len - 1);
338
- }
339
- }
340
- break;
341
-
342
- case CMARK_NODE_CUSTOM_INLINE:
343
- if (entering) {
344
- cmark_strbuf_put(html, node->as.custom.on_enter.data,
345
- node->as.custom.on_enter.len);
346
- } else {
347
- cmark_strbuf_put(html, node->as.custom.on_exit.data,
348
- node->as.custom.on_exit.len);
349
- }
350
- break;
351
-
352
- case CMARK_NODE_STRONG:
353
- if (entering) {
354
- cmark_strbuf_puts(html, "<strong>");
355
- } else {
356
- cmark_strbuf_puts(html, "</strong>");
357
- }
358
- break;
359
-
360
- case CMARK_NODE_EMPH:
361
- if (entering) {
362
- cmark_strbuf_puts(html, "<em>");
363
- } else {
364
- cmark_strbuf_puts(html, "</em>");
365
- }
366
- break;
367
-
368
- case CMARK_NODE_LINK:
369
- if (entering) {
370
- cmark_strbuf_puts(html, "<a href=\"");
371
- if ((options & CMARK_OPT_UNSAFE) ||
372
- !(scan_dangerous_url(&node->as.link.url, 0))) {
373
- houdini_escape_href(html, node->as.link.url.data,
374
- node->as.link.url.len);
375
- }
376
- if (node->as.link.title.len) {
377
- cmark_strbuf_puts(html, "\" title=\"");
378
- escape_html(html, node->as.link.title.data, node->as.link.title.len);
379
- }
380
- cmark_strbuf_puts(html, "\">");
381
- } else {
382
- cmark_strbuf_puts(html, "</a>");
383
- }
384
- break;
385
-
386
- case CMARK_NODE_IMAGE:
387
- if (entering) {
388
- cmark_strbuf_puts(html, "<img src=\"");
389
- if ((options & CMARK_OPT_UNSAFE) ||
390
- !(scan_dangerous_url(&node->as.link.url, 0))) {
391
- houdini_escape_href(html, node->as.link.url.data,
392
- node->as.link.url.len);
393
- }
394
- cmark_strbuf_puts(html, "\" alt=\"");
395
- renderer->plain = node;
396
- } else {
397
- if (node->as.link.title.len) {
398
- cmark_strbuf_puts(html, "\" title=\"");
399
- escape_html(html, node->as.link.title.data, node->as.link.title.len);
400
- }
401
-
402
- cmark_strbuf_puts(html, "\" />");
403
- }
404
- break;
405
-
406
- case CMARK_NODE_FOOTNOTE_DEFINITION:
407
- if (entering) {
408
- if (renderer->footnote_ix == 0) {
409
- cmark_strbuf_puts(html, "<section class=\"footnotes\" data-footnotes>\n<ol>\n");
410
- }
411
- ++renderer->footnote_ix;
412
-
413
- cmark_strbuf_puts(html, "<li id=\"fn-");
414
- houdini_escape_href(html, node->as.literal.data, node->as.literal.len);
415
- cmark_strbuf_puts(html, "\">\n");
416
- } else {
417
- if (S_put_footnote_backref(renderer, html, node)) {
418
- cmark_strbuf_putc(html, '\n');
419
- }
420
- cmark_strbuf_puts(html, "</li>\n");
421
- }
422
- break;
423
-
424
- case CMARK_NODE_FOOTNOTE_REFERENCE:
425
- if (entering) {
426
- cmark_strbuf_puts(html, "<sup class=\"footnote-ref\"><a href=\"#fn-");
427
- houdini_escape_href(html, node->parent_footnote_def->as.literal.data, node->parent_footnote_def->as.literal.len);
428
- cmark_strbuf_puts(html, "\" id=\"fnref-");
429
- houdini_escape_href(html, node->parent_footnote_def->as.literal.data, node->parent_footnote_def->as.literal.len);
430
-
431
- if (node->footnote.ref_ix > 1) {
432
- char n[32];
433
- snprintf(n, sizeof(n), "%d", node->footnote.ref_ix);
434
- cmark_strbuf_puts(html, "-");
435
- cmark_strbuf_puts(html, n);
436
- }
437
-
438
- cmark_strbuf_puts(html, "\" data-footnote-ref>");
439
- houdini_escape_href(html, node->as.literal.data, node->as.literal.len);
440
- cmark_strbuf_puts(html, "</a></sup>");
441
- }
442
- break;
443
-
444
- default:
445
- assert(false);
446
- break;
447
- }
448
-
449
- return 1;
450
- }
451
-
452
- char *cmark_render_html(cmark_node *root, int options, cmark_llist *extensions) {
453
- return cmark_render_html_with_mem(root, options, extensions, cmark_node_mem(root));
454
- }
455
-
456
- char *cmark_render_html_with_mem(cmark_node *root, int options, cmark_llist *extensions, cmark_mem *mem) {
457
- char *result;
458
- cmark_strbuf html = CMARK_BUF_INIT(mem);
459
- cmark_event_type ev_type;
460
- cmark_node *cur;
461
- cmark_html_renderer renderer = {&html, NULL, NULL, 0, 0, NULL};
462
- cmark_iter *iter = cmark_iter_new(root);
463
-
464
- for (; extensions; extensions = extensions->next)
465
- if (((cmark_syntax_extension *) extensions->data)->html_filter_func)
466
- renderer.filter_extensions = cmark_llist_append(
467
- mem,
468
- renderer.filter_extensions,
469
- (cmark_syntax_extension *) extensions->data);
470
-
471
- while ((ev_type = cmark_iter_next(iter)) != CMARK_EVENT_DONE) {
472
- cur = cmark_iter_get_node(iter);
473
- S_render_node(&renderer, cur, ev_type, options);
474
- }
475
-
476
- if (renderer.footnote_ix) {
477
- cmark_strbuf_puts(&html, "</ol>\n</section>\n");
478
- }
479
-
480
- result = (char *)cmark_strbuf_detach(&html);
481
-
482
- cmark_llist_free(mem, renderer.filter_extensions);
483
-
484
- cmark_iter_free(iter);
485
- return result;
486
- }
@@ -1,27 +0,0 @@
1
- #ifndef CMARK_HTML_H
2
- #define CMARK_HTML_H
3
-
4
- #include "buffer.h"
5
- #include "node.h"
6
-
7
- CMARK_INLINE
8
- static void cmark_html_render_cr(cmark_strbuf *html) {
9
- if (html->size && html->ptr[html->size - 1] != '\n')
10
- cmark_strbuf_putc(html, '\n');
11
- }
12
-
13
- #define BUFFER_SIZE 100
14
-
15
- CMARK_INLINE
16
- static void cmark_html_render_sourcepos(cmark_node *node, cmark_strbuf *html, int options) {
17
- char buffer[BUFFER_SIZE];
18
- if (CMARK_OPT_SOURCEPOS & options) {
19
- snprintf(buffer, BUFFER_SIZE, " data-sourcepos=\"%d:%d-%d:%d\"",
20
- cmark_node_get_start_line(node), cmark_node_get_start_column(node),
21
- cmark_node_get_end_line(node), cmark_node_get_end_column(node));
22
- cmark_strbuf_puts(html, buffer);
23
- }
24
- }
25
-
26
-
27
- #endif