commonmarker 0.5.1 → 0.6.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 (71) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +23 -17
  3. data/ext/commonmarker/cmark/CMakeLists.txt +1 -1
  4. data/ext/commonmarker/cmark/Makefile +13 -14
  5. data/ext/commonmarker/cmark/README.md +1 -0
  6. data/ext/commonmarker/cmark/api_test/cplusplus.h +1 -2
  7. data/ext/commonmarker/cmark/api_test/harness.c +60 -79
  8. data/ext/commonmarker/cmark/api_test/harness.h +13 -20
  9. data/ext/commonmarker/cmark/api_test/main.c +809 -714
  10. data/ext/commonmarker/cmark/build/CMakeCache.txt +3 -0
  11. data/ext/commonmarker/cmark/build/CMakeFiles/Makefile.cmake +0 -67
  12. data/ext/commonmarker/cmark/build/api_test/CMakeFiles/api_test.dir/build.make +1 -1
  13. data/ext/commonmarker/cmark/build/api_test/CMakeFiles/api_test.dir/link.txt +1 -1
  14. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark.dir/DependInfo.cmake +1 -1
  15. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark.dir/build.make +23 -23
  16. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark.dir/cmake_clean.cmake +1 -1
  17. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark.dir/link.txt +1 -1
  18. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/blocks.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/cmark_ctype.c.o +0 -0
  21. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/commonmark.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/iterator.c.o +0 -0
  25. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/latex.c.o +0 -0
  26. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/man.c.o +0 -0
  27. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/node.c.o +0 -0
  28. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/render.c.o +0 -0
  29. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/scanners.c.o +0 -0
  30. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/xml.c.o +0 -0
  31. data/ext/commonmarker/cmark/build/src/cmake_install.cmake +10 -2
  32. data/ext/commonmarker/cmark/build/src/cmark_version.h +2 -2
  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 +1 -0
  36. data/ext/commonmarker/cmark/changelog.txt +85 -0
  37. data/ext/commonmarker/cmark/man/man3/cmark.3 +75 -34
  38. data/ext/commonmarker/cmark/src/CMakeLists.txt +13 -8
  39. data/ext/commonmarker/cmark/src/blocks.c +78 -70
  40. data/ext/commonmarker/cmark/src/chunk.h +5 -7
  41. data/ext/commonmarker/cmark/src/cmark.h +88 -34
  42. data/ext/commonmarker/cmark/src/cmark_ctype.c +6 -6
  43. data/ext/commonmarker/cmark/src/commonmark.c +24 -8
  44. data/ext/commonmarker/cmark/src/houdini_html_u.c +6 -5
  45. data/ext/commonmarker/cmark/src/html.c +33 -11
  46. data/ext/commonmarker/cmark/src/inlines.c +9 -10
  47. data/ext/commonmarker/cmark/src/iterator.c +2 -2
  48. data/ext/commonmarker/cmark/src/latex.c +54 -28
  49. data/ext/commonmarker/cmark/src/main.c +0 -9
  50. data/ext/commonmarker/cmark/src/man.c +17 -5
  51. data/ext/commonmarker/cmark/src/node.c +123 -44
  52. data/ext/commonmarker/cmark/src/node.h +8 -2
  53. data/ext/commonmarker/cmark/src/render.c +8 -1
  54. data/ext/commonmarker/cmark/src/render.h +1 -0
  55. data/ext/commonmarker/cmark/src/scanners.c +3755 -4379
  56. data/ext/commonmarker/cmark/src/scanners.h +7 -6
  57. data/ext/commonmarker/cmark/src/scanners.re +9 -10
  58. data/ext/commonmarker/cmark/src/utf8.c +6 -3
  59. data/ext/commonmarker/cmark/src/utf8.h +4 -2
  60. data/ext/commonmarker/cmark/src/xml.c +18 -4
  61. data/ext/commonmarker/cmark/test/CMakeLists.txt +11 -0
  62. data/ext/commonmarker/cmark/test/normalize.py +5 -1
  63. data/ext/commonmarker/cmark/test/roundtrip.bat +1 -0
  64. data/ext/commonmarker/cmark/test/roundtrip.sh +1 -1
  65. data/ext/commonmarker/cmark/test/spec.txt +257 -157
  66. data/ext/commonmarker/cmark/why-cmark-and-not-x.md +104 -0
  67. data/lib/commonmarker/config.rb +6 -6
  68. data/lib/commonmarker/version.rb +1 -1
  69. metadata +5 -5
  70. data/ext/commonmarker/cmark/src/bench.h +0 -27
  71. data/ext/commonmarker/cmark/wrappers/wrapper.lua +0 -239
