redcarpet 3.5.1 → 3.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,5 @@
1
- /* C code produced by gperf version 3.0.3 */
1
+ /* ANSI-C code produced by gperf version 3.1 */
2
2
  /* Command-line: gperf -N find_block_tag -H hash_block_tag -C -c -E --ignore-case html_block_names.txt */
3
- /* See https://git.io/vPLqa for the list of recognized elements */
4
3
  /* Computed positions: -k'1-2' */
5
4
 
6
5
  #if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \
@@ -27,7 +26,7 @@
27
26
  && ('w' == 119) && ('x' == 120) && ('y' == 121) && ('z' == 122) \
28
27
  && ('{' == 123) && ('|' == 124) && ('}' == 125) && ('~' == 126))
29
28
  /* The character set is not based on ISO-646. */
30
- error "gperf generated tables don't work with this execution character set. Please report a bug to <bug-gnu-gperf@gnu.org>."
29
+ #error "gperf generated tables don't work with this execution character set. Please report a bug to <bug-gperf@gnu.org>."
31
30
  #endif
32
31
 
33
32
  /* maximum key range = 72, duplicates = 0 */
@@ -60,10 +59,7 @@ static unsigned char gperf_downcase[256] =
60
59
  #ifndef GPERF_CASE_STRNCMP
61
60
  #define GPERF_CASE_STRNCMP 1
62
61
  static int
