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
@@ -8,12 +8,12 @@
8
8
  extern "C" {
9
9
  #endif
10
10
 
11
- void utf8proc_case_fold(cmark_strbuf *dest, const uint8_t *str, bufsize_t len);
12
- void utf8proc_encode_char(int32_t uc, cmark_strbuf *buf);
13
- int utf8proc_iterate(const uint8_t *str, bufsize_t str_len, int32_t *dst);
14
- void utf8proc_check(cmark_strbuf *dest, const uint8_t *line, bufsize_t size);
15
- int utf8proc_is_space(int32_t uc);
16
- int utf8proc_is_punctuation(int32_t uc);
11
+ void cmark_utf8proc_case_fold(cmark_strbuf *dest, const uint8_t *str, bufsize_t len);
12
+ void cmark_utf8proc_encode_char(int32_t uc, cmark_strbuf *buf);
13
+ int cmark_utf8proc_iterate(const uint8_t *str, bufsize_t str_len, int32_t *dst);
14
+ void cmark_utf8proc_check(cmark_strbuf *dest, const uint8_t *line, bufsize_t size);
15
+ int cmark_utf8proc_is_space(int32_t uc);
16
+ int cmark_utf8proc_is_punctuation(int32_t uc);
17
17
 
18
18
  #ifdef __cplusplus
19
19
  }
@@ -11,157 +11,142 @@
11
11
 
12
12
  // Functions to convert cmark_nodes to XML strings.
13
13
 
