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
@@ -13,68 +13,67 @@ extern "C" {
13
13
  #include "chunk.h"
14
14
 
15
15
  typedef struct {
16
- cmark_list_type list_type;
17
- int marker_offset;
18
- int padding;
19
- int start;
20
- cmark_delim_type delimiter;
21
- unsigned char bullet_char;
22
- bool tight;
16
+ cmark_list_type list_type;
17
+ int marker_offset;
18
+ int padding;
19
+ int start;
20
+ cmark_delim_type delimiter;
21
+ unsigned char bullet_char;
22
+ bool tight;
23
23
  } cmark_list;
24
24
 
25
25
  typedef struct {
26
- cmark_chunk info;
27
- cmark_chunk literal;
28
- int fence_length;
29
- /* fence_offset must be 0-3, so we can use int8_t */
30
- int8_t fence_offset;
31
- unsigned char fence_char;
32
- bool fenced;
26
+ cmark_chunk info;
27
+ cmark_chunk literal;
28
+ int fence_length;
29
+ /* fence_offset must be 0-3, so we can use int8_t */
30
+ int8_t fence_offset;
31
+ unsigned char fence_char;
32
+ bool fenced;
33
33
  } cmark_code;
34
34
 
35
35
  typedef struct {
36
- int level;
37
- bool setext;
36
+ int level;
37
+ bool setext;
38
38
  } cmark_header;
39
39
 
40
40
  typedef struct {
41
- cmark_chunk url;
42
- cmark_chunk title;
41
+ cmark_chunk url;
42
+ cmark_chunk title;
43
43
  } cmark_link;
44
44
 
45
45
  struct cmark_node {
46
- struct cmark_node *next;
47
- struct cmark_node *prev;
48
- struct cmark_node *parent;
49
- struct cmark_node *first_child;
50
- struct cmark_node *last_child;
51
-
52
- void *user_data;
53
-
54
- int start_line;
55
- int start_column;
56
- int end_line;
57
- int end_column;
58
-
59
- cmark_node_type type;
60
-
61
- bool open;
62
- bool last_line_blank;
63
-
64
- cmark_strbuf string_content;
65
-
66
- union {
67
- cmark_chunk literal;
68
- cmark_list list;
69
- cmark_code code;
70
- cmark_header header;
71
- cmark_link link;
72
- int html_block_type;
73
- } as;
46
+ struct cmark_node *next;
47
+ struct cmark_node *prev;
48
+ struct cmark_node *parent;
49
+ struct cmark_node *first_child;
50
+ struct cmark_node *last_child;
51
+
52
+ void *user_data;
53
+
54
+ int start_line;
55
+ int start_column;
56
+ int end_line;
57
+ int end_column;
58
+
59
+ cmark_node_type type;
60
+
61
+ bool open;
62
+ bool last_line_blank;
63
+
64
+ cmark_strbuf string_content;
65
+
66
+ union {
67
+ cmark_chunk literal;
68
+ cmark_list list;
69
+ cmark_code code;
70
+ cmark_header header;
71
+ cmark_link link;
72
+ int html_block_type;
73
+ } as;
74
74
  };
75
75
 
76
- CMARK_EXPORT int
77
- cmark_node_check(cmark_node *node, FILE *out);
76
+ CMARK_EXPORT int cmark_node_check(cmark_node *node, FILE *out);
78
77
 
79
78
  #ifdef __cplusplus
80
79
  }
