tight-redcarpet 3.2.0 → 3.3.2t
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.
- checksums.yaml +4 -4
- data/COPYING +17 -11
- data/Gemfile +2 -2
- data/README.markdown +21 -15
- data/bin/redcarpet +4 -40
- data/ext/redcarpet/autolink.c +17 -11
- data/ext/redcarpet/autolink.h +17 -11
- data/ext/redcarpet/buffer.c +22 -16
- data/ext/redcarpet/buffer.h +17 -11
- data/ext/redcarpet/houdini.h +22 -0
- data/ext/redcarpet/houdini_href_e.c +22 -0
- data/ext/redcarpet/houdini_html_e.c +22 -0
- data/ext/redcarpet/html.c +54 -55
- data/ext/redcarpet/html.h +17 -17
- data/ext/redcarpet/html_smartypants.c +27 -15
- data/ext/redcarpet/markdown.c +25 -17
- data/ext/redcarpet/markdown.h +17 -12
- data/ext/redcarpet/rc_markdown.c +18 -11
- data/ext/redcarpet/rc_render.c +23 -12
- data/ext/redcarpet/redcarpet.h +22 -0
- data/ext/redcarpet/stack.c +22 -0
- data/ext/redcarpet/stack.h +22 -0
- data/lib/redcarpet.rb +2 -2
- data/lib/redcarpet/cli.rb +86 -0
- data/lib/redcarpet/render_strip.rb +13 -1
- data/redcarpet.gemspec +7 -5
- data/test/custom_render_test.rb +1 -1
- data/test/fixtures/benchmark.md +232 -0
- data/test/html_render_test.rb +5 -5
- data/test/html_toc_render_test.rb +2 -3
- data/test/markdown_test.rb +60 -26
- data/test/redcarpet_bin_test.rb +80 -0
- data/test/redcarpet_compat_test.rb +6 -6
- data/test/safe_render_test.rb +5 -6
- data/test/smarty_html_test.rb +8 -8
- data/test/smarty_pants_test.rb +5 -0
- data/test/stripdown_render_test.rb +26 -5
- data/test/test_helper.rb +9 -11
- metadata +14 -23
data/ext/redcarpet/html.h
CHANGED
@@ -1,17 +1,23 @@
|
|
1
1
|
/*
|
2
|
-
* Copyright (c)
|
2
|
+
* Copyright (c) 2015, Vicent Marti
|
3
3
|
*
|
4
|
-
* Permission
|
5
|
-
*
|
6
|
-
*
|
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
|
-
*
|
9
|
-
*
|
10
|
-
*
|
11
|
-
*
|
12
|
-
*
|
13
|
-
*
|
14
|
-
* OR
|
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 HTML_H__
|
@@ -70,12 +76,6 @@ sdhtml_toc_renderer(struct sd_callbacks *callbacks, struct html_renderopt *optio
|
|
70
76
|
extern void
|
71
77
|
sdhtml_smartypants(struct buf *ob, const uint8_t *text, size_t size);
|
72
78
|
|
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
79
|
#ifdef __cplusplus
|
80
80
|
}
|
81
81
|
#endif
|
@@ -1,17 +1,23 @@
|
|
1
1
|
/*
|
2
|
-
* Copyright (c)
|
2
|
+
* Copyright (c) 2015, Vicent Marti
|
3
3
|
*
|
4
|
-
* Permission
|
5
|
-
*
|
6
|
-
*
|
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
|
-
*
|
9
|
-
*
|
10
|
-
*
|
11
|
-
*
|
12
|
-
*
|
13
|
-
*
|
14
|
-
* OR
|
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"
|
@@ -83,6 +89,12 @@ word_boundary(uint8_t c)
|
|
83
89
|
return c == 0 || isspace(c) || ispunct(c);
|
84
90
|
}
|
85
91
|
|
92
|
+
static inline int
|
93
|
+
fraction_boundary(uint8_t c)
|
94
|
+
{
|
95
|
+
return c == 0 || isspace(c) || (c != '/' && ispunct(c));
|
96
|
+
}
|
97
|
+
|
86
98
|
// If 'text' begins with any kind of single quote (e.g. "'" or "'" etc.),
|
87
99
|
// returns the length of the sequence of characters that makes up the single-
|
88
100
|
// quote. Otherwise, returns zero.
|
@@ -282,16 +294,16 @@ smartypants_cb__backtick(struct buf *ob, struct smartypants_data *smrt, uint8_t
|
|
282
294
|
static size_t
|
283
295
|
smartypants_cb__number(struct buf *ob, struct smartypants_data *smrt, uint8_t previous_char, const uint8_t *text, size_t size)
|
284
296
|
{
|
285
|
-
if (
|
297
|
+
if (fraction_boundary(previous_char) && size >= 3) {
|
286
298
|
if (text[0] == '1' && text[1] == '/' && text[2] == '2') {
|
287
|
-
if (size == 3 ||
|
299
|
+
if (size == 3 || fraction_boundary(text[3])) {
|
288
300
|
BUFPUTSL(ob, "½");
|
289
301
|
return 2;
|
290
302
|
}
|
291
303
|
}
|
292
304
|
|
293
305
|
if (text[0] == '1' && text[1] == '/' && text[2] == '4') {
|
294
|
-
if (size == 3 ||
|
306
|
+
if (size == 3 || fraction_boundary(text[3]) ||
|
295
307
|
(size >= 5 && tolower(text[3]) == 't' && tolower(text[4]) == 'h')) {
|
296
308
|
BUFPUTSL(ob, "¼");
|
297
309
|
return 2;
|
@@ -299,7 +311,7 @@ smartypants_cb__number(struct buf *ob, struct smartypants_data *smrt, uint8_t pr
|
|
299
311
|
}
|
300
312
|
|
301
313
|
if (text[0] == '3' && text[1] == '/' && text[2] == '4') {
|
302
|
-
if (size == 3 ||
|
314
|
+
if (size == 3 || fraction_boundary(text[3]) ||
|
303
315
|
(size >= 6 && tolower(text[3]) == 't' && tolower(text[4]) == 'h' && tolower(text[5]) == 's')) {
|
304
316
|
BUFPUTSL(ob, "¾");
|
305
317
|
return 2;
|
data/ext/redcarpet/markdown.c
CHANGED
@@ -1,20 +1,24 @@
|
|
1
|
-
/* markdown.c - generic markdown parser */
|
2
|
-
|
3
1
|
/*
|
4
2
|
* Copyright (c) 2009, Natacha Porté
|
5
|
-
* Copyright (c)
|
3
|
+
* Copyright (c) 2015, Vicent Marti
|
4
|
+
*
|
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:
|
6
11
|
*
|
7
|
-
*
|
8
|
-
*
|
9
|
-
* copyright notice and this permission notice appear in all copies.
|
12
|
+
* The above copyright notice and this permission notice shall be included in
|
13
|
+
* all copies or substantial portions of the Software.
|
10
14
|
*
|
11
|
-
* THE SOFTWARE IS PROVIDED "AS IS"
|
12
|
-
*
|
13
|
-
*
|
14
|
-
*
|
15
|
-
*
|
16
|
-
*
|
17
|
-
*
|
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.
|
18
22
|
*/
|
19
23
|
|
20
24
|
#include "markdown.h"
|
@@ -461,7 +465,7 @@ tag_length(uint8_t *data, size_t size, enum mkd_autolink *autolink)
|
|
461
465
|
static void
|
462
466
|
parse_inline(struct buf *ob, struct sd_markdown *rndr, uint8_t *data, size_t size)
|
463
467
|
{
|
464
|
-
size_t i = 0, end = 0;
|
468
|
+
size_t i = 0, end = 0, consumed = 0;
|
465
469
|
uint8_t action = 0;
|
466
470
|
struct buf work = { 0, 0, 0, 0 };
|
467
471
|
|
@@ -486,12 +490,13 @@ parse_inline(struct buf *ob, struct sd_markdown *rndr, uint8_t *data, size_t siz
|
|
486
490
|
if (end >= size) break;
|
487
491
|
i = end;
|
488
492
|
|
489
|
-
end = markdown_char_ptrs[(int)action](ob, rndr, data + i, i, size - i);
|
493
|
+
end = markdown_char_ptrs[(int)action](ob, rndr, data + i, i - consumed, size - i);
|
490
494
|
if (!end) /* no action from the callback */
|
491
495
|
end = i + 1;
|
492
496
|
else {
|
493
497
|
i += end;
|
494
498
|
end = i;
|
499
|
+
consumed = i;
|
495
500
|
}
|
496
501
|
}
|
497
502
|
}
|
@@ -1118,7 +1123,7 @@ char_link(struct buf *ob, struct sd_markdown *rndr, uint8_t *data, size_t offset
|
|
1118
1123
|
title_e--;
|
1119
1124
|
|
1120
1125
|
/* checking for closing quote presence */
|
1121
|
-
if (data[title_e] != '\'' &&
|
1126
|
+
if (data[title_e] != '\'' && data[title_e] != '"') {
|
1122
1127
|
title_b = title_e = 0;
|
1123
1128
|
link_e = i;
|
1124
1129
|
}
|
@@ -2866,7 +2871,7 @@ sd_markdown_render(struct buf *ob, const uint8_t *document, size_t doc_size, str
|
|
2866
2871
|
|
2867
2872
|
if (text->size) {
|
2868
2873
|
/* adding a final newline if not already present */
|
2869
|
-
if (text->data[text->size - 1] != '\n' &&
|
2874
|
+
if (text->data[text->size - 1] != '\n' && text->data[text->size - 1] != '\r')
|
2870
2875
|
bufputc(text, '\n');
|
2871
2876
|
|
2872
2877
|
parse_block(ob, md, text->data, text->size);
|
@@ -2879,6 +2884,9 @@ sd_markdown_render(struct buf *ob, const uint8_t *document, size_t doc_size, str
|
|
2879
2884
|
if (md->cb.doc_footer)
|
2880
2885
|
md->cb.doc_footer(ob, md->opaque);
|
2881
2886
|
|
2887
|
+
/* Null-terminate the buffer */
|
2888
|
+
bufcstr(ob);
|
2889
|
+
|
2882
2890
|
/* clean-up */
|
2883
2891
|
bufrelease(text);
|
2884
2892
|
free_link_refs(md->refs);
|
data/ext/redcarpet/markdown.h
CHANGED
@@ -1,19 +1,24 @@
|
|
1
|
-
/* markdown.h - generic markdown parser */
|
2
|
-
|
3
1
|
/*
|
4
2
|
* Copyright (c) 2009, Natacha Porté
|
3
|
+
* Copyright (c) 2015, Vicent Marti
|
4
|
+
*
|
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:
|
5
11
|
*
|
6
|
-
*
|
7
|
-
*
|
8
|
-
* copyright notice and this permission notice appear in all copies.
|
12
|
+
* The above copyright notice and this permission notice shall be included in
|
13
|
+
* all copies or substantial portions of the Software.
|
9
14
|
*
|
10
|
-
* THE SOFTWARE IS PROVIDED "AS IS"
|
11
|
-
*
|
12
|
-
*
|
13
|
-
*
|
14
|
-
*
|
15
|
-
*
|
16
|
-
*
|
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.
|
17
22
|
*/
|
18
23
|
|
19
24
|
#ifndef MARKDOWN_H__
|
data/ext/redcarpet/rc_markdown.c
CHANGED
@@ -1,18 +1,25 @@
|
|
1
1
|
/*
|
2
|
-
* Copyright (c)
|
2
|
+
* Copyright (c) 2015, Vicent Marti
|
3
3
|
*
|
4
|
-
* Permission
|
5
|
-
*
|
6
|
-
*
|
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
|
-
*
|
9
|
-
*
|
10
|
-
*
|
11
|
-
*
|
12
|
-
*
|
13
|
-
*
|
14
|
-
* OR
|
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
|
*/
|
22
|
+
|
16
23
|
#include "redcarpet.h"
|
17
24
|
|
18
25
|
VALUE rb_mRedcarpet;
|
data/ext/redcarpet/rc_render.c
CHANGED
@@ -1,17 +1,23 @@
|
|
1
1
|
/*
|
2
|
-
* Copyright (c)
|
2
|
+
* Copyright (c) 2015, Vicent Marti
|
3
3
|
*
|
4
|
-
* Permission
|
5
|
-
*
|
6
|
-
*
|
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
|
-
*
|
9
|
-
*
|
10
|
-
*
|
11
|
-
*
|
12
|
-
*
|
13
|
-
*
|
14
|
-
* OR
|
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 "redcarpet.h"
|
@@ -369,11 +375,16 @@ static void rb_redcarpet_rbase_mark(struct rb_redcarpet_rndr *rndr)
|
|
369
375
|
rb_gc_mark(rndr->options.link_attributes);
|
370
376
|
}
|
371
377
|
|
378
|
+
static void rndr_deallocate(void *rndr)
|
379
|
+
{
|
380
|
+
xfree(rndr);
|
381
|
+
}
|
382
|
+
|
372
383
|
static VALUE rb_redcarpet_rbase_alloc(VALUE klass)
|
373
384
|
{
|
374
385
|
struct rb_redcarpet_rndr *rndr = ALLOC(struct rb_redcarpet_rndr);
|
375
386
|
memset(rndr, 0x0, sizeof(struct rb_redcarpet_rndr));
|
376
|
-
return Data_Wrap_Struct(klass, rb_redcarpet_rbase_mark,
|
387
|
+
return Data_Wrap_Struct(klass, rb_redcarpet_rbase_mark, rndr_deallocate, rndr);
|
377
388
|
}
|
378
389
|
|
379
390
|
static void rb_redcarpet__overload(VALUE self, VALUE base_class)
|
data/ext/redcarpet/redcarpet.h
CHANGED
@@ -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 REDCARPET_H__
|
2
24
|
#define REDCARPET_H__
|
3
25
|
|
data/ext/redcarpet/stack.c
CHANGED
@@ -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 "stack.h"
|
2
24
|
#include <string.h>
|
3
25
|
|
data/ext/redcarpet/stack.h
CHANGED
@@ -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 STACK_H__
|
2
24
|
#define STACK_H__
|
3
25
|
|
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.2
|
5
|
+
VERSION = '3.3.2'
|
6
6
|
|
7
7
|
class Markdown
|
8
8
|
attr_reader :renderer
|
@@ -54,7 +54,7 @@ module Redcarpet
|
|
54
54
|
'>' => '>',
|
55
55
|
'"' => '"',
|
56
56
|
"'" => ''',
|
57
|
-
"/" => '/',
|
57
|
+
"/" => '/',
|
58
58
|
})
|
59
59
|
end
|
60
60
|
end
|
@@ -0,0 +1,86 @@
|
|
1
|
+
require 'redcarpet'
|
2
|
+
require 'optparse'
|
3
|
+
|
4
|
+
module Redcarpet
|
5
|
+
# This class aims at easing the creation of custom
|
6
|
+
# binary for your needs. For example, you can add new
|
7
|
+
# options or change the existing ones. The parsing
|
8
|
+
# is handled by Ruby's OptionParser. For instance:
|
9
|
+
#
|
10
|
+
# class Custom::CLI < Redcarpet::CLI
|
11
|
+
# def self.options_parser
|
12
|
+
# super.tap do |opts|
|
13
|
+
# opts.on("--rainbow") do
|
14
|
+
# @@options[:rainbow] = true
|
15
|
+
# end
|
16
|
+
# end
|
17
|
+
# end
|
18
|
+
#
|
19
|
+
# def self.render_object
|
20
|
+
# @@options[:rainbow] ? RainbowRender : super
|
21
|
+
# end
|
22
|
+
# end
|
23
|
+
class CLI
|
24
|
+
def self.options_parser
|
25
|
+
@@options = {
|
26
|
+
render_extensions: {},
|
27
|
+
parse_extensions: {},
|
28
|
+
smarty_pants: false
|
29
|
+
}
|
30
|
+
|
31
|
+
OptionParser.new do |opts|
|
32
|
+
opts.banner = "Usage: redcarpet [--parse <extension>...] " \
|
33
|
+
"[--render <extension>...] [--smarty] <file>..."
|
34
|
+
|
35
|
+
opts.on("--parse EXTENSION", "Enable a parsing extension") do |ext|
|
36
|
+
ext = ext.gsub('-', '_').to_sym
|
37
|
+
@@options[:parse_extensions][ext] = true
|
38
|
+
end
|
39
|
+
|
40
|
+
opts.on("--render EXTENSION", "Enable a rendering extension") do |ext|
|
41
|
+
ext = ext.gsub('-', '_').to_sym
|
42
|
+
@@options[:render_extensions][ext] = true
|
43
|
+
end
|
44
|
+
|
45
|
+
opts.on("--smarty", "Enable Smarty Pants") do
|
46
|
+
@@options[:smarty_pants] = true
|
47
|
+
end
|
48
|
+
|
49
|
+
opts.on_tail("-v", "--version", "Display the current version") do
|
50
|
+
STDOUT.write "Redcarpet #{Redcarpet::VERSION}"
|
51
|
+
exit
|
52
|
+
end
|
53
|
+
|
54
|
+
opts.on_tail("-h", "--help", "Display this help message") do
|
55
|
+
puts opts
|
56
|
+
exit
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def self.process(args)
|
62
|
+
self.legacy_parse!(args)
|
63
|
+
self.options_parser.parse!(args)
|
64
|
+
STDOUT.write parser_object.render(ARGF.read)
|
65
|
+
end
|
66
|
+
|
67
|
+
def self.render_object
|
68
|
+
@@options[:smarty_pants] ? Render::SmartyHTML : Render::HTML
|
69
|
+
end
|
70
|
+
|
71
|
+
def self.parser_object
|
72
|
+
renderer = render_object.new(@@options[:render_extensions])
|
73
|
+
Redcarpet::Markdown.new(renderer, @@options[:parse_extensions])
|
74
|
+
end
|
75
|
+
|
76
|
+
def self.legacy_parse!(args) # :nodoc:
|
77
|
+
# Workaround for backward compatibility as OptionParser
|
78
|
+
# doesn't support the --flag-OPTION syntax.
|
79
|
+
args.select {|a| a =~ /--(parse|render)-/ }.each do |arg|
|
80
|
+
args.delete(arg)
|
81
|
+
arg = arg.partition(/\b-/)
|
82
|
+
args.push(arg.first, arg.last)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|