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
@@ -12,190 +12,183 @@
12
12
  #endif
13
13
 
14
14
  typedef enum {
15
- FORMAT_NONE,
16
- FORMAT_HTML,
17
- FORMAT_XML,
18
- FORMAT_MAN,
19
- FORMAT_COMMONMARK,
20
- FORMAT_LATEX
15
+ FORMAT_NONE,
16
+ FORMAT_HTML,
17
+ FORMAT_XML,
18
+ FORMAT_MAN,
19
+ FORMAT_COMMONMARK,
20
+ FORMAT_LATEX
21
21
  } writer_format;
22
22
 
23
- void print_usage()
24
- {
25
- printf("Usage: cmark [FILE*]\n");
26
- printf("Options:\n");
27
- printf(" --to, -t FORMAT Specify output format (html, xml, man, commonmark, latex)\n");
28
- printf(" --width WIDTH Specify wrap width (default 0 = nowrap)\n");
29
- printf(" --sourcepos Include source position attribute\n");
30
- printf(" --hardbreaks Treat newlines as hard line breaks\n");
31
- printf(" --safe Suppress raw HTML and dangerous URLs\n");
32
- printf(" --smart Use smart punctuation\n");
33
- printf(" --normalize Consolidate adjacent text nodes\n");
34
- printf(" --help, -h Print usage information\n");
35
- printf(" --version Print version\n");
23
+ void print_usage() {
24
+ printf("Usage: cmark [FILE*]\n");
25
+ printf("Options:\n");
26
+ printf(" --to, -t FORMAT Specify output format (html, xml, man, "
27
+ "commonmark, latex)\n");
28
+ printf(" --width WIDTH Specify wrap width (default 0 = nowrap)\n");
29
+ printf(" --sourcepos Include source position attribute\n");
30
+ printf(" --hardbreaks Treat newlines as hard line breaks\n");
31
+ printf(" --safe Suppress raw HTML and dangerous URLs\n");
32
+ printf(" --smart Use smart punctuation\n");
33
+ printf(" --normalize Consolidate adjacent text nodes\n");
34
+ printf(" --help, -h Print usage information\n");
35
+ printf(" --version Print version\n");
36
36
  }
37
37
 
38
38
  static void print_document(cmark_node *document, writer_format writer,
39
- int options, int width)
40
- {
41
- char *result;
42
-
43
- switch (writer) {
44
- case FORMAT_HTML:
45
- result = cmark_render_html(document, options);
46
- break;
47
- case FORMAT_XML:
48
- result = cmark_render_xml(document, options);
49
- break;
50
- case FORMAT_MAN:
51
- result = cmark_render_man(document, options, width);
52
- break;
53
- case FORMAT_COMMONMARK:
54
- result = cmark_render_commonmark(document, options, width);
55
- break;
56
- case FORMAT_LATEX:
57
- result = cmark_render_latex(document, options, width);
58
- break;
59
- default:
60
- fprintf(stderr, "Unknown format %d\n", writer);
61
- exit(1);
62
- }
63
- printf("%s", result);
64
- free(result);
39
+ int options, int width) {
40
+ char *result;
41
+
42
+ switch (writer) {
43
+ case FORMAT_HTML:
44
+ result = cmark_render_html(document, options);
45
+ break;
46
+ case FORMAT_XML:
47
+ result = cmark_render_xml(document, options);
48
+ break;
49
+ case FORMAT_MAN:
50
+ result = cmark_render_man(document, options, width);
51
+ break;
52
+ case FORMAT_COMMONMARK:
53
+ result = cmark_render_commonmark(document, options, width);
54
+ break;
55
+ case FORMAT_LATEX:
56
+ result = cmark_render_latex(document, options, width);
57
+ break;
58
+ default:
59
+ fprintf(stderr, "Unknown format %d\n", writer);
60
+ exit(1);
61
+ }
62
+ printf("%s", result);
63
+ free(result);
65
64
  }
66
65
 
67
- int main(int argc, char *argv[])
68
- {
69
- int i, numfps = 0;
70
- int *files;
71
- char buffer[4096];
72
- cmark_parser *parser;
73
- size_t bytes;
74
- cmark_node *document;
75
- int width = 0;
76
- char *unparsed;
77
- writer_format writer = FORMAT_HTML;
78
- int options = CMARK_OPT_DEFAULT;
66
+ int main(int argc, char *argv[]) {
67
+ int i, numfps = 0;
68
+ int *files;
69
+ char buffer[4096];
70
+ cmark_parser *parser;
71
+ size_t bytes;
72
+ cmark_node *document;
73
+ int width = 0;
74
+ char *unparsed;
75
+ writer_format writer = FORMAT_HTML;
76
+ int options = CMARK_OPT_DEFAULT;
79
77
 
80
78
  #if defined(_WIN32) && !defined(__CYGWIN__)
81
- _setmode(_fileno(stdout), _O_BINARY);
79
+ _setmode(_fileno(stdout), _O_BINARY);
82
80
  #endif
83
81
 
84
- files = (int *)malloc(argc * sizeof(*files));
85
-
86
- for (i = 1; i < argc; i++) {
87
- if (strcmp(argv[i], "--version") == 0) {
88
- printf("cmark %s", CMARK_VERSION_STRING);
89
- printf(" - CommonMark converter\n(C) 2014, 2015 John MacFarlane\n");
90
- exit(0);
91
- } else if (strcmp(argv[i], "--sourcepos") == 0) {
92
- options |= CMARK_OPT_SOURCEPOS;
93
- } else if (strcmp(argv[i], "--hardbreaks") == 0) {
94
- options |= CMARK_OPT_HARDBREAKS;
95
- } else if (strcmp(argv[i], "--smart") == 0) {
96
- options |= CMARK_OPT_SMART;
97
- } else if (strcmp(argv[i], "--safe") == 0) {
98
- options |= CMARK_OPT_SAFE;
99
- } else if (strcmp(argv[i], "--normalize") == 0) {
100
- options |= CMARK_OPT_NORMALIZE;
101
- } else if (strcmp(argv[i], "--validate-utf8") == 0) {
102
- options |= CMARK_OPT_VALIDATE_UTF8;
103
- } else if ((strcmp(argv[i], "--help") == 0) ||
104
- (strcmp(argv[i], "-h") == 0)) {
105
- print_usage();
106
- exit(0);
107
- } else if (strcmp(argv[i], "--width") == 0) {
108
- i += 1;
109
- if (i < argc) {
110
- width = (int)strtol(argv[i], &unparsed, 10);
111
- if (unparsed && strlen(unparsed) > 0) {
112
- fprintf(stderr,
113
- "failed parsing width '%s' at '%s'\n",
114
- argv[i], unparsed);
115
- exit(1);
116
- }
117
- } else {
118
- fprintf(stderr,
119
- "--width requires an argument\n");
120
- exit(1);
121
- }
122
- } else if ((strcmp(argv[i], "-t") == 0) ||
123
- (strcmp(argv[i], "--to") == 0)) {
124
- i += 1;
125
- if (i < argc) {
126
- if (strcmp(argv[i], "man") == 0) {
127
- writer = FORMAT_MAN;
128
- } else if (strcmp(argv[i], "html") == 0) {
129
- writer = FORMAT_HTML;
130
- } else if (strcmp(argv[i], "xml") == 0) {
131
- writer = FORMAT_XML;
132
- } else if (strcmp(argv[i], "commonmark") == 0) {
133
- writer = FORMAT_COMMONMARK;
134
- } else if (strcmp(argv[i], "latex") == 0) {
135
- writer = FORMAT_LATEX;
136
- } else {
137
- fprintf(stderr,
138
- "Unknown format %s\n", argv[i]);
139
- exit(1);
140
- }
141
- } else {
142
- fprintf(stderr, "No argument provided for %s\n",
143
- argv[i - 1]);
144
- exit(1);
145
- }
146
- } else if (*argv[i] == '-') {
147
- print_usage();
148
- exit(1);
149
- } else { // treat as file argument
150
- files[numfps++] = i;
151
- }
152
- }
153
-
154
- parser = cmark_parser_new(options);
155
- for (i = 0; i < numfps; i++) {
156
- FILE *fp = fopen(argv[files[i]], "r");
157
- if (fp == NULL) {
158
- fprintf(stderr, "Error opening file %s: %s\n",
159
- argv[files[i]], strerror(errno));
160
- exit(1);
161
- }
162
-
163
- start_timer();
164
- while ((bytes = fread(buffer, 1, sizeof(buffer), fp)) > 0) {
165
- cmark_parser_feed(parser, buffer, bytes);
166
- if (bytes < sizeof(buffer)) {
167
- break;
168
- }
169
- }
170
- end_timer("processing lines");
171
-
172
- fclose(fp);
173
- }
174
-
175
- if (numfps == 0) {
176
-
177
- while ((bytes = fread(buffer, 1, sizeof(buffer), stdin)) > 0) {
178
- cmark_parser_feed(parser, buffer, bytes);
179
- if (bytes < sizeof(buffer)) {
180
- break;
181
- }
182
- }
183
- }
184
-
185
- start_timer();
186
- document = cmark_parser_finish(parser);
187
- end_timer("finishing document");
188
- cmark_parser_free(parser);
189
-
190
- start_timer();
191
- print_document(document, writer, options, width);
192
- end_timer("print_document");
193
-
194
- start_timer();
195
- cmark_node_free(document);
196
- end_timer("free_blocks");
197
-
198
- free(files);
199
-
200
- return 0;
82
+ files = (int *)malloc(argc * sizeof(*files));
83
+
84
+ for (i = 1; i < argc; i++) {
85
+ if (strcmp(argv[i], "--version") == 0) {
86
+ printf("cmark %s", CMARK_VERSION_STRING);
87
+ printf(" - CommonMark converter\n(C) 2014, 2015 John MacFarlane\n");
88
+ exit(0);
89
+ } else if (strcmp(argv[i], "--sourcepos") == 0) {
90
+ options |= CMARK_OPT_SOURCEPOS;
91
+ } else if (strcmp(argv[i], "--hardbreaks") == 0) {
92
+ options |= CMARK_OPT_HARDBREAKS;
93
+ } else if (strcmp(argv[i], "--smart") == 0) {
94
+ options |= CMARK_OPT_SMART;
95
+ } else if (strcmp(argv[i], "--safe") == 0) {
96
+ options |= CMARK_OPT_SAFE;
97
+ } else if (strcmp(argv[i], "--normalize") == 0) {
98
+ options |= CMARK_OPT_NORMALIZE;
99
+ } else if (strcmp(argv[i], "--validate-utf8") == 0) {
100
+ options |= CMARK_OPT_VALIDATE_UTF8;
101
+ } else if ((strcmp(argv[i], "--help") == 0) ||
102
+ (strcmp(argv[i], "-h") == 0)) {
103
+ print_usage();
104
+ exit(0);
105
+ } else if (strcmp(argv[i], "--width") == 0) {
106
+ i += 1;
107
+ if (i < argc) {
108
+ width = (int)strtol(argv[i], &unparsed, 10);
109
+ if (unparsed && strlen(unparsed) > 0) {
110
+ fprintf(stderr, "failed parsing width '%s' at '%s'\n", argv[i],
111
+ unparsed);
112
+ exit(1);
113
+ }
114
+ } else {
115
+ fprintf(stderr, "--width requires an argument\n");
116
+ exit(1);
117
+ }
118
+ } else if ((strcmp(argv[i], "-t") == 0) || (strcmp(argv[i], "--to") == 0)) {
119
+ i += 1;
120
+ if (i < argc) {
121
+ if (strcmp(argv[i], "man") == 0) {
122
+ writer = FORMAT_MAN;
123
+ } else if (strcmp(argv[i], "html") == 0) {
124
+ writer = FORMAT_HTML;
125
+ } else if (strcmp(argv[i], "xml") == 0) {
126
+ writer = FORMAT_XML;
127
+ } else if (strcmp(argv[i], "commonmark") == 0) {
128
+ writer = FORMAT_COMMONMARK;
129
+ } else if (strcmp(argv[i], "latex") == 0) {
130
+ writer = FORMAT_LATEX;
131
+ } else {
132
+ fprintf(stderr, "Unknown format %s\n", argv[i]);
133
+ exit(1);
134
+ }
135
+ } else {
136
+ fprintf(stderr, "No argument provided for %s\n", argv[i - 1]);
137
+ exit(1);
138
+ }
139
+ } else if (*argv[i] == '-') {
140
+ print_usage();
141
+ exit(1);
142
+ } else { // treat as file argument
143
+ files[numfps++] = i;
144
+ }
145
+ }
146
+
147
+ parser = cmark_parser_new(options);
148
+ for (i = 0; i < numfps; i++) {
149
+ FILE *fp = fopen(argv[files[i]], "r");
150
+ if (fp == NULL) {
151
+ fprintf(stderr, "Error opening file %s: %s\n", argv[files[i]],
152
+ strerror(errno));
153
+ exit(1);
154
+ }
155
+
156
+ start_timer();
157
+ while ((bytes = fread(buffer, 1, sizeof(buffer), fp)) > 0) {
158
+ cmark_parser_feed(parser, buffer, bytes);
159
+ if (bytes < sizeof(buffer)) {
160
+ break;
161
+ }
162
+ }
163
+ end_timer("processing lines");
164
+
165
+ fclose(fp);
166
+ }
167
+
168
+ if (numfps == 0) {
169
+
170
+ while ((bytes = fread(buffer, 1, sizeof(buffer), stdin)) > 0) {
171
+ cmark_parser_feed(parser, buffer, bytes);
172
+ if (bytes < sizeof(buffer)) {
173
+ break;
174
+ }
175
+ }
176
+ }
177
+
178
+ start_timer();
179
+ document = cmark_parser_finish(parser);
180
+ end_timer("finishing document");
181
+ cmark_parser_free(parser);
182
+
183
+ start_timer();
184
+ print_document(document, writer, options, width);
185
+ end_timer("print_document");
186
+
187
+ start_timer();
188
+ cmark_node_free(document);
189
+ end_timer("free_blocks");
190
+
191
+ free(files);
192
+
193
+ return 0;
201
194
  }