commonmarker 0.14.2 → 0.14.3
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/extensions/table.c +26 -23
- data/ext/commonmarker/cmark/src/cmark_extension_api.h +11 -1
- data/ext/commonmarker/cmark/src/node.c +3 -0
- data/ext/commonmarker/cmark/src/syntax_extension.c +5 -0
- data/ext/commonmarker/cmark/src/syntax_extension.h +1 -0
- data/ext/commonmarker/commonmarker.c +5 -0
- data/lib/commonmarker/renderer/html_renderer.rb +18 -0
- data/lib/commonmarker/version.rb +1 -1
- data/test/test_extensions.rb +17 -0
- metadata +2 -126
- data/ext/commonmarker/cmark/build/CMakeCache.txt +0 -468
- data/ext/commonmarker/cmark/build/CMakeFiles/3.7.2/CMakeCCompiler.cmake +0 -68
- data/ext/commonmarker/cmark/build/CMakeFiles/3.7.2/CMakeCXXCompiler.cmake +0 -69
- data/ext/commonmarker/cmark/build/CMakeFiles/3.7.2/CMakeDetermineCompilerABI_C.bin +0 -0
- data/ext/commonmarker/cmark/build/CMakeFiles/3.7.2/CMakeDetermineCompilerABI_CXX.bin +0 -0
- data/ext/commonmarker/cmark/build/CMakeFiles/3.7.2/CMakeSystem.cmake +0 -15
- data/ext/commonmarker/cmark/build/CMakeFiles/3.7.2/CompilerIdC/CMakeCCompilerId.c +0 -561
- data/ext/commonmarker/cmark/build/CMakeFiles/3.7.2/CompilerIdC/a.out +0 -0
- data/ext/commonmarker/cmark/build/CMakeFiles/3.7.2/CompilerIdCXX/CMakeCXXCompilerId.cpp +0 -533
- data/ext/commonmarker/cmark/build/CMakeFiles/3.7.2/CompilerIdCXX/a.out +0 -0
- data/ext/commonmarker/cmark/build/CMakeFiles/CMakeDirectoryInformation.cmake +0 -16
- data/ext/commonmarker/cmark/build/CMakeFiles/CMakeError.log +0 -14
- data/ext/commonmarker/cmark/build/CMakeFiles/CMakeOutput.log +0 -562
- data/ext/commonmarker/cmark/build/CMakeFiles/Makefile.cmake +0 -154
- data/ext/commonmarker/cmark/build/CMakeFiles/Makefile2 +0 -351
- data/ext/commonmarker/cmark/build/CMakeFiles/TargetDirectories.txt +0 -47
- data/ext/commonmarker/cmark/build/CMakeFiles/cmake.check_cache +0 -1
- data/ext/commonmarker/cmark/build/CMakeFiles/feature_tests.bin +0 -0
- data/ext/commonmarker/cmark/build/CMakeFiles/feature_tests.c +0 -34
- data/ext/commonmarker/cmark/build/CMakeFiles/feature_tests.cxx +0 -405
- data/ext/commonmarker/cmark/build/CMakeFiles/progress.marks +0 -1
- data/ext/commonmarker/cmark/build/CTestTestfile.cmake +0 -11
- data/ext/commonmarker/cmark/build/Makefile +0 -264
- data/ext/commonmarker/cmark/build/api_test/CMakeFiles/CMakeDirectoryInformation.cmake +0 -16
- data/ext/commonmarker/cmark/build/api_test/CMakeFiles/api_test.dir/DependInfo.cmake +0 -35
- data/ext/commonmarker/cmark/build/api_test/CMakeFiles/api_test.dir/build.make +0 -168
- data/ext/commonmarker/cmark/build/api_test/CMakeFiles/api_test.dir/cmake_clean.cmake +0 -12
- data/ext/commonmarker/cmark/build/api_test/CMakeFiles/api_test.dir/depend.make +0 -2
- data/ext/commonmarker/cmark/build/api_test/CMakeFiles/api_test.dir/flags.make +0 -17
- data/ext/commonmarker/cmark/build/api_test/CMakeFiles/api_test.dir/link.txt +0 -1
- data/ext/commonmarker/cmark/build/api_test/CMakeFiles/api_test.dir/progress.make +0 -5
- data/ext/commonmarker/cmark/build/api_test/CMakeFiles/progress.marks +0 -1
- data/ext/commonmarker/cmark/build/api_test/Makefile +0 -300
- data/ext/commonmarker/cmark/build/api_test/cmake_install.cmake +0 -29
- data/ext/commonmarker/cmark/build/cmake_install.cmake +0 -49
- data/ext/commonmarker/cmark/build/extensions/CMakeFiles/CMakeDirectoryInformation.cmake +0 -16
- data/ext/commonmarker/cmark/build/extensions/CMakeFiles/libcmarkextensions_static.dir/C.includecache +0 -204
- data/ext/commonmarker/cmark/build/extensions/CMakeFiles/libcmarkextensions_static.dir/DependInfo.cmake +0 -29
- data/ext/commonmarker/cmark/build/extensions/CMakeFiles/libcmarkextensions_static.dir/autolink.c.o +0 -0
- data/ext/commonmarker/cmark/build/extensions/CMakeFiles/libcmarkextensions_static.dir/build.make +0 -249
- data/ext/commonmarker/cmark/build/extensions/CMakeFiles/libcmarkextensions_static.dir/cmake_clean.cmake +0 -15
- data/ext/commonmarker/cmark/build/extensions/CMakeFiles/libcmarkextensions_static.dir/cmake_clean_target.cmake +0 -3
- data/ext/commonmarker/cmark/build/extensions/CMakeFiles/libcmarkextensions_static.dir/core-extensions.c.o +0 -0
- data/ext/commonmarker/cmark/build/extensions/CMakeFiles/libcmarkextensions_static.dir/depend.internal +0 -94
- data/ext/commonmarker/cmark/build/extensions/CMakeFiles/libcmarkextensions_static.dir/depend.make +0 -94
- data/ext/commonmarker/cmark/build/extensions/CMakeFiles/libcmarkextensions_static.dir/ext_scanners.c.o +0 -0
- data/ext/commonmarker/cmark/build/extensions/CMakeFiles/libcmarkextensions_static.dir/flags.make +0 -10
- data/ext/commonmarker/cmark/build/extensions/CMakeFiles/libcmarkextensions_static.dir/link.txt +0 -2
- data/ext/commonmarker/cmark/build/extensions/CMakeFiles/libcmarkextensions_static.dir/progress.make +0 -8
- data/ext/commonmarker/cmark/build/extensions/CMakeFiles/libcmarkextensions_static.dir/strikethrough.c.o +0 -0
- data/ext/commonmarker/cmark/build/extensions/CMakeFiles/libcmarkextensions_static.dir/table.c.o +0 -0
- data/ext/commonmarker/cmark/build/extensions/CMakeFiles/libcmarkextensions_static.dir/tagfilter.c.o +0 -0
- data/ext/commonmarker/cmark/build/extensions/CMakeFiles/progress.marks +0 -1
- data/ext/commonmarker/cmark/build/extensions/Makefile +0 -390
- data/ext/commonmarker/cmark/build/extensions/cmake_install.cmake +0 -29
- data/ext/commonmarker/cmark/build/extensions/libcmarkextensions.a +0 -0
- data/ext/commonmarker/cmark/build/man/CMakeFiles/CMakeDirectoryInformation.cmake +0 -16
- data/ext/commonmarker/cmark/build/man/CMakeFiles/progress.marks +0 -1
- data/ext/commonmarker/cmark/build/man/Makefile +0 -194
- data/ext/commonmarker/cmark/build/man/cmake_install.cmake +0 -37
- data/ext/commonmarker/cmark/build/src/CMakeFiles/CMakeDirectoryInformation.cmake +0 -16
- data/ext/commonmarker/cmark/build/src/CMakeFiles/Export/lib/cmake/cmark-release.cmake +0 -38
- data/ext/commonmarker/cmark/build/src/CMakeFiles/Export/lib/cmake/cmark.cmake +0 -95
- data/ext/commonmarker/cmark/build/src/CMakeFiles/cmark.dir/DependInfo.cmake +0 -29
- data/ext/commonmarker/cmark/build/src/CMakeFiles/cmark.dir/build.make +0 -115
- data/ext/commonmarker/cmark/build/src/CMakeFiles/cmark.dir/cmake_clean.cmake +0 -10
- data/ext/commonmarker/cmark/build/src/CMakeFiles/cmark.dir/depend.make +0 -2
- data/ext/commonmarker/cmark/build/src/CMakeFiles/cmark.dir/flags.make +0 -10
- data/ext/commonmarker/cmark/build/src/CMakeFiles/cmark.dir/link.txt +0 -1
- data/ext/commonmarker/cmark/build/src/CMakeFiles/cmark.dir/progress.make +0 -3
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark.dir/DependInfo.cmake +0 -56
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark.dir/build.make +0 -738
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark.dir/cmake_clean.cmake +0 -34
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark.dir/depend.make +0 -2
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark.dir/flags.make +0 -10
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark.dir/link.txt +0 -1
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark.dir/progress.make +0 -26
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/C.includecache +0 -612
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/DependInfo.cmake +0 -50
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/arena.c.o +0 -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/buffer.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/build.make +0 -735
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/cmake_clean.cmake +0 -33
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/cmake_clean_target.cmake +0 -3
- 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/cmark_ctype.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/commonmark.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/depend.internal +0 -290
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/depend.make +0 -290
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/flags.make +0 -10
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/houdini_href_e.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/houdini_html_e.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/houdini_html_u.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/html.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/inlines.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/iterator.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/latex.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/link.txt +0 -2
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/linked_list.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/man.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/node.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/plugin.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/progress.make +0 -26
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/references.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/registry.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/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/syntax_extension.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/utf8.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/xml.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/progress.marks +0 -1
- data/ext/commonmarker/cmark/build/src/Makefile +0 -1064
- data/ext/commonmarker/cmark/build/src/cmake_install.cmake +0 -103
- data/ext/commonmarker/cmark/build/src/cmark_export.h +0 -42
- data/ext/commonmarker/cmark/build/src/cmark_version.h +0 -7
- data/ext/commonmarker/cmark/build/src/config.h +0 -76
- data/ext/commonmarker/cmark/build/src/libcmark.a +0 -0
- data/ext/commonmarker/cmark/build/src/libcmark.pc +0 -10
- data/ext/commonmarker/cmark/build/testdir/CMakeFiles/CMakeDirectoryInformation.cmake +0 -16
- data/ext/commonmarker/cmark/build/testdir/CMakeFiles/progress.marks +0 -1
- data/ext/commonmarker/cmark/build/testdir/CTestTestfile.cmake +0 -17
- data/ext/commonmarker/cmark/build/testdir/Makefile +0 -194
- data/ext/commonmarker/cmark/build/testdir/cmake_install.cmake +0 -29
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c66dd273d46d41ebb56c7e6ca8d29eb0a447271d
|
4
|
+
data.tar.gz: 6d328f0fefa8996ef9842059032ddfd435d3eace
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8160c279776e983ada3e2d28d6d3317292a02fbaf3f64e24cbf24624f95641e5b38136404374190edaeebadd90222f07b9e29a5f794eee9e936a7c954dc3ce97
|
7
|
+
data.tar.gz: ecd7b6a1971a5bf5a6ab5d1953b26207143314610092cc884d85de5ae6a8dd3c5b07b637663a449167036af0e5e8746329922c87739ed061fd4e9c633220cdf4
|
@@ -49,14 +49,14 @@ static int get_n_table_columns(cmark_node *node) {
|
|
49
49
|
if (!node || node->type != CMARK_NODE_TABLE)
|
50
50
|
return -1;
|
51
51
|
|
52
|
-
return (int)((node_table *)node->
|
52
|
+
return (int)((node_table *)node->as.opaque)->n_columns;
|
53
53
|
}
|
54
54
|
|
55
55
|
static int set_n_table_columns(cmark_node *node, uint16_t n_columns) {
|
56
56
|
if (!node || node->type != CMARK_NODE_TABLE)
|
57
57
|
return 0;
|
58
58
|
|
59
|
-
((node_table *)node->
|
59
|
+
((node_table *)node->as.opaque)->n_columns = n_columns;
|
60
60
|
return 1;
|
61
61
|
}
|
62
62
|
|
@@ -64,14 +64,14 @@ static uint8_t *get_table_alignments(cmark_node *node) {
|
|
64
64
|
if (!node || node->type != CMARK_NODE_TABLE)
|
65
65
|
return 0;
|
66
66
|
|
67
|
-
return ((node_table *)node->
|
67
|
+
return ((node_table *)node->as.opaque)->alignments;
|
68
68
|
}
|
69
69
|
|
70
70
|
static int set_table_alignments(cmark_node *node, uint8_t *alignments) {
|
71
71
|
if (!node || node->type != CMARK_NODE_TABLE)
|
72
72
|
return 0;
|
73
73
|
|
74
|
-
((node_table *)node->
|
74
|
+
((node_table *)node->as.opaque)->alignments = alignments;
|
75
75
|
return 1;
|
76
76
|
}
|
77
77
|
|
@@ -79,7 +79,7 @@ static int is_table_header(cmark_node *node, int is_table_header) {
|
|
79
79
|
if (!node || node->type != CMARK_NODE_TABLE_ROW)
|
80
80
|
return 0;
|
81
81
|
|
82
|
-
((node_table_row *)node->
|
82
|
+
((node_table_row *)node->as.opaque)->is_header = (is_table_header != 0);
|
83
83
|
return 1;
|
84
84
|
}
|
85
85
|
|
@@ -282,9 +282,7 @@ static cmark_node *try_opening_table_header(cmark_syntax_extension *self,
|
|
282
282
|
|
283
283
|
cmark_node_set_syntax_extension(parent_container, self);
|
284
284
|
|
285
|
-
|
286
|
-
parser->mem->calloc(1, sizeof(node_table)));
|
287
|
-
cmark_node_set_user_data_free_func(parent_container, free_node_table);
|
285
|
+
parent_container->as.opaque = parser->mem->calloc(1, sizeof(node_table));
|
288
286
|
|
289
287
|
set_n_table_columns(parent_container, header_row->n_columns);
|
290
288
|
|
@@ -320,9 +318,7 @@ static cmark_node *try_opening_table_header(cmark_syntax_extension *self,
|
|
320
318
|
cmark_parser_get_offset(parser));
|
321
319
|
cmark_node_set_syntax_extension(table_header, self);
|
322
320
|
|
323
|
-
|
324
|
-
parser->mem->calloc(1, sizeof(node_table_row)));
|
325
|
-
cmark_node_set_user_data_free_func(table_header, free_node_table_row);
|
321
|
+
table_header->as.opaque = parser->mem->calloc(1, sizeof(node_table_row));
|
326
322
|
is_table_header(table_header, true);
|
327
323
|
|
328
324
|
{
|
@@ -361,12 +357,10 @@ static cmark_node *try_opening_table_row(cmark_syntax_extension *self,
|
|
361
357
|
cmark_parser_get_offset(parser));
|
362
358
|
|
363
359
|
cmark_node_set_syntax_extension(table_row_block, self);
|
364
|
-
|
365
|
-
parser->mem->calloc(1, sizeof(node_table_row)));
|
366
|
-
cmark_node_set_user_data_free_func(table_row_block, free_node_table_row);
|
360
|
+
table_row_block->as.opaque = parser->mem->calloc(1, sizeof(node_table_row));
|
367
361
|
|
368
362
|
/* We don't advance the offset here */
|
369
|
-
nt = (node_table *)parent_container->
|
363
|
+
nt = (node_table *)parent_container->as.opaque;
|
370
364
|
if (nt->last_matched_row) {
|
371
365
|
row = nt->last_matched_row;
|
372
366
|
nt->last_matched_row = NULL;
|
@@ -431,7 +425,7 @@ static int matches(cmark_syntax_extension *self, cmark_parser *parser,
|
|
431
425
|
len - cmark_parser_get_first_nonspace(parser));
|
432
426
|
if (new_row && new_row->n_columns) {
|
433
427
|
res = 1;
|
434
|
-
nt = (node_table *)parent_container->
|
428
|
+
nt = (node_table *)parent_container->as.opaque;
|
435
429
|
free_table_row(parser->mem, nt->last_matched_row);
|
436
430
|
nt->last_matched_row = new_row;
|
437
431
|
} else
|
@@ -446,7 +440,7 @@ static const char *get_type_string(cmark_syntax_extension *ext,
|
|
446
440
|
if (node->type == CMARK_NODE_TABLE) {
|
447
441
|
return "table";
|
448
442
|
} else if (node->type == CMARK_NODE_TABLE_ROW) {
|
449
|
-
if (((node_table_row *)node->
|
443
|
+
if (((node_table_row *)node->as.opaque)->is_header)
|
450
444
|
return "table_header";
|
451
445
|
else
|
452
446
|
return "table_row";
|
@@ -495,12 +489,12 @@ static void commonmark_render(cmark_syntax_extension *extension,
|
|
495
489
|
renderer->out(renderer, " ", false, LITERAL);
|
496
490
|
} else {
|
497
491
|
renderer->out(renderer, " |", false, LITERAL);
|
498
|
-
if (((node_table_row *)node->parent->
|
492
|
+
if (((node_table_row *)node->parent->as.opaque)->is_header &&
|
499
493
|
!node->next) {
|
500
494
|
int i;
|
501
495
|
uint8_t *alignments = get_table_alignments(node->parent->parent);
|
502
496
|
uint16_t n_cols =
|
503
|
-
((node_table *)node->parent->parent->
|
497
|
+
((node_table *)node->parent->parent->as.opaque)->n_columns;
|
504
498
|
renderer->cr(renderer);
|
505
499
|
renderer->out(renderer, "|", false, LITERAL);
|
506
500
|
for (i = 0; i < n_cols; i++) {
|
@@ -535,7 +529,7 @@ static void latex_render(cmark_syntax_extension *extension,
|
|
535
529
|
renderer->cr(renderer);
|
536
530
|
renderer->out(renderer, "\\begin{tabular}{", false, LITERAL);
|
537
531
|
|
538
|
-
n_cols = ((node_table *)node->
|
532
|
+
n_cols = ((node_table *)node->as.opaque)->n_columns;
|
539
533
|
for (i = 0; i < n_cols; i++) {
|
540
534
|
switch(alignments[i]) {
|
541
535
|
case 0:
|
@@ -592,7 +586,7 @@ static void man_render(cmark_syntax_extension *extension,
|
|
592
586
|
renderer->out(renderer, "tab(@);", false, LITERAL);
|
593
587
|
renderer->cr(renderer);
|
594
588
|
|
595
|
-
n_cols = ((node_table *)node->
|
589
|
+
n_cols = ((node_table *)node->as.opaque)->n_columns;
|
596
590
|
|
597
591
|
for (i = 0; i < n_cols; i++) {
|
598
592
|
switch (alignments[i]) {
|
@@ -662,7 +656,7 @@ static void html_render(cmark_syntax_extension *extension,
|
|
662
656
|
} else if (node->type == CMARK_NODE_TABLE_ROW) {
|
663
657
|
if (entering) {
|
664
658
|
cmark_html_render_cr(html);
|
665
|
-
if (((node_table_row *)node->
|
659
|
+
if (((node_table_row *)node->as.opaque)->is_header) {
|
666
660
|
table_state->in_table_header = 1;
|
667
661
|
cmark_strbuf_puts(html, "<thead>");
|
668
662
|
cmark_html_render_cr(html);
|
@@ -673,7 +667,7 @@ static void html_render(cmark_syntax_extension *extension,
|
|
673
667
|
} else {
|
674
668
|
cmark_html_render_cr(html);
|
675
669
|
cmark_strbuf_puts(html, "</tr>");
|
676
|
-
if (((node_table_row *)node->
|
670
|
+
if (((node_table_row *)node->as.opaque)->is_header) {
|
677
671
|
cmark_html_render_cr(html);
|
678
672
|
cmark_strbuf_puts(html, "</thead>");
|
679
673
|
cmark_html_render_cr(html);
|
@@ -717,6 +711,14 @@ static void html_render(cmark_syntax_extension *extension,
|
|
717
711
|
}
|
718
712
|
}
|
719
713
|
|
714
|
+
static void opaque_free(cmark_syntax_extension *ext, cmark_mem *mem, cmark_node *node) {
|
715
|
+
if (node->type == CMARK_NODE_TABLE) {
|
716
|
+
free_node_table(mem, node->as.opaque);
|
717
|
+
} else if (node->type == CMARK_NODE_TABLE_ROW) {
|
718
|
+
free_node_table_row(mem, node->as.opaque);
|
719
|
+
}
|
720
|
+
}
|
721
|
+
|
720
722
|
cmark_syntax_extension *create_table_extension(void) {
|
721
723
|
cmark_syntax_extension *ext = cmark_syntax_extension_new("table");
|
722
724
|
|
@@ -729,6 +731,7 @@ cmark_syntax_extension *create_table_extension(void) {
|
|
729
731
|
cmark_syntax_extension_set_latex_render_func(ext, latex_render);
|
730
732
|
cmark_syntax_extension_set_man_render_func(ext, man_render);
|
731
733
|
cmark_syntax_extension_set_html_render_func(ext, html_render);
|
734
|
+
cmark_syntax_extension_set_opaque_free_func(ext, opaque_free);
|
732
735
|
CMARK_NODE_TABLE = cmark_syntax_extension_add_node(0);
|
733
736
|
CMARK_NODE_TABLE_ROW = cmark_syntax_extension_add_node(0);
|
734
737
|
CMARK_NODE_TABLE_CELL = cmark_syntax_extension_add_node(0);
|
@@ -249,6 +249,10 @@ typedef cmark_node *(*cmark_postprocess_func) (cmark_syntax_extension *extension
|
|
249
249
|
|
250
250
|
typedef int (*cmark_ispunct_func) (char c);
|
251
251
|
|
252
|
+
typedef void (*cmark_opaque_free_func) (cmark_syntax_extension *extension,
|
253
|
+
cmark_mem *mem,
|
254
|
+
cmark_node *node);
|
255
|
+
|
252
256
|
/** Free a cmark_syntax_extension.
|
253
257
|
*/
|
254
258
|
CMARK_EXPORT
|
@@ -356,7 +360,13 @@ void cmark_syntax_extension_set_postprocess_func(cmark_syntax_extension *extensi
|
|
356
360
|
/** See the documentation for 'cmark_syntax_extension'
|
357
361
|
*/
|
358
362
|
CMARK_EXPORT
|
359
|
-
void
|
363
|
+
void cmark_syntax_extension_set_opaque_free_func(cmark_syntax_extension *extension,
|
364
|
+
cmark_opaque_free_func func);
|
365
|
+
|
366
|
+
/** See the documentation for 'cmark_syntax_extension'
|
367
|
+
*/
|
368
|
+
CMARK_EXPORT
|
369
|
+
void cmark_parser_set_backslash_ispunct_func(cmark_parser *parser,
|
360
370
|
cmark_ispunct_func func);
|
361
371
|
|
362
372
|
/** Return the index of the line currently being parsed, starting with 1.
|
@@ -134,6 +134,9 @@ static void S_free_nodes(cmark_node *e) {
|
|
134
134
|
if (e->user_data && e->user_data_free_func)
|
135
135
|
e->user_data_free_func(NODE_MEM(e), e->user_data);
|
136
136
|
|
137
|
+
if (e->as.opaque && e->extension && e->extension->opaque_free_func)
|
138
|
+
e->extension->opaque_free_func(e->extension, NODE_MEM(e), e);
|
139
|
+
|
137
140
|
free_node_as(e);
|
138
141
|
|
139
142
|
if (e->last_child) {
|
@@ -112,3 +112,8 @@ void cmark_syntax_extension_set_private(cmark_syntax_extension *extension,
|
|
112
112
|
extension->priv = priv;
|
113
113
|
extension->free_function = free_func;
|
114
114
|
}
|
115
|
+
|
116
|
+
void cmark_syntax_extension_set_opaque_free_func(cmark_syntax_extension *extension,
|
117
|
+
cmark_opaque_free_func func) {
|
118
|
+
extension->opaque_free_func = func;
|
119
|
+
}
|
@@ -329,6 +329,7 @@ static VALUE rb_node_get_type(VALUE self) {
|
|
329
329
|
int node_type;
|
330
330
|
cmark_node *node;
|
331
331
|
VALUE symbol;
|
332
|
+
const char *s;
|
332
333
|
|
333
334
|
Data_Get_Struct(self, cmark_node, node);
|
334
335
|
|
@@ -391,6 +392,10 @@ static VALUE rb_node_get_type(VALUE self) {
|
|
391
392
|
symbol = sym_image;
|
392
393
|
break;
|
393
394
|
default:
|
395
|
+
if (node->extension) {
|
396
|
+
s = node->extension->get_type_string_func(node->extension, node);
|
397
|
+
return ID2SYM(rb_intern(s));
|
398
|
+
}
|
394
399
|
rb_raise(rb_mNodeError, "invalid node type %d", node_type);
|
395
400
|
}
|
396
401
|
|
@@ -137,5 +137,23 @@ module CommonMarker
|
|
137
137
|
def softbreak(_)
|
138
138
|
out("\n")
|
139
139
|
end
|
140
|
+
|
141
|
+
def table(_)
|
142
|
+
out('<table>', :children, '</tbody></table>')
|
143
|
+
end
|
144
|
+
|
145
|
+
def table_header(_)
|
146
|
+
@in_header = true
|
147
|
+
out('<thead>', :children, '</thead><tbody>')
|
148
|
+
@in_header = false
|
149
|
+
end
|
150
|
+
|
151
|
+
def table_row(_)
|
152
|
+
out('<tr>', :children, '</tr>')
|
153
|
+
end
|
154
|
+
|
155
|
+
def table_cell(_)
|
156
|
+
out(@in_header ? '<th>' : '<td>', :children, @in_header ? '</th>' : '</td>')
|
157
|
+
end
|
140
158
|
end
|
141
159
|
end
|
data/lib/commonmarker/version.rb
CHANGED
data/test/test_extensions.rb
CHANGED
@@ -40,6 +40,23 @@ Another extension:
|
|
40
40
|
refute out.include?("| <strong>x</strong>")
|
41
41
|
refute out.include?("~~hi~~")
|
42
42
|
end
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_extensions_with_renderers
|
47
|
+
doc = CommonMarker.render_doc(@markdown, :default, %i[table])
|
48
|
+
|
49
|
+
doc.to_html.tap do |out|
|
50
|
+
refute out.include?("| a")
|
51
|
+
%w(<table> <tr> <th> a </th> <td> c </td> <strong>x</strong>).each {|html| assert out.include?(html) }
|
52
|
+
assert out.include?("~~hi~~")
|
53
|
+
end
|
54
|
+
|
55
|
+
HtmlRenderer.new.render(doc).tap do |out|
|
56
|
+
refute out.include?("| a")
|
57
|
+
%w(<table> <tr> <th> a </th> <td> c </td> <strong>x</strong>).each {|html| assert out.include?(html) }
|
58
|
+
assert out.include?("~~hi~~")
|
59
|
+
end
|
43
60
|
end
|
44
61
|
|
45
62
|
def test_bad_extension_specifications
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: commonmarker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.14.
|
4
|
+
version: 0.14.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Garen Torikian
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-02-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ruby-enum
|
@@ -164,130 +164,6 @@ files:
|
|
164
164
|
- ext/commonmarker/cmark/bench/statistics.py
|
165
165
|
- ext/commonmarker/cmark/bench/stats.py
|
166
166
|
- ext/commonmarker/cmark/benchmarks.md
|
167
|
-
- ext/commonmarker/cmark/build/CMakeCache.txt
|
168
|
-
- ext/commonmarker/cmark/build/CMakeFiles/3.7.2/CMakeCCompiler.cmake
|
169
|
-
- ext/commonmarker/cmark/build/CMakeFiles/3.7.2/CMakeCXXCompiler.cmake
|
170
|
-
- ext/commonmarker/cmark/build/CMakeFiles/3.7.2/CMakeDetermineCompilerABI_C.bin
|
171
|
-
- ext/commonmarker/cmark/build/CMakeFiles/3.7.2/CMakeDetermineCompilerABI_CXX.bin
|
172
|
-
- ext/commonmarker/cmark/build/CMakeFiles/3.7.2/CMakeSystem.cmake
|
173
|
-
- ext/commonmarker/cmark/build/CMakeFiles/3.7.2/CompilerIdC/CMakeCCompilerId.c
|
174
|
-
- ext/commonmarker/cmark/build/CMakeFiles/3.7.2/CompilerIdC/a.out
|
175
|
-
- ext/commonmarker/cmark/build/CMakeFiles/3.7.2/CompilerIdCXX/CMakeCXXCompilerId.cpp
|
176
|
-
- ext/commonmarker/cmark/build/CMakeFiles/3.7.2/CompilerIdCXX/a.out
|
177
|
-
- ext/commonmarker/cmark/build/CMakeFiles/CMakeDirectoryInformation.cmake
|
178
|
-
- ext/commonmarker/cmark/build/CMakeFiles/CMakeError.log
|
179
|
-
- ext/commonmarker/cmark/build/CMakeFiles/CMakeOutput.log
|
180
|
-
- ext/commonmarker/cmark/build/CMakeFiles/Makefile.cmake
|
181
|
-
- ext/commonmarker/cmark/build/CMakeFiles/Makefile2
|
182
|
-
- ext/commonmarker/cmark/build/CMakeFiles/TargetDirectories.txt
|
183
|
-
- ext/commonmarker/cmark/build/CMakeFiles/cmake.check_cache
|
184
|
-
- ext/commonmarker/cmark/build/CMakeFiles/feature_tests.bin
|
185
|
-
- ext/commonmarker/cmark/build/CMakeFiles/feature_tests.c
|
186
|
-
- ext/commonmarker/cmark/build/CMakeFiles/feature_tests.cxx
|
187
|
-
- ext/commonmarker/cmark/build/CMakeFiles/progress.marks
|
188
|
-
- ext/commonmarker/cmark/build/CTestTestfile.cmake
|
189
|
-
- ext/commonmarker/cmark/build/Makefile
|
190
|
-
- ext/commonmarker/cmark/build/api_test/CMakeFiles/CMakeDirectoryInformation.cmake
|
191
|
-
- ext/commonmarker/cmark/build/api_test/CMakeFiles/api_test.dir/DependInfo.cmake
|
192
|
-
- ext/commonmarker/cmark/build/api_test/CMakeFiles/api_test.dir/build.make
|
193
|
-
- ext/commonmarker/cmark/build/api_test/CMakeFiles/api_test.dir/cmake_clean.cmake
|
194
|
-
- ext/commonmarker/cmark/build/api_test/CMakeFiles/api_test.dir/depend.make
|
195
|
-
- ext/commonmarker/cmark/build/api_test/CMakeFiles/api_test.dir/flags.make
|
196
|
-
- ext/commonmarker/cmark/build/api_test/CMakeFiles/api_test.dir/link.txt
|
197
|
-
- ext/commonmarker/cmark/build/api_test/CMakeFiles/api_test.dir/progress.make
|
198
|
-
- ext/commonmarker/cmark/build/api_test/CMakeFiles/progress.marks
|
199
|
-
- ext/commonmarker/cmark/build/api_test/Makefile
|
200
|
-
- ext/commonmarker/cmark/build/api_test/cmake_install.cmake
|
201
|
-
- ext/commonmarker/cmark/build/cmake_install.cmake
|
202
|
-
- ext/commonmarker/cmark/build/extensions/CMakeFiles/CMakeDirectoryInformation.cmake
|
203
|
-
- ext/commonmarker/cmark/build/extensions/CMakeFiles/libcmarkextensions_static.dir/C.includecache
|
204
|
-
- ext/commonmarker/cmark/build/extensions/CMakeFiles/libcmarkextensions_static.dir/DependInfo.cmake
|
205
|
-
- ext/commonmarker/cmark/build/extensions/CMakeFiles/libcmarkextensions_static.dir/autolink.c.o
|
206
|
-
- ext/commonmarker/cmark/build/extensions/CMakeFiles/libcmarkextensions_static.dir/build.make
|
207
|
-
- ext/commonmarker/cmark/build/extensions/CMakeFiles/libcmarkextensions_static.dir/cmake_clean.cmake
|
208
|
-
- ext/commonmarker/cmark/build/extensions/CMakeFiles/libcmarkextensions_static.dir/cmake_clean_target.cmake
|
209
|
-
- ext/commonmarker/cmark/build/extensions/CMakeFiles/libcmarkextensions_static.dir/core-extensions.c.o
|
210
|
-
- ext/commonmarker/cmark/build/extensions/CMakeFiles/libcmarkextensions_static.dir/depend.internal
|
211
|
-
- ext/commonmarker/cmark/build/extensions/CMakeFiles/libcmarkextensions_static.dir/depend.make
|
212
|
-
- ext/commonmarker/cmark/build/extensions/CMakeFiles/libcmarkextensions_static.dir/ext_scanners.c.o
|
213
|
-
- ext/commonmarker/cmark/build/extensions/CMakeFiles/libcmarkextensions_static.dir/flags.make
|
214
|
-
- ext/commonmarker/cmark/build/extensions/CMakeFiles/libcmarkextensions_static.dir/link.txt
|
215
|
-
- ext/commonmarker/cmark/build/extensions/CMakeFiles/libcmarkextensions_static.dir/progress.make
|
216
|
-
- ext/commonmarker/cmark/build/extensions/CMakeFiles/libcmarkextensions_static.dir/strikethrough.c.o
|
217
|
-
- ext/commonmarker/cmark/build/extensions/CMakeFiles/libcmarkextensions_static.dir/table.c.o
|
218
|
-
- ext/commonmarker/cmark/build/extensions/CMakeFiles/libcmarkextensions_static.dir/tagfilter.c.o
|
219
|
-
- ext/commonmarker/cmark/build/extensions/CMakeFiles/progress.marks
|
220
|
-
- ext/commonmarker/cmark/build/extensions/Makefile
|
221
|
-
- ext/commonmarker/cmark/build/extensions/cmake_install.cmake
|
222
|
-
- ext/commonmarker/cmark/build/extensions/libcmarkextensions.a
|
223
|
-
- ext/commonmarker/cmark/build/man/CMakeFiles/CMakeDirectoryInformation.cmake
|
224
|
-
- ext/commonmarker/cmark/build/man/CMakeFiles/progress.marks
|
225
|
-
- ext/commonmarker/cmark/build/man/Makefile
|
226
|
-
- ext/commonmarker/cmark/build/man/cmake_install.cmake
|
227
|
-
- ext/commonmarker/cmark/build/src/CMakeFiles/CMakeDirectoryInformation.cmake
|
228
|
-
- ext/commonmarker/cmark/build/src/CMakeFiles/Export/lib/cmake/cmark-release.cmake
|
229
|
-
- ext/commonmarker/cmark/build/src/CMakeFiles/Export/lib/cmake/cmark.cmake
|
230
|
-
- ext/commonmarker/cmark/build/src/CMakeFiles/cmark.dir/DependInfo.cmake
|
231
|
-
- ext/commonmarker/cmark/build/src/CMakeFiles/cmark.dir/build.make
|
232
|
-
- ext/commonmarker/cmark/build/src/CMakeFiles/cmark.dir/cmake_clean.cmake
|
233
|
-
- ext/commonmarker/cmark/build/src/CMakeFiles/cmark.dir/depend.make
|
234
|
-
- ext/commonmarker/cmark/build/src/CMakeFiles/cmark.dir/flags.make
|
235
|
-
- ext/commonmarker/cmark/build/src/CMakeFiles/cmark.dir/link.txt
|
236
|
-
- ext/commonmarker/cmark/build/src/CMakeFiles/cmark.dir/progress.make
|
237
|
-
- ext/commonmarker/cmark/build/src/CMakeFiles/libcmark.dir/DependInfo.cmake
|
238
|
-
- ext/commonmarker/cmark/build/src/CMakeFiles/libcmark.dir/build.make
|
239
|
-
- ext/commonmarker/cmark/build/src/CMakeFiles/libcmark.dir/cmake_clean.cmake
|
240
|
-
- ext/commonmarker/cmark/build/src/CMakeFiles/libcmark.dir/depend.make
|
241
|
-
- ext/commonmarker/cmark/build/src/CMakeFiles/libcmark.dir/flags.make
|
242
|
-
- ext/commonmarker/cmark/build/src/CMakeFiles/libcmark.dir/link.txt
|
243
|
-
- ext/commonmarker/cmark/build/src/CMakeFiles/libcmark.dir/progress.make
|
244
|
-
- ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/C.includecache
|
245
|
-
- ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/DependInfo.cmake
|
246
|
-
- ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/arena.c.o
|
247
|
-
- ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/blocks.c.o
|
248
|
-
- ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/buffer.c.o
|
249
|
-
- ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/build.make
|
250
|
-
- ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/cmake_clean.cmake
|
251
|
-
- ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/cmake_clean_target.cmake
|
252
|
-
- ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/cmark.c.o
|
253
|
-
- ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/cmark_ctype.c.o
|
254
|
-
- ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/commonmark.c.o
|
255
|
-
- ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/depend.internal
|
256
|
-
- ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/depend.make
|
257
|
-
- ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/flags.make
|
258
|
-
- ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/houdini_href_e.c.o
|
259
|
-
- ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/houdini_html_e.c.o
|
260
|
-
- ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/houdini_html_u.c.o
|
261
|
-
- ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/html.c.o
|
262
|
-
- ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/inlines.c.o
|
263
|
-
- ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/iterator.c.o
|
264
|
-
- ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/latex.c.o
|
265
|
-
- ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/link.txt
|
266
|
-
- ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/linked_list.c.o
|
267
|
-
- ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/man.c.o
|
268
|
-
- ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/node.c.o
|
269
|
-
- ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/plugin.c.o
|
270
|
-
- ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/progress.make
|
271
|
-
- ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/references.c.o
|
272
|
-
- ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/registry.c.o
|
273
|
-
- ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/render.c.o
|
274
|
-
- ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/scanners.c.o
|
275
|
-
- ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/syntax_extension.c.o
|
276
|
-
- ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/utf8.c.o
|
277
|
-
- ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/xml.c.o
|
278
|
-
- ext/commonmarker/cmark/build/src/CMakeFiles/progress.marks
|
279
|
-
- ext/commonmarker/cmark/build/src/Makefile
|
280
|
-
- ext/commonmarker/cmark/build/src/cmake_install.cmake
|
281
|
-
- ext/commonmarker/cmark/build/src/cmark_export.h
|
282
|
-
- ext/commonmarker/cmark/build/src/cmark_version.h
|
283
|
-
- ext/commonmarker/cmark/build/src/config.h
|
284
|
-
- ext/commonmarker/cmark/build/src/libcmark.a
|
285
|
-
- ext/commonmarker/cmark/build/src/libcmark.pc
|
286
|
-
- ext/commonmarker/cmark/build/testdir/CMakeFiles/CMakeDirectoryInformation.cmake
|
287
|
-
- ext/commonmarker/cmark/build/testdir/CMakeFiles/progress.marks
|
288
|
-
- ext/commonmarker/cmark/build/testdir/CTestTestfile.cmake
|
289
|
-
- ext/commonmarker/cmark/build/testdir/Makefile
|
290
|
-
- ext/commonmarker/cmark/build/testdir/cmake_install.cmake
|
291
167
|
- ext/commonmarker/cmark/changelog.txt
|
292
168
|
- ext/commonmarker/cmark/data/CaseFolding.txt
|
293
169
|
- ext/commonmarker/cmark/extensions/CMakeLists.txt
|