@@ -12,20 +12,20 @@ extern "C" {
12
12
  #define MAX_LINK_LABEL_LENGTH 1000
13
13
 
14
14
  struct cmark_parser {
15
- struct cmark_reference_map *refmap;
16
- struct cmark_node* root;
17
- struct cmark_node* current;
18
- int line_number;
19
- bufsize_t offset;
20
- bufsize_t column;
21
- bufsize_t first_nonspace;
22
- bufsize_t first_nonspace_column;
23
- int indent;
24
- bool blank;
25
- cmark_strbuf *curline;
26
- bufsize_t last_line_length;
27
- cmark_strbuf *linebuf;
28
- int options;
15
+ struct cmark_reference_map *refmap;
16
+ struct cmark_node *root;
17
+ struct cmark_node *current;
18
+ int line_number;
19
+ bufsize_t offset;
20
+ bufsize_t column;
21
+ bufsize_t first_nonspace;
22
+ bufsize_t first_nonspace_column;
23
+ int indent;
24
+ bool blank;
25
+ cmark_strbuf *curline;
26
+ bufsize_t last_line_length;
27
+ cmark_strbuf *linebuf;
28
+ int options;
29
29
  };
30
30
 
31
31
  #ifdef __cplusplus
@@ -5,150 +5,140 @@
5
5
  #include "inlines.h"
6
6
  #include "chunk.h"
7
7
 
8
- static unsigned int
9
- refhash(const unsigned char *link_ref)
10
- {
11
- unsigned int hash = 0;
8
+ static unsigned int refhash(const unsigned char *link_ref) {
9
+ unsigned int hash = 0;
12
10
 
13
- while (*link_ref)
14
- hash = (*link_ref++) + (hash << 6) + (hash << 16) - hash;
11
+ while (*link_ref)
12
+ hash = (*link_ref++) + (hash << 6) + (hash << 16) - hash;
15
13
 
16
- return hash;
14
+ return hash;
17
15
  }
18
16
 
19
- static void reference_free(cmark_reference *ref)
20
- {
21
- if(ref != NULL) {
22
- free(ref->label);
23
- cmark_chunk_free(&ref->url);
24
- cmark_chunk_free(&ref->title);
25
- free(ref);
26
- }
17
+ static void reference_free(cmark_reference *ref) {
18
+ if (ref != NULL) {
19
+ free(ref->label);
20
+ cmark_chunk_free(&ref->url);
21
+ cmark_chunk_free(&ref->title);
22
+ free(ref);
23
+ }
27
24
  }
28
25
 
29
26
  // normalize reference: collapse internal whitespace to single space,
30
27
  // remove leading/trailing whitespace, case fold
31
28
  // Return NULL if the reference name is actually empty (i.e. composed
32
29
  // solely from whitespace)
33
- static unsigned char *normalize_reference(cmark_chunk *ref)
34
- {
35
- cmark_strbuf normalized = GH_BUF_INIT;
36
- unsigned char *result;
30
+ static unsigned char *normalize_reference(cmark_chunk *ref) {
31
+ cmark_strbuf normalized = GH_BUF_INIT;
32
+ unsigned char *result;
37
33
 
38
- if(ref == NULL)
39
- return NULL;
34
+ if (ref == NULL)
35
+ return NULL;
40
36
 
41
- if (ref->len == 0)
42
- return NULL;
37
+ if (ref->len == 0)
38
+ return NULL;
43
39
 
44
- utf8proc_case_fold(&normalized, ref->data, ref->len);
45
- cmark_strbuf_trim(&normalized);
46
- cmark_strbuf_normalize_whitespace(&normalized);
40
+ cmark_utf8proc_case_fold(&normalized, ref->data, ref->len);
41
+ cmark_strbuf_trim(&normalized);
42
+ cmark_strbuf_normalize_whitespace(&normalized);
47
43
 
48
- result = cmark_strbuf_detach(&normalized);
49
- assert(result);
44
+ result = cmark_strbuf_detach(&normalized);
45
+ assert(result);
50
46
 
51
- if (result[0] == '\0') {
52
- free(result);
53
- return NULL;
54
- }
47
+ if (result[0] == '\0') {
48
+ free(result);
49
+ return NULL;
50
+ }
55
51
 
56
- return result;
52
+ return result;
57
53
  }
58
54
 
59
- static void add_reference(cmark_reference_map *map, cmark_reference* ref)
60
- {
61
- cmark_reference *t = ref->next = map->table[ref->hash % REFMAP_SIZE];
55
+ static void add_reference(cmark_reference_map *map, cmark_reference *ref) {
56
+ cmark_reference *t = ref->next = map->table[ref->hash % REFMAP_SIZE];
62
57
 
63
- while (t) {
64
- if (t->hash == ref->hash &&
65
- !strcmp((char *)t->label, (char *)ref->label)) {
66
- reference_free(ref);
67
- return;
68
- }
58
+ while (t) {
59
+ if (t->hash == ref->hash && !strcmp((char *)t->label, (char *)ref->label)) {
60
+ reference_free(ref);
61
+ return;
62
+ }
69
63
 
70
- t = t->next;
71
- }
64
+ t = t->next;
65
+ }
72
66
 
73
- map->table[ref->hash % REFMAP_SIZE] = ref;
67
+ map->table[ref->hash % REFMAP_SIZE] = ref;
74
68
  }
75
69
 
76
- void cmark_reference_create(cmark_reference_map *map, cmark_chunk *label, cmark_chunk *url,
77
- cmark_chunk *title)
78
- {
79
- cmark_reference *ref;
80
- unsigned char *reflabel = normalize_reference(label);
81
-
82
- /* empty reference name, or composed from only whitespace */
83
- if (reflabel == NULL)
84
- return;
85
-
86
- ref = (cmark_reference *)calloc(1, sizeof(*ref));
87
- if(ref != NULL) {
88
- ref->label = reflabel;
89
- ref->hash = refhash(ref->label);
90
- ref->url = cmark_clean_url(url);
91
- ref->title = cmark_clean_title(title);
92
- ref->next = NULL;
93
-
94
- add_reference(map, ref);
95
- }
70
+ void cmark_reference_create(cmark_reference_map *map, cmark_chunk *label,
71
+ cmark_chunk *url, cmark_chunk *title) {
72
+ cmark_reference *ref;
73
+ unsigned char *reflabel = normalize_reference(label);
74
+
75
+ /* empty reference name, or composed from only whitespace */
76
+ if (reflabel == NULL)
77
+ return;
78
+
79
+ ref = (cmark_reference *)calloc(1, sizeof(*ref));
80
+ if (ref != NULL) {
81
+ ref->label = reflabel;
82
+ ref->hash = refhash(ref->label);
83
+ ref->url = cmark_clean_url(url);
84
+ ref->title = cmark_clean_title(title);
85
+ ref->next = NULL;
86
+
87
+ add_reference(map, ref);
88
+ }
96
89
  }
97
90
 
98
91
  // Returns reference if refmap contains a reference with matching
99
92
  // label, otherwise NULL.
100
- cmark_reference* cmark_reference_lookup(cmark_reference_map *map, cmark_chunk *label)
101
- {
102
- cmark_reference *ref = NULL;
103
- unsigned char *norm;
104
- unsigned int hash;
105
-
106
- if (label->len > MAX_LINK_LABEL_LENGTH)
107
- return NULL;
108
-
109
- if (map == NULL)
110
- return NULL;
111
-
112
- norm = normalize_reference(label);
113
- if (norm == NULL)
114
- return NULL;
115
-
116
- hash = refhash(norm);
117
- ref = map->table[hash % REFMAP_SIZE];
118
-
119
- while (ref) {
120
- if (ref->hash == hash &&
121
- !strcmp((char *)ref->label, (char *)norm))
122
- break;
123
- ref = ref->next;
124
- }
125
-
126
- free(norm);
127
- return ref;
93
+ cmark_reference *cmark_reference_lookup(cmark_reference_map *map,
94
+ cmark_chunk *label) {
95
+ cmark_reference *ref = NULL;
96
+ unsigned char *norm;
97
+ unsigned int hash;
98
+
99
+ if (label->len > MAX_LINK_LABEL_LENGTH)
100
+ return NULL;
101
+
102
+ if (map == NULL)
103
+ return NULL;
104
+
105
+ norm = normalize_reference(label);
106
+ if (norm == NULL)
107
+ return NULL;
108
+
109
+ hash = refhash(norm);
110
+ ref = map->table[hash % REFMAP_SIZE];
111
+
112
+ while (ref) {
113
+ if (ref->hash == hash && !strcmp((char *)ref->label, (char *)norm))
114
+ break;
115
+ ref = ref->next;
116
+ }
117
+
118
+ free(norm);
119
+ return ref;
128
120
  }
129
121
 
130
- void cmark_reference_map_free(cmark_reference_map *map)
131
- {
132
- unsigned int i;
122
+ void cmark_reference_map_free(cmark_reference_map *map) {
123
+ unsigned int i;
133
124
 
134
- if(map == NULL)
135
- return;
125
+ if (map == NULL)
126
+ return;
136
127
 
137
- for (i = 0; i < REFMAP_SIZE; ++i) {
138
- cmark_reference *ref = map->table[i];
139
- cmark_reference *next;
128
+ for (i = 0; i < REFMAP_SIZE; ++i) {
129
+ cmark_reference *ref = map->table[i];
130
+ cmark_reference *next;
140
131
 
141
- while (ref) {
142
- next = ref->next;
143
- reference_free(ref);
144
- ref = next;
145
- }
146
- }
132
+ while (ref) {
133
+ next = ref->next;
134
+ reference_free(ref);
135
+ ref = next;
136
+ }
137
+ }
147
138
 
148
- free(map);
139
+ free(map);
149
140
  }
150
141
 
151
- cmark_reference_map *cmark_reference_map_new(void)
152
- {
153
- return (cmark_reference_map *)calloc(1, sizeof(cmark_reference_map));
142
+ cmark_reference_map *cmark_reference_map_new(void) {
143
+ return (cmark_reference_map *)calloc(1, sizeof(cmark_reference_map));
154
144
  }
@@ -10,25 +10,27 @@ extern "C" {
10
10
  #define REFMAP_SIZE 16
11
11
 
12
12
  struct cmark_reference {
13
- struct cmark_reference *next;
14
- unsigned char *label;
15
- cmark_chunk url;
16
- cmark_chunk title;
17
- unsigned int hash;
13
+ struct cmark_reference *next;
14
+ unsigned char *label;
15
+ cmark_chunk url;
16
+ cmark_chunk title;
17
+ unsigned int hash;
18
18
  };
19
19
 
20
20
  typedef struct cmark_reference cmark_reference;
21
21
 
22
22
  struct cmark_reference_map {
23
- cmark_reference *table[REFMAP_SIZE];
23
+ cmark_reference *table[REFMAP_SIZE];
24
24
  };
25
25
 
26
26
  typedef struct cmark_reference_map cmark_reference_map;
27
27
 
28
28
  cmark_reference_map *cmark_reference_map_new(void);
29
29
  void cmark_reference_map_free(cmark_reference_map *map);
30
- cmark_reference* cmark_reference_lookup(cmark_reference_map *map, cmark_chunk *label);
31
- extern void cmark_reference_create(cmark_reference_map *map, cmark_chunk *label, cmark_chunk *url, cmark_chunk *title);
30
+ cmark_reference *cmark_reference_lookup(cmark_reference_map *map,
31
+ cmark_chunk *label);
32
+ extern void cmark_reference_create(cmark_reference_map *map, cmark_chunk *label,
33
+ cmark_chunk *url, cmark_chunk *title);
32
34
 
33
35
  #ifdef __cplusplus
34
36
  }