redcarpet 3.3.1 → 3.3.2

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of redcarpet might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 357df7331e4bc2256b21132e897105ce6241494b
4
- data.tar.gz: 28ce2d2ad837940fff06c2a4ee3a6b501fc3d6fe
3
+ metadata.gz: 4549cbe772995b6ab432142d20b4e4de5c45229c
4
+ data.tar.gz: b80438cae22fe723e749a432fcaaa7656f7f660b
5
5
  SHA512:
6
- metadata.gz: 2971c2bea2d9117e85e87ee9d889b6ef466fedff78c35286847bba884ca4591c7e672b12032f371bff8a02cb308a703689982b6056cc0ca90d6bb8eaf9f1f3af
7
- data.tar.gz: 987022b77e2b3bdbf6b87191c9b90056da7c1eed3a30b29f510ab6bbbd0268d040d08399a67237cbde425656ea5704867c086b7d400c4458ae4a868da7c6ee5c
6
+ metadata.gz: 0a04dd8f57fdeb53ecb79c28e680915c607d6e4b95b7888b7b3bc86ea1729d9b1aeccf710b00d1849989ce940aaccdc126e796d17acbbdd3ca3e8b924e756673
7
+ data.tar.gz: fe26df7e15e06d3a34e5a253000d5cfc8c0c77e2b5cd56ad04f0484af90349bfbb84e1b5d80df3ac189a3509c1b46d8f56e9f8d4033b00350410775856f6d63a
@@ -264,56 +264,35 @@ rndr_linebreak(struct buf *ob, void *opaque)
264
264
  return 1;
265
265
  }
266
266
 