@@ -0,0 +1,104 @@
1
+ Why use `cmark` and not X?
2
+ ==========================
3
+
4
+ `hoedown`
5
+ ---------
6
+
7
+ `hoedown` (which derives from `sundown`) is slightly faster
8
+ than `cmark` in our benchmarks (0.21s vs. 0.29s). But both
9
+ are much faster than any other available implementations.
10
+
11
+ `hoedown` boasts of including "protection against all possible
12
+ DOS attacks," but there are some chinks in the armor:
13
+
14
+ % time python -c 'print(("[" * 50000) + "a" + ("]" * 50000))' | cmark
15
+ ...
16
+ user 0m0.073s
17
+ % time python -c 'print(("[" * 50000) + "a" + ("]" * 50000))' | hoedown
18
+ ...
19
+ 0m17.84s
20
+
21
+ `hoedown` has many parsing bugs. Here is a selection (as of
22
+ v3.0.3):
23
+
24
+ % hoedown
25
+ - one
26
+ - two
27
+ 1. three
28
+ ^D
29
+ <ul>
30
+ <li>one
31
+
32
+ <ul>
33
+ <li>two</li>
34
+ <li>three</li>
35
+ </ul></li>
36
+ </ul>
37
+
38
+
39
+ % hoedown
40
+ ## hi\###
41
+ ^D
42
+ <h2>hi\</h2>
43
+
44
+
45
+ % hoedown
46
+ [ΑΓΩ]: /φου
47
+
48
+ [αγω]
49
+ ^D
50
+ <p>[αγω]</p>
51
+
52
+
53
+ % hoedown
54
+ ```
55
+ [foo]: /url
56
+ ```
57
+
58
+ [foo]
59
+ ^D
60
+ <p>```</p>
61
+
62
+ <p>```</p>
63
+
64
+ <p><a href="/url">foo</a></p>
65
+
66
+
67
+ % hoedown
68
+ [foo](url "ti\*tle")
69
+ ^D
70
+ <p><a href="url" title="ti\*tle">foo</a></p>
71
+
72
+
73
+ % ./hoedown
74
+ - one
75
+ - two
76
+ - three
77
+ - four
78
+ ^D
79
+ <ul>
80
+ <li>one
81
+
82
+ <ul>
83
+ <li>two</li>
84
+ <li>three</li>
85
+ <li>four</li>
86
+ </ul></li>
87
+ </ul>
88
+
89
+
90
+ `discount`
91
+ ----------
92
+
93
+ `cmark` is about six times faster.
94
+
95
+ `kramdown`
96
+ ----------
97
+
98
+ `cmark` is about a hundred times faster.
99
+
100
+ `kramdown` also gets tied in knots by pathological input like
101
+
102
+ python -c 'print(("[" * 50000) + "a" + ("]" * 50000))'
103
+
104
+
@@ -6,18 +6,18 @@ module CommonMarker
6
6
  include Ruby::Enum
7
7
 
8
8
  define :default, 0
9
- define :normalize, 4
10
- define :validate_utf8, 16
11
- define :smart, 8
9
+ define :normalize, (1 << 8)
10
+ define :validate_utf8, (1 << 9)
11
+ define :smart, (1 << 10)
12
12
  end
13
13
 
14
14
  class Render
15
15
  include Ruby::Enum
16
16
 
17
17
  define :default, 0
