tight-redcarpet 3.2.0 → 3.3.2t

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0d789e647d9d2bfdd99bff901a26d1fe0513acfb
4
- data.tar.gz: e980f2395afd5e731b7ffbfaa18701c627458bb1
3
+ metadata.gz: cf3dc5590d70a25ee9b132d657ea5eaa8969dad9
4
+ data.tar.gz: fb3042ee7c682ba2cbe002fc98e5f212486e126e
5
5
  SHA512:
6
- metadata.gz: aa7805caaf2ce5bd875e89c9bd723c5ffdfc34e7ce53355619af0c89f472d4c6eef5bb48c37591d3ef6d269a01e125d134879d6fd022bf76f7f255f9bf866c5b
7
- data.tar.gz: 350f45ef2e36f7ab9ffb30e5664ab706bcce18e5710d31ac11b905bfe7702e1c99a31fc6599a0ec583fa3099ada9d4327cb93f844de445ed158025f69213e63e
6
+ metadata.gz: 8097f93b8ef15d63dbdb6949f92e5b152352837370e180767b3db3de3713018b3beb65b50626dff2c11b71c7cf6b39dbd196420f723252f64badfe919ae1f073
7
+ data.tar.gz: 7895715b616d1c825155073acdcc2783e80fb0b1e9d95d36f86d72c93855d8cf84730e9282293d9251195768c29dd13564c71e1165ee337deea7e8fa2013e8a6
data/COPYING CHANGED
@@ -1,14 +1,20 @@
1
1
  Copyright (c) 2009, Natacha Porté
2
- Copyright (c) 2011, Vicent Marti
2
+ Copyright (c) 2015, Vicent Marti
3
3
 
4
- Permission to use, copy, modify, and distribute this software for any
5
- purpose with or without fee is hereby granted, provided that the above
6
- copyright notice and this permission notice appear in all copies.
4
+ Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ of this software and associated documentation files (the "Software"), to deal
6
+ in the Software without restriction, including without limitation the rights
7
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the Software is
9
+ furnished to do so, subject to the following conditions:
7
10
 
8
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9
- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10
- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11
- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12
- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13
- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14
- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
11
+ The above copyright notice and this permission notice shall be included in
12
+ all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
+ THE SOFTWARE.
data/Gemfile CHANGED
@@ -3,7 +3,7 @@ source "https://rubygems.org/"
3
3
  gemspec
4
4
 
5
5
  group :benchmark do
6
- gem "benchmark-ips", "~> 1.2.0"
6
+ gem "benchmark-ips", "~> 2.3.0"
7
7
  gem "bluecloth", "~> 2.2.0"
8
- gem "kramdown", "~> 1.0.2"
8
+ gem "kramdown", "~> 1.8.0"
9
9
  end
data/README.markdown CHANGED
@@ -83,7 +83,7 @@ but starting with `www` are also handled.
83
83
 
84
84
  * `:disable_indented_code_blocks`: do not parse usual markdown
85
85
  code blocks. Markdown converts text with four spaces at
86
- the front of each line to code blocks. This options
86
+ the front of each line to code blocks. This option
87
87
  prevents it from doing so. Recommended to use
88
88
  with `fenced_code_blocks: true`.
89
89
 
@@ -159,7 +159,7 @@ safe.
159
159
  * `:with_toc_data`: add HTML anchors to each header in the output HTML,
160
160
  to allow linking to each section.
161
161
 
162
- * `:hard_wrap`: insert HTML `<br>` tags inside on paragraphs where the origin
162
+ * `:hard_wrap`: insert HTML `<br>` tags inside paragraphs where the original
163
163
  Markdown document had newlines (by default, Markdown ignores these newlines).
164
164
 
165
165
  * `:xhtml`: output XHTML-conformant tags. This option is always enabled in the
@@ -372,16 +372,22 @@ monkeypatches the Markdown class, you're a terrible human being. Just saying.
372
372
  Boring legal stuff
373
373
  ------------------
374
374
 