63
- gperf_case_strncmp (s1, s2, n)
64
- register const char *s1;
65
- register const char *s2;
66
- register unsigned int n;
62
+ gperf_case_strncmp (register const char *s1, register const char *s2, register size_t n)
67
63
  {
68
64
  for (; n > 0;)
69
65
  {
@@ -88,9 +84,7 @@ inline
88
84
  #endif
89
85
  #endif
90
86
  static unsigned int
91
- hash_block_tag (str, len)
92
- register const char *str;
93
- register unsigned int len;
87
+ hash_block_tag (register const char *str, register size_t len)
94
88
  {
95
89
  static const unsigned char asso_values[] =
96
90
  {
@@ -99,13 +93,13 @@ hash_block_tag (str, len)
99
93
  73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
100
94
  73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
101
95
  73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
102
- 26, 60, 55, 45, 40, 35, 73, 73, 73, 73,
103
- 73, 73, 73, 73, 73, 20, 15, 15, 0, 35,
104
- 0, 25, 10, 10, 5, 73, 73, 0, 15, 15,
96
+ 16, 55, 50, 45, 40, 5, 73, 73, 73, 73,
97
+ 73, 73, 73, 73, 73, 20, 15, 25, 0, 45,
98
+ 0, 30, 10, 0, 5, 73, 73, 0, 15, 35,
105
99
  0, 73, 73, 15, 20, 10, 10, 73, 73, 73,
106
- 73, 73, 73, 73, 73, 73, 73, 20, 15, 15,
107
- 0, 35, 0, 25, 10, 10, 5, 73, 73, 0,
108
- 15, 15, 0, 73, 73, 15, 20, 10, 10, 73,
100
+ 73, 73, 73, 73, 73, 73, 73, 20, 15, 25,
101
+ 0, 45, 0, 30, 10, 0, 5, 73, 73, 0,
102
+ 15, 35, 0, 73, 73, 15, 20, 10, 10, 73,
109
103
  73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
110
104
  73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
111
105
  73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
@@ -136,13 +130,11 @@ hash_block_tag (str, len)
136
130
  }
137
131
 
138
132
  const char *
139
- find_block_tag (str, len)
140
- register const char *str;
141
- register unsigned int len;
133
+ find_block_tag (register const char *str, register size_t len)
142
134
  {
143
135
  enum
144
136
  {
145
- TOTAL_KEYWORDS = 43,
137
+ TOTAL_KEYWORDS = 44,
146
138
  MIN_WORD_LENGTH = 1,
147
139
  MAX_WORD_LENGTH = 10,
148
140
  MIN_HASH_VALUE = 1,
@@ -167,7 +159,7 @@ find_block_tag (str, len)
167
159
  "",
168
160
  "figcaption",
169
161
  "header",
170
- "ol",
162
+ "h6",
171
163
  "pre",
172
164
  "math",
173
165
  "video",
@@ -178,42 +170,45 @@ find_block_tag (str, len)
178
170
  "blockquote",
179
171
  "hgroup",
180
172
  "hr",
181
- "ins",
173
+ "h1",
182
174
  "",
183
175
  "style",
184
- "output",
176
+ "center",
185
177
  "summary",
186
178
  "nav",
187
179
  "",
188
180
  "audio",
189
- "canvas",
190
- "dd",
191
- "h1",
192
- "abbr",
193
- "table",
194
181
  "iframe",
182
+ "ol",
183
+ "ins",
184
+ "",
185
+ "table",
186
+ "",
195
187
  "article",
196
188
  "", "",
197
189
  "aside",
190
+ "canvas",
191
+ "dd",
198
192
  "",
199
- "h6",
193
+ "abbr",
194
+ "",
195
+ "output",
196
+ "h5",
200
197
  "", "",
201
198
  "tfoot",
202
199
  "",
203
- "h5",
204
- "", "", "", "",
205
200
  "h4",
206
201
  "", "", "", "",
207
- "address",
208
- "", "", "", "",
209
202
  "h3",
210
203
  "", "", "", "",
211
- "h2"
204
+ "h2",
205
+ "", "", "", "",
206
+ "address"
212
207
  };
213
208
 
214
209
  if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
215
210
  {
216
- unsigned int key = hash_block_tag (str, len);
211
+ register unsigned int key = hash_block_tag (str, len);
217
212
 
218
213
  if (key <= MAX_HASH_VALUE)
219
214
  {
@@ -1353,13 +1353,13 @@ is_hrule(uint8_t *data, size_t size)
1353
1353
  return n >= 3;
1354
1354
  }
1355
1355
 
1356
- /* check if a line begins with a code fence; return the
1357
- * width of the code fence */
1356
+ /* check if a line begins with a code fence matching optional opendelim;
1357
+ return the width of the code fence and store the delimiter string */
1358
1358
  static size_t
1359
- prefix_codefence(uint8_t *data, size_t size)
1359
+ prefix_codefence(uint8_t *data, size_t size, struct buf *delim, struct buf *opendelim)
1360
1360
  {
1361
- size_t i = 0, n = 0;
1362
- uint8_t c;
1361
+ size_t i = 0, n = 0, min_n = 3;
1362
+ uint8_t c, *delim_start;
1363
1363
 
1364
1364
  /* skipping initial spaces */
1365
1365
  if (size < 3) return 0;
@@ -1367,31 +1367,46 @@ prefix_codefence(uint8_t *data, size_t size)
1367
1367
  if (data[1] == ' ') { i++;
1368
1368
  if (data[2] == ' ') { i++; } } }
1369
1369
 
1370
+ delim_start = data + i;
1371
+
1370
1372
  /* looking at the hrule uint8_t */
1371
1373
  if (i + 2 >= size || !(data[i] == '~' || data[i] == '`'))
1372
1374
  return 0;
1373
1375
 
1374
- c = data[i];
1376
+ if (opendelim && opendelim->size) {
1377
+ c = opendelim->data[0];
1378
+ min_n = opendelim->size;
1379
+ } else {
1380
+ c = data[i];
1381
+ }
1375
1382
 
1376
1383
  /* the whole line must be the uint8_t or whitespace */
1377
1384
  while (i < size && data[i] == c) {
1378
1385
  n++; i++;
1379
1386
  }
1380
1387
 
1381
- if (n < 3)
1388
+ if (n < min_n)
1382
1389
  return 0;
1383
1390
 
1391
+ if (delim) {
1392
+ delim->data = delim_start;
1393
+ delim->size = n;
1394
+ }
1395
+
1384
1396
  return i;
1385
1397
  }
1386
1398
 
1387
1399
  /* check if a line is a code fence; return its size if it is */
1400
+ /* checking is done in fence-pair matching mode if curdelim is provided */
1388
1401
  static size_t
1389
- is_codefence(uint8_t *data, size_t size, struct buf *syntax)
1402
+ is_codefence(uint8_t *data, size_t size, struct buf *curdelim, struct buf *syntax)
1390
1403
  {
1391
1404
  size_t i = 0, syn_len = 0;
1392
1405
  uint8_t *syn_start;
1406
+ struct buf delim = { 0, 0, 0, 0 };
1407
+
1408
+ i = prefix_codefence(data, size, &delim, curdelim);
1393
1409
 
1394
- i = prefix_codefence(data, size);
1395
1410
  if (i == 0)
1396
1411
  return 0;
1397
1412
 
@@ -1426,10 +1441,9 @@ is_codefence(uint8_t *data, size_t size, struct buf *syntax)
1426
1441
  }
1427
1442
  }
1428
1443
 
1429
- if (syntax) {
1430
- syntax->data = syn_start;
1431
- syntax->size = syn_len;
1432
- }
1444
+ /* info string must not be present at the closing fence */
1445
+ if (curdelim && curdelim->size && syn_len)
1446
+ return 0;
1433
1447
 
1434
1448
  while (i < size && data[i] != '\n') {
1435
1449
  if (!_isspace(data[i]))
@@ -1438,6 +1452,21 @@ is_codefence(uint8_t *data, size_t size, struct buf *syntax)
1438
1452
  i++;
1439
1453
  }
1440
1454
 
1455
+ if (curdelim) {
1456
+ if (curdelim->size) {
1457
+ curdelim->data = NULL;
1458
+ curdelim->size = 0;
1459
+ } else {
1460
+ curdelim->data = delim.data;
1461
+ curdelim->size = delim.size;
1462
+ }
1463
+ }
1464
+
1465
+ if (syntax) {
1466
+ syntax->data = syn_start;
1467
+ syntax->size = syn_len;
1468
+ }
1469
+
1441
1470
  return i + 1;
1442
1471
  }
1443
1472
 
@@ -1673,7 +1702,7 @@ parse_paragraph(struct buf *ob, struct sd_markdown *rndr, uint8_t *data, size_t
1673
1702
 
1674
1703
  /* see if a code fence starts here */
1675
1704
  if ((rndr->ext_flags & MKDEXT_FENCED_CODE) != 0 &&
1676
- is_codefence(data + i, size - i, NULL) != 0) {
1705
+ is_codefence(data + i, size - i, NULL, NULL) != 0) {
1677
1706
  end = i;
1678
1707
  break;
1679
1708
  }
@@ -1739,19 +1768,19 @@ parse_fencedcode(struct buf *ob, struct sd_markdown *rndr, uint8_t *data, size_t
1739
1768
  {
1740
1769
  size_t beg, end;
1741
1770
  struct buf *work = 0;
1771
+ struct buf delim = { 0, 0, 0, 0 };
1742
1772
  struct buf lang = { 0, 0, 0, 0 };
1743
1773
 
1744
- beg = is_codefence(data, size, &lang);
1774
+ beg = is_codefence(data, size, &delim, &lang);
1745
1775
  if (beg == 0) return 0;
1746
1776
 
1747
1777
  work = rndr_newbuf(rndr, BUFFER_BLOCK);
1748
1778
 
1749
1779
  while (beg < size) {
1750
1780
  size_t fence_end;
1751
- struct buf fence_trail = { 0, 0, 0, 0 };
1752
1781
 
1753
- fence_end = is_codefence(data + beg, size - beg, &fence_trail);
1754
- if (fence_end != 0 && fence_trail.size == 0) {
1782
+ fence_end = is_codefence(data + beg, size - beg, &delim, NULL);
1783
+ if (fence_end != 0) {
1755
1784
  beg += fence_end;
1756
1785
  break;
1757
1786
  }
@@ -1827,6 +1856,7 @@ parse_listitem(struct buf *ob, struct sd_markdown *rndr, uint8_t *data, size_t s
1827
1856
  struct buf *work = 0, *inter = 0;
1828
1857
  size_t beg = 0, end, pre, sublist = 0, orgpre = 0, i;
1829
1858
  int in_empty = 0, has_inside_empty = 0, in_fence = 0;
1859
+ struct buf fence_delim = { 0, 0, 0, 0 };
1830
1860
 
1831
1861
  /* keeping track of the first indentation prefix */
1832
1862
  while (orgpre < 3 && orgpre < size && data[orgpre] == ' ')
@@ -1876,7 +1906,7 @@ parse_listitem(struct buf *ob, struct sd_markdown *rndr, uint8_t *data, size_t s
1876
1906
  pre = i;
1877
1907
 
1878
1908
  if (rndr->ext_flags & MKDEXT_FENCED_CODE) {
1879
- if (is_codefence(data + beg + i, end - beg - i, NULL) != 0)
1909
+ if (is_codefence(data + beg + i, end - beg - i, &fence_delim, NULL) != 0)
1880
1910
  in_fence = !in_fence;
1881
1911
  }
1882
1912
 
@@ -2804,6 +2834,7 @@ sd_markdown_render(struct buf *ob, const uint8_t *document, size_t doc_size, str
2804
2834
  struct buf *text;
2805
2835
  size_t beg, end;
2806
2836
  int in_fence = 0;
2837
+ struct buf fence_delim = { 0, 0, 0, 0 };
2807
2838
 
2808
2839
  text = bufnew(64);
2809
2840
  if (!text)
@@ -2833,7 +2864,7 @@ sd_markdown_render(struct buf *ob, const uint8_t *document, size_t doc_size, str
2833
2864
  beg += 3;
2834
2865
 
2835
2866
  while (beg < doc_size) { /* iterating over lines */
2836
- if (codefences_enabled && (is_codefence(document + beg, doc_size - beg, NULL) != 0))
2867
+ if (codefences_enabled && (is_codefence(document + beg, doc_size - beg, &fence_delim, NULL) != 0))
2837
2868
  in_fence = !in_fence;
2838
2869
 
2839
2870
  if (!in_fence && footnotes_enabled && is_footnote(document, beg, doc_size, &end, &md->footnotes_found))
@@ -85,6 +85,17 @@ rb_redcarpet_md__free(void *markdown)
85
85
  sd_markdown_free((struct sd_markdown *)markdown);
86
86
  }
87
87
 
88
+ static const rb_data_type_t rb_redcarpet_md__type = {
89
+ "Redcarpet/md",
90
+ {
91
+ NULL, // Nothing to mark
92
+ rb_redcarpet_md__free,
93
+ },
94
+ 0,
95
+ 0,
96
+ RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
97
+ };
98
+
88
99
  static VALUE rb_redcarpet_md__new(int argc, VALUE *argv, VALUE klass)
89
100
  {
90
101
  VALUE rb_markdown, rb_rndr, hash, rndr_options;
@@ -111,7 +122,7 @@ static VALUE rb_redcarpet_md__new(int argc, VALUE *argv, VALUE klass)
111
122
  if (rb_obj_is_kind_of(rb_rndr, rb_cRenderHTML_TOC))
112
123
  extensions |= MKDEXT_FENCED_CODE;
113
124
 
114
- Data_Get_Struct(rb_rndr, struct rb_redcarpet_rndr, rndr);
125
+ rndr = rb_redcarpet_rndr_unwrap(rb_rndr);
115
126
 
116
127
  /* Merge the current options in the @options hash */
117
128
  if (hash != Qnil) {
@@ -123,7 +134,7 @@ static VALUE rb_redcarpet_md__new(int argc, VALUE *argv, VALUE klass)
123
134
  if (!markdown)
124
135
  rb_raise(rb_eRuntimeError, "Failed to create new Renderer class");
125
136
 
126
- rb_markdown = Data_Wrap_Struct(klass, NULL, rb_redcarpet_md__free, markdown);
137
+ rb_markdown = TypedData_Wrap_Struct(klass, &rb_redcarpet_md__type, markdown);
127
138
  rb_iv_set(rb_markdown, "@renderer", rb_rndr);
128
139
 
129
140
  return rb_markdown;
@@ -138,15 +149,14 @@ static VALUE rb_redcarpet_md_render(VALUE self, VALUE text)
138
149
  Check_Type(text, T_STRING);
139
150
 
140
151
  rb_rndr = rb_iv_get(self, "@renderer");
141
- Data_Get_Struct(self, struct sd_markdown, markdown);
152
+ TypedData_Get_Struct(self, struct sd_markdown, &rb_redcarpet_md__type, markdown);
142
153
 
143
154
  if (rb_respond_to(rb_rndr, rb_intern("preprocess")))
144
155
  text = rb_funcall(rb_rndr, rb_intern("preprocess"), 1, text);
145
156
  if (NIL_P(text))
146
157
  return Qnil;
147
158
 
148
- struct rb_redcarpet_rndr *renderer;
149
- Data_Get_Struct(rb_rndr, struct rb_redcarpet_rndr, renderer);
159
+ struct rb_redcarpet_rndr *renderer = rb_redcarpet_rndr_unwrap(rb_rndr);
150
160
  renderer->options.active_enc = rb_enc_get(text);
151
161
 
152
162
  /* initialize buffers */
@@ -176,6 +186,7 @@ void Init_redcarpet()
176
186
  rb_mRedcarpet = rb_define_module("Redcarpet");
177
187
 
178
188
  rb_cMarkdown = rb_define_class_under(rb_mRedcarpet, "Markdown", rb_cObject);
189
+ rb_undef_alloc_func(rb_cMarkdown);
179
190
  rb_define_singleton_method(rb_cMarkdown, "new", rb_redcarpet_md__new, -1);
180
191
  rb_define_method(rb_cMarkdown, "render", rb_redcarpet_md_render, 1);
181
192
 
@@ -113,9 +113,10 @@ rndr_tablerow(struct buf *ob, const struct buf *text, void *opaque)
113
113
  static void
114
114
  rndr_tablecell(struct buf *ob, const struct buf *text, int align, void *opaque)
115
115
  {
116
- VALUE rb_align;
116
+ VALUE rb_align, rb_header;
117
+ VALUE rb_callback, rb_callback_arity;
117
118
 
118
- switch (align) {
119
+ switch (align & MKD_TABLE_ALIGNMASK) {
119
120
  case MKD_TABLE_ALIGN_L:
120
121
  rb_align = CSTR2SYM("left");
121
122
  break;
@@ -133,7 +134,25 @@ rndr_tablecell(struct buf *ob, const struct buf *text, int align, void *opaque)
133
134
  break;
134
135
  }
135
136
 
136
- BLOCK_CALLBACK("table_cell", 2, buf2str(text), rb_align);
137
+ if (align & MKD_TABLE_HEADER) {
138
+ rb_header = Qtrue;
139
+ } else {
140
+ rb_header = Qfalse;
141
+ }
142
+
143
+ struct redcarpet_renderopt *opt = opaque;
144
+
145
+ rb_callback = rb_funcall(opt->self, rb_intern("method"), 1, CSTR2SYM("table_cell"));
146
+
147
+ rb_callback_arity = rb_funcall(rb_callback, rb_intern("arity"), 0);
148
+
149
+ /* For backward compatibility, let's ensure that the erasure with
150
+ only two parameters is still supported. */
151
+ if (FIX2INT(rb_callback_arity) == 3) {
152
+ BLOCK_CALLBACK("table_cell", 3, buf2str(text), rb_align, rb_header);
153
+ } else {
154
+ BLOCK_CALLBACK("table_cell", 2, buf2str(text), rb_align);
155
+ }
137
156
  }
138
157
 
139
158
  static void
@@ -280,17 +299,6 @@ cb_link_attribute(VALUE key, VALUE val, VALUE payload)
280
299
  return 0;
281
300
  }
282
301
 
283
- static void
284
- rndr_link_attributes(struct buf *ob, const struct buf *url, void *opaque)
285
- {
286
- struct redcarpet_renderopt *opt = opaque;
287
- struct rb_redcarpet_rndr *rndr;
288
-
289
- Data_Get_Struct(opt->self, struct rb_redcarpet_rndr, rndr);
290
- Check_Type(opt->link_attributes, T_HASH);
291
- rb_hash_foreach(opt->link_attributes, &cb_link_attribute, (VALUE)ob);
292
- }
293
-
294
302
  static struct sd_callbacks rb_redcarpet_callbacks = {
295
303
  rndr_blockcode,
296
304
  rndr_blockquote,
@@ -369,22 +377,47 @@ static const char *rb_redcarpet_method_names[] = {
369
377
 
370
378
  static const size_t rb_redcarpet_method_count = sizeof(rb_redcarpet_method_names)/sizeof(char *);
371
379
 
372
- static void rb_redcarpet_rbase_mark(struct rb_redcarpet_rndr *rndr)
380
+ static void rb_redcarpet_rbase_mark(void *data)
373
381
  {
382
+ struct rb_redcarpet_rndr *rndr = (struct rb_redcarpet_rndr *)data;
374
383
  if (rndr->options.link_attributes)
375
384
  rb_gc_mark(rndr->options.link_attributes);
376
385
  }
377
386
 
378
- static void rndr_deallocate(void *rndr)
387
+ static const rb_data_type_t rb_redcarpet_rndr_type = {
388
+ "Redcarpet/rndr",
389
+ {
390
+ rb_redcarpet_rbase_mark,
391
+ RUBY_TYPED_DEFAULT_FREE,
392
+ },
393
+ 0,
394
+ 0,
395
+ RUBY_TYPED_FREE_IMMEDIATELY | RUBY_TYPED_WB_PROTECTED,
396
+ };
397
+
398
+ struct rb_redcarpet_rndr * rb_redcarpet_rndr_unwrap(VALUE self)
379
399
  {
380
- xfree(rndr);
400
+ struct rb_redcarpet_rndr *rndr;
401
+ TypedData_Get_Struct(self, struct rb_redcarpet_rndr, &rb_redcarpet_rndr_type, rndr);
402
+ return rndr;
381
403
  }
382
404
 
383
405
  static VALUE rb_redcarpet_rbase_alloc(VALUE klass)
384
406
  {
385
407
  struct rb_redcarpet_rndr *rndr = ALLOC(struct rb_redcarpet_rndr);
386
408
  memset(rndr, 0x0, sizeof(struct rb_redcarpet_rndr));
387
- return Data_Wrap_Struct(klass, rb_redcarpet_rbase_mark, rndr_deallocate, rndr);
409
+ return TypedData_Wrap_Struct(klass, &rb_redcarpet_rndr_type, rndr);
410
+ }
411
+
412
+ static void
413
+ rndr_link_attributes(struct buf *ob, const struct buf *url, void *opaque)
414
+ {
415
+ struct redcarpet_renderopt *opt = opaque;
416
+ struct rb_redcarpet_rndr *rndr;
417
+
418
+ TypedData_Get_Struct(opt->self, struct rb_redcarpet_rndr, &rb_redcarpet_rndr_type, rndr);
419
+ Check_Type(opt->link_attributes, T_HASH);
420
+ rb_hash_foreach(opt->link_attributes, &cb_link_attribute, (VALUE)ob);
388
421
  }
389
422
 
390
423
  static void rb_redcarpet__overload(VALUE self, VALUE base_class)
@@ -392,7 +425,7 @@ static void rb_redcarpet__overload(VALUE self, VALUE base_class)
392
425
  struct rb_redcarpet_rndr *rndr;
393
426
  VALUE options_ivar;
394
427
 
395
- Data_Get_Struct(self, struct rb_redcarpet_rndr, rndr);
428
+ TypedData_Get_Struct(self, struct rb_redcarpet_rndr, &rb_redcarpet_rndr_type, rndr);
396
429
  rndr->options.self = self;
397
430
  rndr->options.base_class = base_class;
398
431
 
@@ -429,7 +462,7 @@ static VALUE rb_redcarpet_html_init(int argc, VALUE *argv, VALUE self)
429
462
  unsigned int render_flags = 0;
430
463
  VALUE hash, link_attr = Qnil;
431
464
 
432
- Data_Get_Struct(self, struct rb_redcarpet_rndr, rndr);
465
+ TypedData_Get_Struct(self, struct rb_redcarpet_rndr, &rb_redcarpet_rndr_type, rndr);
433
466
 
434
467
  if (rb_scan_args(argc, argv, "01", &hash) == 1) {
435
468
  Check_Type(hash, T_HASH);
@@ -481,7 +514,7 @@ static VALUE rb_redcarpet_html_init(int argc, VALUE *argv, VALUE self)
481
514
  rb_redcarpet__overload(self, rb_cRenderHTML);
482
515
 
483
516
  if (!NIL_P(link_attr)) {
484
- rndr->options.link_attributes = link_attr;
517
+ RB_OBJ_WRITE(self, &rndr->options.link_attributes, link_attr);
485
518
  rndr->options.html.link_attributes = &rndr_link_attributes;
486
519
  }
487
520
 
@@ -494,7 +527,7 @@ static VALUE rb_redcarpet_htmltoc_init(int argc, VALUE *argv, VALUE self)
494
527
  unsigned int render_flags = HTML_TOC;
495
528
  VALUE hash, nesting_level = Qnil;
496
529
 
497
- Data_Get_Struct(self, struct rb_redcarpet_rndr, rndr);
530
+ TypedData_Get_Struct(self, struct rb_redcarpet_rndr, &rb_redcarpet_rndr_type, rndr);
498
531
 
499
532
  if (rb_scan_args(argc, argv, "01", &hash) == 1) {
500
533
  Check_Type(hash, T_HASH);
@@ -49,4 +49,6 @@ struct rb_redcarpet_rndr {
49
49
  struct redcarpet_renderopt options;
50
50
  };
51
51
 
52
+ struct rb_redcarpet_rndr * rb_redcarpet_rndr_unwrap(VALUE);
53
+
52
54
  #endif
data/lib/redcarpet.rb CHANGED
@@ -2,7 +2,7 @@ require 'redcarpet.so'
2
2
  require 'redcarpet/compat'
3
3
 
4
4
  module Redcarpet
5
- VERSION = '3.5.1'
5
+ VERSION = '3.6.1'
6
6
 
7
7
  class Markdown
8
8
  attr_reader :renderer
data/redcarpet.gemspec CHANGED
@@ -1,17 +1,19 @@
1
1
  # encoding: utf-8
2
2
  Gem::Specification.new do |s|
3
3
  s.name = 'redcarpet'
4
- s.version = '3.5.1'
4
+ s.version = '3.6.1'
5
5
  s.summary = "Markdown that smells nice"
6
6
  s.description = 'A fast, safe and extensible Markdown to (X)HTML parser'
7
- s.date = '2020-12-15'
7
+ s.date = '2025-02-25'
8
8
  s.email = 'vicent@github.com'
9
- s.homepage = 'http://github.com/vmg/redcarpet'
9
+ s.homepage = 'https://github.com/vmg/redcarpet'
10
10
  s.authors = ["Natacha Porté", "Vicent Martí"]
11
11
  s.license = 'MIT'
12
12
  s.required_ruby_version = '>= 1.9.2'
13
13
  # = MANIFEST =
14
14
  s.files = %w[
15
+ CHANGELOG.md
16
+ CONTRIBUTING.md
15
17
  COPYING
16
18
  Gemfile
17
19
  README.markdown
@@ -27,6 +29,7 @@ Gem::Specification.new do |s|
27
29
  ext/redcarpet/houdini_html_e.c
28
30
  ext/redcarpet/html.c
29
31
  ext/redcarpet/html.h
32
+ ext/redcarpet/html_block_names.txt
30
33
  ext/redcarpet/html_blocks.h
31
34
  ext/redcarpet/html_smartypants.c
32
35
  ext/redcarpet/markdown.c
@@ -42,21 +45,6 @@ Gem::Specification.new do |s|
42
45
  lib/redcarpet/render_man.rb
43
46
  lib/redcarpet/render_strip.rb
44
47
  redcarpet.gemspec
45
- test/benchmark.rb
46
- test/custom_render_test.rb
47
- test/fixtures/benchmark.md
48
- test/html5_test.rb
49
- test/html_render_test.rb
50
- test/html_toc_render_test.rb
51
- test/markdown_test.rb
52
- test/pathological_inputs_test.rb
53
- test/redcarpet_bin_test.rb
54
- test/redcarpet_compat_test.rb
55
- test/safe_render_test.rb
56
- test/smarty_html_test.rb
57
- test/smarty_pants_test.rb
58
- test/stripdown_render_test.rb
59
- test/test_helper.rb
60
48
  ]
61
49
  # = MANIFEST =
62
50
  s.test_files = s.files.grep(%r{^test/})
@@ -65,7 +53,7 @@ Gem::Specification.new do |s|
65
53
  s.executables = ["redcarpet"]
66
54
  s.require_paths = ["lib"]
67
55
 
68
- s.add_development_dependency "rake", "~> 12.2.1"
69
- s.add_development_dependency "rake-compiler", "~> 1.0.3"
70
- s.add_development_dependency "test-unit", "~> 3.2.3"
56
+ s.add_development_dependency "rake", "~> 13"
57
+ s.add_development_dependency "rake-compiler", "~> 1.1"
58
+ s.add_development_dependency "test-unit", "~> 3.5"
71
59
  end