18
- define :sourcepos, 1
19
- define :hardbreaks, 2
20
- define :safe, 32
18
+ define :sourcepos, (1 << 1)
19
+ define :hardbreaks, (1 << 2)
20
+ define :safe, (1 << 3)
21
21
  end
22
22
 
23
23
  def self.process_options(option, type)
@@ -1,3 +1,3 @@
1
1
  module CommonMarker
2
- VERSION = '0.5.1'
2
+ VERSION = '0.6.0'
3
3
  end
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.5.1
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Garen Torikian
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-04 00:00:00.000000000 Z
11
+ date: 2016-01-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ruby-enum
@@ -252,7 +252,6 @@ files:
252
252
  - ext/commonmarker/cmark/man/man3/cmark.3
253
253
  - ext/commonmarker/cmark/nmake.bat
254
254
  - ext/commonmarker/cmark/src/CMakeLists.txt
255
- - ext/commonmarker/cmark/src/bench.h
256
255
  - ext/commonmarker/cmark/src/blocks.c
257
256
  - ext/commonmarker/cmark/src/buffer.c
258
257
  - ext/commonmarker/cmark/src/buffer.h
@@ -348,6 +347,7 @@ files:
348
347
  - ext/commonmarker/cmark/test/cmark.py
349
348
  - ext/commonmarker/cmark/test/normalize.py
350
349
  - ext/commonmarker/cmark/test/pathological_tests.py
350
+ - ext/commonmarker/cmark/test/roundtrip.bat
351
351
  - ext/commonmarker/cmark/test/roundtrip.sh
352
352
  - ext/commonmarker/cmark/test/smart_punct.txt
353
353
  - ext/commonmarker/cmark/test/spec.txt
@@ -355,7 +355,7 @@ files:
355
355
  - ext/commonmarker/cmark/toolchain-mingw32.cmake
356
356
  - ext/commonmarker/cmark/tools/make_entities_inc.py
357
357
  - ext/commonmarker/cmark/tools/mkcasefold.pl
358
- - ext/commonmarker/cmark/wrappers/wrapper.lua
358
+ - ext/commonmarker/cmark/why-cmark-and-not-x.md
359
359
  - ext/commonmarker/cmark/wrappers/wrapper.py
360
360
  - ext/commonmarker/cmark/wrappers/wrapper.rb
361
361
  - ext/commonmarker/cmark/wrappers/wrapper.rkt
@@ -402,7 +402,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
402
402
  version: '0'
403
403
  requirements: []
404
404
  rubyforge_project:
405
- rubygems_version: 2.4.5
405
+ rubygems_version: 2.4.5.1
406
406
  signing_key:
407
407
  specification_version: 4
408
408
  summary: CommonMark parser and renderer. Written in C, wrapped in Ruby.