375
- Copyright (c) 2011-2014, Vicent Martí
376
-
377
- Permission to use, copy, modify, and/or distribute this software for any
378
- purpose with or without fee is hereby granted, provided that the above
379
- copyright notice and this permission notice appear in all copies.
380
-
381
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
382
- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
383
- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
384
- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
385
- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
386
- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
387
- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
375
+ Copyright (c) 2011-2015, Vicent Martí
376
+
377
+ Permission is hereby granted, free of charge, to any person obtaining a copy
378
+ of this software and associated documentation files (the "Software"), to deal
379
+ in the Software without restriction, including without limitation the rights
380
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
381
+ copies of the Software, and to permit persons to whom the Software is
382
+ furnished to do so, subject to the following conditions:
383
+
384
+ The above copyright notice and this permission notice shall be included in
385
+ all copies or substantial portions of the Software.
386
+
387
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
388
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
389
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
390
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
391
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
392
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
393
+ THE SOFTWARE.
data/bin/redcarpet CHANGED
@@ -1,43 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
- # Usage: redcarpet [--parse-<extension>...] [--render-<extension>...] [--smarty] [<file>...]
3
- # Convert one or more Markdown files to HTML and write to standard output. With
4
- # no <file> or when <file> is '-', read Markdown source text from standard input.
5
- # With <extension>s, perform additional Markdown processing before writing output.
6
- # With --smarty, use the SmartyHTML renderer
7
- if ARGV.include?('--help') or ARGV.include?('-h')
8
- File.read(__FILE__).split("\n").grep(/^# /).each do |line|
9
- puts line[2..-1]
10
- end
11
- exit 0
12
- end
2
+ lib_path = File.expand_path('../../lib', __FILE__)
3
+ $:.unshift(lib_path)
13
4
 
14
- require 'redcarpet'
5
+ require 'redcarpet/cli'
15
6
 
16
- if ARGV.include?('--version') or ARGV.include?('-v')
17
- puts "Redcarpet #{Redcarpet::VERSION}"
18
- exit 0
19
- end
20
-
21
- root = File.expand_path('../../', __FILE__)
22
- $:.unshift File.expand_path('lib', root)
23
-
24
- render_extensions = {}
25
- parse_extensions = {}
26
- renderer = Redcarpet::Render::HTML
27
-
28
- ARGV.delete_if do |arg|
29
- if arg =~ /^--render-([\w-]+)$/
30
- arg = $1.gsub('-', '_')
31
- render_extensions[arg.to_sym] = true
32
- elsif arg =~ /^--parse-([\w-]+)$/
33
- arg = $1.gsub('-', '_')
34
- parse_extensions[arg.to_sym] = true
35
- elsif arg == '--smarty'
36
- renderer = Redcarpet::Render::SmartyHTML
37
- else
38
- false
39
- end
40
- end
41
-
42
- render = renderer.new(render_extensions)
43
- STDOUT.write(Redcarpet::Markdown.new(render, parse_extensions).render(ARGF.read))
7
+ Redcarpet::CLI.process(ARGV)
@@ -1,17 +1,23 @@
1
1
  /*
2
- * Copyright (c) 2011, Vicent Marti
2
+ * Copyright (c) 2015, Vicent Marti
3
3
  *
4
- * Permission to use, copy, modify, and distribute this software for any
5
- * purpose with or without fee is hereby granted, provided that the above
6
- * copyright notice and this permission notice appear in all copies.
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
7
10
  *
8
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
+ * THE SOFTWARE.
15
21
  */
16
22
 
17
23
  #include "buffer.h"
@@ -1,17 +1,23 @@
1
1
  /*
2
- * Copyright (c) 2011, Vicent Marti
2
+ * Copyright (c) 2015, Vicent Marti
3
3
  *
4
- * Permission to use, copy, modify, and distribute this software for any
5
- * purpose with or without fee is hereby granted, provided that the above
6
- * copyright notice and this permission notice appear in all copies.
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
7
10
  *
8
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
+ * THE SOFTWARE.
15
21
  */
16
22
 
17
23
  #ifndef AUTOLINK_H__
@@ -1,18 +1,24 @@
1
1
  /*
2
2
  * Copyright (c) 2008, Natacha Porté
3
- * Copyright (c) 2011, Vicent Martí
3
+ * Copyright (c) 2015, Vicent Marti
4
4
  *
5
- * Permission to use, copy, modify, and distribute this software for any
6
- * purpose with or without fee is hereby granted, provided that the above
7
- * copyright notice and this permission notice appear in all copies.
5
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ * of this software and associated documentation files (the "Software"), to deal
7
+ * in the Software without restriction, including without limitation the rights
8
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ * copies of the Software, and to permit persons to whom the Software is
10
+ * furnished to do so, subject to the following conditions:
8
11
  *
9
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
12
+ * The above copyright notice and this permission notice shall be included in
13
+ * all copies or substantial portions of the Software.
14
+ *
15
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ * THE SOFTWARE.
16
22
  */
17
23
 
18
24
  #define BUFFER_MAX_ALLOC_SIZE (1024 * 1024 * 16) //16mb
@@ -101,7 +107,7 @@ bufcstr(const struct buf *buf)
101
107
  if (buf->size < buf->asize && buf->data[buf->size] == 0)
102
108
  return (char *)buf->data;
103
109
 
104
- if (buf->size + 1 <= buf->asize || bufgrow(buf, buf->size + 1) == 0) {
110
+ if (buf->size + 1 <= buf->asize || bufgrow(buf, buf->size + 1) == BUF_OK) {
105
111
  buf->data[buf->size] = 0;
106
112
  return (char *)buf->data;
107
113
  }
@@ -118,7 +124,7 @@ bufprintf(struct buf *buf, const char *fmt, ...)
118
124
 
119
125
  assert(buf && buf->unit);
120
126
 
121
- if (buf->size >= buf->asize && bufgrow(buf, buf->size + 1) < 0)
127
+ if (buf->size >= buf->asize && bufgrow(buf, buf->size + 1) < BUF_OK)
122
128
  return;
123
129
 
124
130
  va_start(ap, fmt);
@@ -136,7 +142,7 @@ bufprintf(struct buf *buf, const char *fmt, ...)
136
142
  }
137
143
 
138
144
  if ((size_t)n >= buf->asize - buf->size) {
139
- if (bufgrow(buf, buf->size + n + 1) < 0)
145
+ if (bufgrow(buf, buf->size + n + 1) < BUF_OK)
140
146
  return;
141
147
 
142
148
  va_start(ap, fmt);
@@ -156,7 +162,7 @@ bufput(struct buf *buf, const void *data, size_t len)
156
162
  {
157
163
  assert(buf && buf->unit);
158
164
 
159
- if (buf->size + len > buf->asize && bufgrow(buf, buf->size + len) < 0)
165
+ if (buf->size + len > buf->asize && bufgrow(buf, buf->size + len) < BUF_OK)
160
166
  return;
161
167
 
162
168
  memcpy(buf->data + buf->size, data, len);
@@ -177,7 +183,7 @@ bufputc(struct buf *buf, int c)
177
183
  {
178
184
  assert(buf && buf->unit);
179
185
 
180
- if (buf->size + 1 > buf->asize && bufgrow(buf, buf->size + 1) < 0)
186
+ if (buf->size + 1 > buf->asize && bufgrow(buf, buf->size + 1) < BUF_OK)
181
187
  return;
182
188
 
183
189
  buf->data[buf->size] = c;
@@ -1,18 +1,24 @@
1
1
  /*
2
2
  * Copyright (c) 2008, Natacha Porté
3
- * Copyright (c) 2011, Vicent Martí
3
+ * Copyright (c) 2015, Vicent Marti
4
4
  *
5
- * Permission to use, copy, modify, and distribute this software for any
6
- * purpose with or without fee is hereby granted, provided that the above
7
- * copyright notice and this permission notice appear in all copies.
5
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ * of this software and associated documentation files (the "Software"), to deal
7
+ * in the Software without restriction, including without limitation the rights
8
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ * copies of the Software, and to permit persons to whom the Software is
10
+ * furnished to do so, subject to the following conditions:
8
11
  *
9
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
12
+ * The above copyright notice and this permission notice shall be included in
13
+ * all copies or substantial portions of the Software.
14
+ *
15
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ * THE SOFTWARE.
16
22
  */
17
23
 
18
24
  #ifndef BUFFER_H__
@@ -1,3 +1,25 @@
1
+ /*
2
+ * Copyright (c) 2015, Vicent Marti
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
+ * THE SOFTWARE.
21
+ */
22
+
1
23
  #ifndef HOUDINI_H__
2
24
  #define HOUDINI_H__
3
25
 
@@ -1,3 +1,25 @@
1
+ /*
2
+ * Copyright (c) 2015, Vicent Marti
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
+ * THE SOFTWARE.
21
+ */
22
+
1
23
  #include <assert.h>
2
24
  #include <stdio.h>
3
25
  #include <string.h>
@@ -1,3 +1,25 @@
1
+ /*
2
+ * Copyright (c) 2015, Vicent Marti
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
+ * THE SOFTWARE.
21
+ */
22
+
1
23
  #include <assert.h>
2
24
  #include <stdio.h>
3
25
  #include <string.h>
data/ext/redcarpet/html.c CHANGED
@@ -1,18 +1,24 @@
1
1
  /*
2
2
  * Copyright (c) 2009, Natacha Porté
3
- * Copyright (c) 2011, Vicent Marti
3
+ * Copyright (c) 2015, Vicent Marti
4
4
  *
5
- * Permission to use, copy, modify, and distribute this software for any
6
- * purpose with or without fee is hereby granted, provided that the above
7
- * copyright notice and this permission notice appear in all copies.
5
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ * of this software and associated documentation files (the "Software"), to deal
7
+ * in the Software without restriction, including without limitation the rights
8
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ * copies of the Software, and to permit persons to whom the Software is
10
+ * furnished to do so, subject to the following conditions:
8
11
  *
9
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
12
+ * The above copyright notice and this permission notice shall be included in
13
+ * all copies or substantial portions of the Software.
14
+ *
15
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ * THE SOFTWARE.
16
22
  */
17
23
 
18
24
  #include "markdown.h"
@@ -264,51 +270,35 @@ rndr_linebreak(struct buf *ob, void *opaque)
264
270
  return 1;
265
271
  }
266
272
 
267
- char *header_anchor(const struct buf *buffer)
273
+ static void
274
+ rndr_header_anchor(struct buf *out, const struct buf *anchor)
268
275
  {
269
- size_t i, j, k, size = buffer->size;
270
-
271
- char text[size];
272
- strcpy(text, bufcstr(buffer));
273
-
274
- char raw_string[size];
276
+ static const char *STRIPPED = " -&+$,/:;=?@\"#{}|^~[]`\\*()%.!'";
275
277
 
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);
278
+ const uint8_t *a = anchor->data;
279
+ const size_t size = anchor->size;
280
+ size_t i = 0;
281
+ int stripped = 0, inserted = 0;
287
282
 
288
- part = strtok(NULL, "<>");
283
+ for (; i < size; ++i) {
284
+ if (a[i] == '<') {
285
+ while (i < size && a[i] != '>')
286
+ i++;
287
+ }
288
+ else if (strchr(STRIPPED, a[i])) {
289
+ if (inserted && !stripped)
290
+ bufputc(out, '-');
291
+ stripped = 1;
292
+ }
293
+ else {
294
+ bufputc(out, tolower(a[i]));
295
+ stripped = 0;
296
+ inserted++;
289
297
  }
290
-
291
- size = strlen(raw_string);
292
- } else {
293
- strcpy(raw_string, text);
294
- }
295
-
296
- char* heading = malloc(size * sizeof(char));
297
-
298
- /* Dasherize the string removing extra white spaces
299
- and stripped chars */
300
- for (i = 0, j = 0; i < size; ++i, ++j) {
301
- while (STRIPPED_CHAR(raw_string[i]) && STRIPPED_CHAR(raw_string[i+1]))
302
- i++;
303
-
304
- if (STRIPPED_CHAR(raw_string[i]))
305
- heading[j] = '-';
306
- else
307
- heading[j] = tolower(raw_string[i]);
308
298
  }
309
299
 
310
- heading[j++] = '\0';
311
- return heading;
300
+ if (stripped)
301
+ out->size--;
312
302
  }
313
303
 
314
304
  static void
@@ -319,8 +309,11 @@ rndr_header(struct buf *ob, const struct buf *text, int level, void *opaque)
319
309
  if (ob->size)
320
310
  bufputc(ob, '\n');
321
311
 
322
- if ((options->flags & HTML_TOC) && (level <= options->toc_data.nesting_level))
323
- bufprintf(ob, "<h%d id=\"%s\">", level, header_anchor(text));
312
+ if ((options->flags & HTML_TOC) && (level <= options->toc_data.nesting_level)) {
313
+ bufprintf(ob, "<h%d id=\"", level);
314
+ rndr_header_anchor(ob, text);
315
+ BUFPUTSL(ob, "\">");
316
+ }
324
317
  else
325
318
  bufprintf(ob, "<h%d>", level);
326
319
 
@@ -482,7 +475,10 @@ rndr_image(struct buf *ob, const struct buf *link, const struct buf *title, cons
482
475
  return 0;
483
476
 
484
477
  BUFPUTSL(ob, "<img src=\"");
485
- escape_href(ob, link->data, link->size);
478
+
479
+ if (link && link->size)
480
+ escape_href(ob, link->data, link->size);
481
+
486
482
  BUFPUTSL(ob, "\" alt=\"");
487
483
 
488
484
  if (alt && alt->size)
@@ -490,7 +486,8 @@ rndr_image(struct buf *ob, const struct buf *link, const struct buf *title, cons
490
486
 
491
487
  if (title && title->size) {
492
488
  BUFPUTSL(ob, "\" title=\"");
493
- escape_html(ob, title->data, title->size); }
489
+ escape_html(ob, title->data, title->size);
490
+ }
494
491
 
495
492
  bufputs(ob, USE_XHTML(options) ? "\"/>" : "\">");
496
493
  return 1;
@@ -685,7 +682,9 @@ toc_header(struct buf *ob, const struct buf *text, int level, void *opaque)
685
682
  BUFPUTSL(ob,"</li>\n<li>\n");
686
683
  }
687
684
 
688
- bufprintf(ob, "<a href=\"#%s\">", header_anchor(text));
685
+ bufprintf(ob, "<a href=\"#");
686
+ rndr_header_anchor(ob, text);
687
+ BUFPUTSL(ob, "\">");
689
688
 
690
689
  if (text) {
691
690
  if (options->flags & HTML_ESCAPE)