14
- static void escape_xml(cmark_strbuf *dest, const unsigned char *source, bufsize_t length)
15
- {
16
- houdini_escape_html0(dest, source, length, 0);
14
+ static void escape_xml(cmark_strbuf *dest, const unsigned char *source,
15
+ bufsize_t length) {
16
+ houdini_escape_html0(dest, source, length, 0);
17
17
  }
18
18
 
19
19
  struct render_state {
20
- cmark_strbuf* xml;
21
- int indent;
20
+ cmark_strbuf *xml;
21
+ int indent;
22
22
  };
23
23
 
24
- static inline void indent(struct render_state *state)
25
- {
26
- int i;
27
- for (i = 0; i < state->indent; i++) {
28
- cmark_strbuf_putc(state->xml, ' ');
29
- }
24
+ static inline void indent(struct render_state *state) {
25
+ int i;
26
+ for (i = 0; i < state->indent; i++) {
27
+ cmark_strbuf_putc(state->xml, ' ');
28
+ }
30
29
  }
31
30
 
32
- static int
33
- S_render_node(cmark_node *node, cmark_event_type ev_type,
34
- struct render_state *state, int options)
35
- {
36
- cmark_strbuf *xml = state->xml;
37
- bool literal = false;
38
- cmark_delim_type delim;
39
- bool entering = (ev_type == CMARK_EVENT_ENTER);
40
-
41
- if (entering) {
42
- indent(state);
43
- cmark_strbuf_printf(xml, "<%s",
44
- cmark_node_get_type_string(node));
45
-
46
- if (options & CMARK_OPT_SOURCEPOS && node->start_line != 0) {
47
- cmark_strbuf_printf(xml, " sourcepos=\"%d:%d-%d:%d\"",
48
- node->start_line,
49
- node->start_column,
50
- node->end_line,
51
- node->end_column);
52
- }
53
-
54
- literal = false;
55
-
56
- switch (node->type) {
57
- case CMARK_NODE_TEXT:
58
- case CMARK_NODE_CODE:
59
- case CMARK_NODE_HTML:
60
- case CMARK_NODE_INLINE_HTML:
61
- cmark_strbuf_puts(xml, ">");
62
- escape_xml(xml, node->as.literal.data,
63
- node->as.literal.len);
64
- cmark_strbuf_puts(xml, "</");
65
- cmark_strbuf_puts(xml,
66
- cmark_node_get_type_string(node));
67
- literal = true;
68
- break;
69
- case CMARK_NODE_LIST:
70
- switch (cmark_node_get_list_type(node)) {
71
- case CMARK_ORDERED_LIST:
72
- cmark_strbuf_puts(xml, " type=\"ordered\"");
73
- cmark_strbuf_printf(xml, " start=\"%d\"",
74
- cmark_node_get_list_start(node));
75
- delim = cmark_node_get_list_delim(node);
76
- if (delim == CMARK_PAREN_DELIM) {
77
- cmark_strbuf_puts(xml,
78
- " delim=\"paren\"");
79
- } else if (delim == CMARK_PERIOD_DELIM) {
80
- cmark_strbuf_puts(xml,
81
- " delim=\"period\"");
82
- }
83
- break;
84
- case CMARK_BULLET_LIST:
85
- cmark_strbuf_puts(xml, " type=\"bullet\"");
86
- break;
87
- default:
88
- break;
89
- }
90
- cmark_strbuf_printf(xml, " tight=\"%s\"",
91
- (cmark_node_get_list_tight(node) ?
92
- "true" : "false"));
93
- break;
94
- case CMARK_NODE_HEADER:
95
- cmark_strbuf_printf(xml, " level=\"%d\"",
96
- node->as.header.level);
97
- break;
98
- case CMARK_NODE_CODE_BLOCK:
99
- if (node->as.code.info.len > 0) {
100
- cmark_strbuf_puts(xml, " info=\"");
101
- escape_xml(xml, node->as.code.info.data,
102
- node->as.code.info.len);
103
- cmark_strbuf_putc(xml, '"');
104
- }
105
- cmark_strbuf_puts(xml, ">");
106
- escape_xml(xml, node->as.code.literal.data,
107
- node->as.code.literal.len);
108
- cmark_strbuf_puts(xml, "</");
109
- cmark_strbuf_puts(xml,
110
- cmark_node_get_type_string(node));
111
- literal = true;
112
- break;
113
- case CMARK_NODE_LINK:
114
- case CMARK_NODE_IMAGE:
115
- cmark_strbuf_puts(xml, " destination=\"");
116
- escape_xml(xml, node->as.link.url.data,
117
- node->as.link.url.len);
118
- cmark_strbuf_putc(xml, '"');
119
- cmark_strbuf_puts(xml, " title=\"");
120
- escape_xml(xml, node->as.link.title.data,
121
- node->as.link.title.len);
122
- cmark_strbuf_putc(xml, '"');
123
- break;
124
- default:
125
- break;
126
- }
127
- if (node->first_child) {
128
- state->indent += 2;
129
- } else if (!literal) {
130
- cmark_strbuf_puts(xml, " /");
131
- }
132
- cmark_strbuf_puts(xml, ">\n");
133
-
134
-
135
- } else if (node->first_child) {
136
- state->indent -= 2;
137
- indent(state);
138
- cmark_strbuf_printf(xml, "</%s>\n",
139
- cmark_node_get_type_string(node));
140
- }
141
-
142
- return 1;
31
+ static int S_render_node(cmark_node *node, cmark_event_type ev_type,
32
+ struct render_state *state, int options) {
33
+ cmark_strbuf *xml = state->xml;
34
+ bool literal = false;
35
+ cmark_delim_type delim;
36
+ bool entering = (ev_type == CMARK_EVENT_ENTER);
37
+ char buffer[100];
38
+
39
+ if (entering) {
40
+ indent(state);
41
+ cmark_strbuf_putc(xml, '<');
42
+ cmark_strbuf_puts(xml, cmark_node_get_type_string(node));
43
+
44
+ if (options & CMARK_OPT_SOURCEPOS && node->start_line != 0) {
45
+ sprintf(buffer, " sourcepos=\"%d:%d-%d:%d\"", node->start_line,
46
+ node->start_column, node->end_line, node->end_column);
47
+ cmark_strbuf_puts(xml, buffer);
48
+ }
49
+
50
+ literal = false;
51
+
52
+ switch (node->type) {
53
+ case CMARK_NODE_TEXT:
54
+ case CMARK_NODE_CODE:
55
+ case CMARK_NODE_HTML:
56
+ case CMARK_NODE_INLINE_HTML:
57
+ cmark_strbuf_puts(xml, ">");
58
+ escape_xml(xml, node->as.literal.data, node->as.literal.len);
59
+ cmark_strbuf_puts(xml, "</");
60
+ cmark_strbuf_puts(xml, cmark_node_get_type_string(node));
61
+ literal = true;
62
+ break;
63
+ case CMARK_NODE_LIST:
64
+ switch (cmark_node_get_list_type(node)) {
65
+ case CMARK_ORDERED_LIST:
66
+ cmark_strbuf_puts(xml, " type=\"ordered\"");
67
+ sprintf(buffer, " start=\"%d\"", cmark_node_get_list_start(node));
68
+ cmark_strbuf_puts(xml, buffer);
69
+ delim = cmark_node_get_list_delim(node);
70
+ if (delim == CMARK_PAREN_DELIM) {
71
+ cmark_strbuf_puts(xml, " delim=\"paren\"");
72
+ } else if (delim == CMARK_PERIOD_DELIM) {
73
+ cmark_strbuf_puts(xml, " delim=\"period\"");
74
+ }
75
+ break;
76
+ case CMARK_BULLET_LIST:
77
+ cmark_strbuf_puts(xml, " type=\"bullet\"");
78
+ break;
79
+ default:
80
+ break;
81
+ }
82
+ sprintf(buffer, " tight=\"%s\"",
83
+ (cmark_node_get_list_tight(node) ? "true" : "false"));
84
+ cmark_strbuf_puts(xml, buffer);
85
+ break;
86
+ case CMARK_NODE_HEADER:
87
+ sprintf(buffer, " level=\"%d\"", node->as.header.level);
88
+ cmark_strbuf_puts(xml, buffer);
89
+ break;
90
+ case CMARK_NODE_CODE_BLOCK:
91
+ if (node->as.code.info.len > 0) {
92
+ cmark_strbuf_puts(xml, " info=\"");
93
+ escape_xml(xml, node->as.code.info.data, node->as.code.info.len);
94
+ cmark_strbuf_putc(xml, '"');
95
+ }
96
+ cmark_strbuf_puts(xml, ">");
97
+ escape_xml(xml, node->as.code.literal.data, node->as.code.literal.len);
98
+ cmark_strbuf_puts(xml, "</");
99
+ cmark_strbuf_puts(xml, cmark_node_get_type_string(node));
100
+ literal = true;
101
+ break;
102
+ case CMARK_NODE_LINK:
103
+ case CMARK_NODE_IMAGE:
104
+ cmark_strbuf_puts(xml, " destination=\"");
105
+ escape_xml(xml, node->as.link.url.data, node->as.link.url.len);
106
+ cmark_strbuf_putc(xml, '"');
107
+ cmark_strbuf_puts(xml, " title=\"");
108
+ escape_xml(xml, node->as.link.title.data, node->as.link.title.len);
109
+ cmark_strbuf_putc(xml, '"');
110
+ break;
111
+ default:
112
+ break;
113
+ }
114
+ if (node->first_child) {
115
+ state->indent += 2;
116
+ } else if (!literal) {
117
+ cmark_strbuf_puts(xml, " /");
118
+ }
119
+ cmark_strbuf_puts(xml, ">\n");
120
+
121
+ } else if (node->first_child) {
122
+ state->indent -= 2;
123
+ indent(state);
124
+ cmark_strbuf_puts(xml, "</");
125
+ cmark_strbuf_puts(xml, cmark_node_get_type_string(node));
126
+ cmark_strbuf_puts(xml, ">\n");
127
+ }
128
+
129
+ return 1;
143
130
  }
144
131
 
145
- char *cmark_render_xml(cmark_node *root, int options)
146
- {
147
- char *result;
148
- cmark_strbuf xml = GH_BUF_INIT;
149
- cmark_event_type ev_type;
150
- cmark_node *cur;
151
- struct render_state state = { &xml, 0 };
152
-
153
- cmark_iter *iter = cmark_iter_new(root);
154
-
155
- cmark_strbuf_puts(state.xml,
156
- "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
157
- cmark_strbuf_puts(state.xml,
158
- "<!DOCTYPE CommonMark SYSTEM \"CommonMark.dtd\">\n");
159
- while ((ev_type = cmark_iter_next(iter)) != CMARK_EVENT_DONE) {
160
- cur = cmark_iter_get_node(iter);
161
- S_render_node(cur, ev_type, &state, options);
162
- }
163
- result = (char *)cmark_strbuf_detach(&xml);
164
-
165
- cmark_iter_free(iter);
166
- return result;
132
+ char *cmark_render_xml(cmark_node *root, int options) {
133
+ char *result;
134
+ cmark_strbuf xml = GH_BUF_INIT;
135
+ cmark_event_type ev_type;
136
+ cmark_node *cur;
137
+ struct render_state state = {&xml, 0};
138
+
139
+ cmark_iter *iter = cmark_iter_new(root);
140
+
141
+ cmark_strbuf_puts(state.xml, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
142
+ cmark_strbuf_puts(state.xml,
143
+ "<!DOCTYPE CommonMark SYSTEM \"CommonMark.dtd\">\n");
144
+ while ((ev_type = cmark_iter_next(iter)) != CMARK_EVENT_DONE) {
145
+ cur = cmark_iter_get_node(iter);
146
+ S_render_node(cur, ev_type, &state, options);
147
+ }
148
+ result = (char *)cmark_strbuf_detach(&xml);
149
+
150
+ cmark_iter_free(iter);
151
+ return result;
167
152
  }
@@ -27,20 +27,20 @@ IF (PYTHONINTERP_FOUND)
27
27
 
28
28
  add_test(spectest_library
29
29
  ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/spec_tests.py" "--no-normalize" "--spec"
30
- "${CMAKE_SOURCE_DIR}/test/spec.txt" "--library-dir" "${CMAKE_BINARY_DIR}/src"
30
+ "${CMAKE_CURRENT_SOURCE_DIR}/spec.txt" "--library-dir" "${CMAKE_CURRENT_BINARY_DIR}/../src"
31
31
  )
32
32
 
33
33
  add_test(pathological_tests_library
34
34
  ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/pathological_tests.py"
35
- "--library-dir" "${CMAKE_BINARY_DIR}/src"
35
+ "--library-dir" "${CMAKE_CURRENT_BINARY_DIR}/../src"
36
36
  )
37
37
 
38
38
  add_test(spectest_executable
39
- ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/spec_tests.py" "--no-normalize" "--spec" "${CMAKE_SOURCE_DIR}/test/spec.txt" "--program" "${CMAKE_BINARY_DIR}/src/cmark"
39
+ ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/spec_tests.py" "--no-normalize" "--spec" "${CMAKE_CURRENT_SOURCE_DIR}/spec.txt" "--program" "${CMAKE_CURRENT_BINARY_DIR}/../src/cmark"
40
40
  )
41
41
 
42
42
  add_test(smartpuncttest_executable
43
- ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/spec_tests.py" "--no-normalize" "--spec" "${CMAKE_SOURCE_DIR}/test/smart_punct.txt" "--program" "${CMAKE_BINARY_DIR}/src/cmark --smart"
43
+ ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/spec_tests.py" "--no-normalize" "--spec" "${CMAKE_CURRENT_SOURCE_DIR}/smart_punct.txt" "--program" "${CMAKE_CURRENT_BINARY_DIR}/../src/cmark --smart"
44
44
  )
45
45
 
46
46
  ELSE(PYTHONINTERP_FOUND)
@@ -58,6 +58,14 @@ by the single quote before `jolly`:
58
58
  <p>’tis the season to be ‘jolly’</p>
59
59
  .
60
60
 
61
+ Multiple apostrophes should not be marked as open/closing quotes.
62
+
63
+ .
64
+ 'We'll use Jane's boat and John's truck,' Jenna said.
65
+ .
66
+ <p>‘We’ll use Jane’s boat and John’s truck,’ Jenna said.</p>
67
+ .
68
+
61
69
  An unmatched double quote will be interpreted as a
62
70
  left double quote, to facilitate this style:
63
71