@@ -1,27 +0,0 @@
1
- #ifndef CMARK_BENCH_H
2
- #define CMARK_BENCH_H
3
-
4
- #include <stdio.h>
5
- #include <time.h>
6
-
7
- #ifdef TIMER
8
- float _cmark_start_time;
9
- float _cmark_end_time;
10
- float _cmark_save_time;
11
-
12
- #define start_timer() \
13
- _cmark_save_time = _cmark_start_time; \
14
- _cmark_start_time = (float)clock() / CLOCKS_PER_SEC
15
-
16
- #define end_timer(M) \
17
- _cmark_end_time = (float)clock() / CLOCKS_PER_SEC; \
18
- fprintf(stderr, "[TIME] (%s:%d) %4.f ns " M "\n", __FILE__, __LINE__, \
19
- (_cmark_end_time - _cmark_start_time) * 1000000); \
20
- _cmark_start_time = _cmark_save_time;
21
-
22
- #else
23
- #define start_timer()
24
- #define end_timer(M)
25
- #endif
26
-
27
- #endif
@@ -1,239 +0,0 @@
1
- #!/usr/bin/env luajit
2
-
3
- local ffi = require("ffi")
4
-
5
- cmark = ffi.load("libcmark")
6
-
7
- ffi.cdef[[
8
- char *cmark_markdown_to_html(const char *text, int len, int options);
9
-
10
- typedef enum {
11
- /* Error status */
12
- CMARK_NODE_NONE,
13
-
14
- /* Block */
15
- CMARK_NODE_DOCUMENT,
16
- CMARK_NODE_BLOCK_QUOTE,
17
- CMARK_NODE_LIST,
18
- CMARK_NODE_ITEM,
19
- CMARK_NODE_CODE_BLOCK,
20
- CMARK_NODE_HTML,
21
- CMARK_NODE_PARAGRAPH,
22
- CMARK_NODE_HEADER,
23
- CMARK_NODE_HRULE,
24
-
25
- CMARK_NODE_FIRST_BLOCK = CMARK_NODE_DOCUMENT,
26
- CMARK_NODE_LAST_BLOCK = CMARK_NODE_HRULE,
27
-
28
- /* Inline */
29
- CMARK_NODE_TEXT,
30
- CMARK_NODE_SOFTBREAK,
31
- CMARK_NODE_LINEBREAK,
32
- CMARK_NODE_CODE,
33
- CMARK_NODE_INLINE_HTML,
34
- CMARK_NODE_EMPH,
35
- CMARK_NODE_STRONG,
36
- CMARK_NODE_LINK,
37
- CMARK_NODE_IMAGE,
38
-
39
- CMARK_NODE_FIRST_INLINE = CMARK_NODE_TEXT,
40
- CMARK_NODE_LAST_INLINE = CMARK_NODE_IMAGE,
41
- } cmark_node_type;
42
-
43
-
44
- typedef enum {
45
- CMARK_NO_LIST,
46
- CMARK_BULLET_LIST,
47
- CMARK_ORDERED_LIST
48
- } cmark_list_type;
49
-
50
- typedef enum {
51
- CMARK_NO_DELIM,
52
- CMARK_PERIOD_DELIM,
53
- CMARK_PAREN_DELIM
54
- } cmark_delim_type;
55
-
56
- typedef struct cmark_node cmark_node;
57
- typedef struct cmark_parser cmark_parser;
58
- typedef struct cmark_iter cmark_iter;
59
-
60
- typedef enum {
61
- CMARK_EVENT_NONE,
62
- CMARK_EVENT_DONE,
63
- CMARK_EVENT_ENTER,
64
- CMARK_EVENT_EXIT
65
- } cmark_event_type;
66
-
67
- cmark_node*
68
- cmark_node_new(cmark_node_type type);
69
-
70
- void
71
- cmark_node_free(cmark_node *node);
72
-
73
- cmark_node*
74
- cmark_node_next(cmark_node *node);
75
-
76
- cmark_node*
77
- cmark_node_previous(cmark_node *node);
78
-
79
- cmark_node*
80
- cmark_node_parent(cmark_node *node);
81
-
82
- cmark_node*
83
- cmark_node_first_child(cmark_node *node);
84
-
85
- cmark_node*
86
- cmark_node_last_child(cmark_node *node);
87
-
88
- cmark_iter*
89
- cmark_iter_new(cmark_node *root);
90
-
91
- void
92
- cmark_iter_free(cmark_iter *iter);
93
-
94
- cmark_event_type
95
- cmark_iter_next(cmark_iter *iter);
96
-
97
- cmark_node*
98
- cmark_iter_get_node(cmark_iter *iter);
99
-
100
- cmark_event_type
101
- cmark_iter_get_event_type(cmark_iter *iter);
102
-
103
- cmark_node*
104
- cmark_iter_get_root(cmark_iter *iter);
105
-
106
- void
107
- cmark_iter_reset(cmark_iter *iter, cmark_node *current,
108
- cmark_event_type event_type);
109
-
110
- void*
111
- cmark_node_get_user_data(cmark_node *node);
112
-
113
- int
114
- cmark_node_set_user_data(cmark_node *node, void *user_data);
115
-
116
- cmark_node_type
117
- cmark_node_get_type(cmark_node *node);
118
-
119
- const char*
120
- cmark_node_get_type_string(cmark_node *node);
121
-
122
- const char*
123
- cmark_node_get_literal(cmark_node *node);
124
-
125
- int
126
- cmark_node_set_literal(cmark_node *node, const char *content);
127
-
128
- int
129
- cmark_node_get_header_level(cmark_node *node);
130
-
131
- int
132
- cmark_node_set_header_level(cmark_node *node, int level);
133
-
134
- cmark_list_type
135
- cmark_node_get_list_type(cmark_node *node);
136
-
137
- int
138
- cmark_node_set_list_type(cmark_node *node, cmark_list_type type);
139
-
140
- cmark_delim_type
141
- cmark_node_get_list_delim(cmark_node *node);
142
-
143
- int
144
- cmark_node_set_list_delim(cmark_node *node, cmark_delim_type delim);
145
-
146
- int
147
- cmark_node_get_list_start(cmark_node *node);
148
-
149
- int
150
- cmark_node_set_list_start(cmark_node *node, int start);
151
-
152
- int
153
- cmark_node_get_list_tight(cmark_node *node);
154
-
155
- int
156
- cmark_node_set_list_tight(cmark_node *node, int tight);
157
-
158
- const char*
159
- cmark_node_get_fence_info(cmark_node *node);
160
-
161
- int
162
- cmark_node_set_fence_info(cmark_node *node, const char *info);
163
-
164
- const char*
165
- cmark_node_get_url(cmark_node *node);
166
-
167
- int
168
- cmark_node_set_url(cmark_node *node, const char *url);
169
-
170
- const char*
171
- cmark_node_get_title(cmark_node *node);
172
-
173
- int
174
- cmark_node_set_title(cmark_node *node, const char *title);
175
-
176
- int
177
- cmark_node_get_start_line(cmark_node *node);
178
-
179
- int
180
- cmark_node_get_start_column(cmark_node *node);
181
-
182
- int
183
- cmark_node_get_end_line(cmark_node *node);
184
-
185
- int
186
- cmark_node_get_end_column(cmark_node *node);
187
-
188
- void
189
- cmark_node_unlink(cmark_node *node);
190
-
191
- int
192
- cmark_node_insert_before(cmark_node *node, cmark_node *sibling);
193
-
194
- int
195
- cmark_node_insert_after(cmark_node *node, cmark_node *sibling);
196
-
197
- int
198
- cmark_node_prepend_child(cmark_node *node, cmark_node *child);
199
-
200
- int
201
- cmark_node_append_child(cmark_node *node, cmark_node *child);
202
-
203
- void
204
- cmark_consolidate_text_nodes(cmark_node *root);
205
-
206
- cmark_parser *cmark_parser_new(int options);
207
-
208
- void cmark_parser_free(cmark_parser *parser);
209
-
210
- void cmark_parser_feed(cmark_parser *parser, const char *buffer, size_t len);
211
-
212
- cmark_node *cmark_parser_finish(cmark_parser *parser);
213
-
214
- cmark_node *cmark_parse_document(const char *buffer, size_t len, int options);
215
-
216
- char *cmark_render_xml(cmark_node *root, int options);
217
-
218
- char *cmark_render_html(cmark_node *root, int options);
219
-
220
- char *cmark_render_man(cmark_node *root, int options);
221
-
222
- char *cmark_render_commonmark(cmark_node *root, int options, int width);
223
-
224
- extern const int cmark_version;
225
-
226
- extern const char cmark_version_string[];
227
-
228
- ]]
229
-
230
- CMARK_OPT_DEFAULT = 0
231
- CMARK_OPT_SOURCEPOS = 1
232
- CMARK_OPT_HARDBREAKS = 2
233
- CMARK_OPT_NORMALIZE = 4
234
- CMARK_OPT_SMART = 8
235
-
236
- local inp = io.read("*all")
237
- local doc = cmark.cmark_parse_document(inp, string.len(inp), CMARK_OPT_SMART)
238
- local html = ffi.string(cmark.cmark_render_html(doc, CMARK_OPT_DEFAULT))
239
- print(html)