267
- char *header_anchor(const struct buf *buffer)
267
+ static void
268
+ rndr_header_anchor(struct buf *out, const struct buf *anchor)
268
269
  {
269
- size_t i = 0, j, k, size = buffer->size;
270
-
271
- char text[size];
272
- strcpy(text, bufcstr(buffer));
273
-
274
- char raw_string[size];
270
+ static const char *STRIPPED = " -&+$,/:;=?@\"#{}|^~[]`\\*()%.!'";
275
271
 
276
- /* Strip down the inline HTML markup if needed */
277
- if (strchr(text, '<') < strchr(text, '>')) {
278
- char* part = strtok(text, "<>");
279
-
280
- /* Once every two times, the yielded token is the
281
- content of a HTML tag so we don't need to copy it */
282
- for (k = 0; part != NULL; k++) {
283
- if (k == 0)
284
- strcpy(raw_string, part);
285
- else if (k % 2 == 0)
286
- strcat(raw_string, part);
272
+ const uint8_t *a = anchor->data;
273
+ const size_t size = anchor->size;
274
+ size_t i = 0;
275
+ int stripped = 0, inserted = 0;
287
276
 
288
- part = strtok(NULL, "<>");
277
+ for (; i < size; ++i) {
278
+ if (a[i] == '<') {
279
+ while (i < size && a[i] != '>')
280
+ i++;
281
+ }
282
+ else if (strchr(STRIPPED, a[i])) {
283
+ if (inserted && !stripped)
284
+ bufputc(out, '-');
285
+ stripped = 1;
286
+ }
287
+ else {
288
+ bufputc(out, tolower(a[i]));
289
+ stripped = 0;
290
+ inserted++;
289
291
  }
290
-
291
- size = strlen(raw_string);
292
- } else {
293
- strcpy(raw_string, text);
294
- }
295
-
296
- char* heading = malloc(size * sizeof(char));
297
-
298
- /* Remove leading stripped chars */
299
- while (STRIPPED_CHAR(raw_string[i])) i++;
300
-
301
- /* Dasherize the string removing extra white spaces
302
- and stripped chars */
303
- for (j = 0; i < size; i++, j++) {
304
- while ((i+1) < size && STRIPPED_CHAR(raw_string[i]) && STRIPPED_CHAR(raw_string[i+1]))
305
- i++;
306
-
307
- if (STRIPPED_CHAR(raw_string[i]) && i == size - 1)
308
- break;
309
- else if (STRIPPED_CHAR(raw_string[i]))
310
- heading[j] = '-';
311
- else
312
- heading[j] = tolower(raw_string[i]);
313
292
  }
314
293
 
315
- heading[j++] = '\0';
316
- return heading;
294
+ if (stripped)
295
+ out->size--;
317
296
  }
318
297
 
319
298
  static void
@@ -324,8 +303,11 @@ rndr_header(struct buf *ob, const struct buf *text, int level, void *opaque)
324
303
  if (ob->size)
325
304
  bufputc(ob, '\n');
326
305
 
327
- if ((options->flags & HTML_TOC) && (level <= options->toc_data.nesting_level))
328
- bufprintf(ob, "<h%d id=\"%s\">", level, header_anchor(text));
306
+ if ((options->flags & HTML_TOC) && (level <= options->toc_data.nesting_level)) {
307
+ bufprintf(ob, "<h%d id=\"", level);
308
+ rndr_header_anchor(ob, text);
309
+ BUFPUTSL(ob, "\">");
310
+ }
329
311
  else
330
312
  bufprintf(ob, "<h%d>", level);
331
313
 
@@ -694,7 +676,9 @@ toc_header(struct buf *ob, const struct buf *text, int level, void *opaque)
694
676
  BUFPUTSL(ob,"</li>\n<li>\n");
695
677
  }
696
678
 
697
- bufprintf(ob, "<a href=\"#%s\">", header_anchor(text));
679
+ bufprintf(ob, "<a href=\"#");
680
+ rndr_header_anchor(ob, text);
681
+ BUFPUTSL(ob, "\">");
698
682
 
699
683
  if (text) {
700
684
  if (options->flags & HTML_ESCAPE)
@@ -70,12 +70,6 @@ sdhtml_toc_renderer(struct sd_callbacks *callbacks, struct html_renderopt *optio
70
70
  extern void
71
71
  sdhtml_smartypants(struct buf *ob, const uint8_t *text, size_t size);
72
72
 
73
- /* header method used internally in Redcarpet */
74
- char *header_anchor(const struct buf *buffer);
75
-
76
- #define STRIPPED_CHARS " -&+$,/:;=?@\"#{}|^~[]`\\*()%.!'"
77
- #define STRIPPED_CHAR(x) (strchr(STRIPPED_CHARS, x) != NULL)
78
-
79
73
  #ifdef __cplusplus
80
74
  }
81
75
  #endif
@@ -2,7 +2,7 @@ require 'redcarpet.so'
2
2
  require 'redcarpet/compat'
3
3
 
4
4
  module Redcarpet
5
- VERSION = '3.3.1'
5
+ VERSION = '3.3.2'
6
6
 
7
7
  class Markdown
8
8
  attr_reader :renderer
@@ -1,10 +1,10 @@
1
1
  # encoding: utf-8
2
2
  Gem::Specification.new do |s|
3
3
  s.name = 'redcarpet'
4
- s.version = '3.3.1'
4
+ s.version = '3.3.2'
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 = '2015-06-07'
7
+ s.date = '2015-06-22'
8
8
  s.email = 'vicent@github.com'
9
9
  s.homepage = 'http://github.com/vmg/redcarpet'
10
10
  s.authors = ["Natacha Porté", "Vicent Martí"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redcarpet
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.3.1
4
+ version: 3.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Natacha Porté
@@ -9,34 +9,34 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-06-07 00:00:00.000000000 Z
12
+ date: 2015-06-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake-compiler
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - ~>
18
+ - - "~>"
19
19
  - !ruby/object:Gem::Version
20
20
  version: 0.8.3
21
21
  type: :development
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
- - - ~>
25
+ - - "~>"
26
26
  - !ruby/object:Gem::Version
27
27
  version: 0.8.3
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: test-unit
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
- - - ~>
32
+ - - "~>"
33
33
  - !ruby/object:Gem::Version
34
34
  version: 3.0.9
35
35
  type: :development
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
- - - ~>
39
+ - - "~>"
40
40
  - !ruby/object:Gem::Version
41
41
  version: 3.0.9
42
42
  description: A fast, safe and extensible Markdown to (X)HTML parser
@@ -103,17 +103,17 @@ require_paths:
103
103
  - lib
104
104
  required_ruby_version: !ruby/object:Gem::Requirement
105
105
  requirements:
106
- - - '>='
106
+ - - ">="
107
107
  - !ruby/object:Gem::Version
108
108
  version: 1.9.2
109
109
  required_rubygems_version: !ruby/object:Gem::Requirement
110
110
  requirements:
111
- - - '>='
111
+ - - ">="
112
112
  - !ruby/object:Gem::Version
113
113
  version: '0'
114
114
  requirements: []
115
115
  rubyforge_project:
116
- rubygems_version: 2.0.14
116
+ rubygems_version: 2.2.2
117
117
  signing_key:
118
118
  specification_version: 4
119
119
  summary: Markdown that smells nice