redcarpet 3.0.0 → 3.1.0
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 +7 -0
- data/Gemfile +11 -0
- data/README.markdown +43 -25
- data/Rakefile +4 -1
- data/bin/redcarpet +8 -3
- data/ext/redcarpet/autolink.h +2 -2
- data/ext/redcarpet/buffer.c +2 -31
- data/ext/redcarpet/buffer.h +2 -8
- data/ext/redcarpet/houdini.h +0 -8
- data/ext/redcarpet/houdini_html_e.c +3 -8
- data/ext/redcarpet/html.c +124 -33
- data/ext/redcarpet/html.h +4 -4
- data/ext/redcarpet/markdown.c +345 -22
- data/ext/redcarpet/markdown.h +10 -13
- data/ext/redcarpet/rc_markdown.c +6 -0
- data/ext/redcarpet/rc_render.c +49 -5
- data/ext/redcarpet/stack.c +0 -19
- data/ext/redcarpet/stack.h +0 -3
- data/lib/redcarpet.rb +8 -8
- data/lib/redcarpet/render_strip.rb +4 -2
- data/redcarpet.gemspec +4 -4
- data/test/html_render_test.rb +88 -4
- data/test/html_toc_render_test.rb +55 -0
- data/test/markdown_test.rb +43 -6
- data/test/smarty_html_test.rb +15 -0
- metadata +10 -48
data/ext/redcarpet/markdown.h
CHANGED
@@ -16,8 +16,8 @@
|
|
16
16
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
17
17
|
*/
|
18
18
|
|
19
|
-
#ifndef
|
20
|
-
#define
|
19
|
+
#ifndef MARKDOWN_H__
|
20
|
+
#define MARKDOWN_H__
|
21
21
|
|
22
22
|
#include "buffer.h"
|
23
23
|
#include "autolink.h"
|
@@ -26,11 +26,6 @@
|
|
26
26
|
extern "C" {
|
27
27
|
#endif
|
28
28
|
|
29
|
-
#define SUNDOWN_VERSION "1.16.0"
|
30
|
-
#define SUNDOWN_VER_MAJOR 1
|
31
|
-
#define SUNDOWN_VER_MINOR 16
|
32
|
-
#define SUNDOWN_VER_REVISION 0
|
33
|
-
|
34
29
|
/********************
|
35
30
|
* TYPE DEFINITIONS *
|
36
31
|
********************/
|
@@ -61,7 +56,9 @@ enum mkd_extensions {
|
|
61
56
|
MKDEXT_SUPERSCRIPT = (1 << 7),
|
62
57
|
MKDEXT_LAX_SPACING = (1 << 8),
|
63
58
|
MKDEXT_DISABLE_INDENTED_CODE = (1 << 9),
|
64
|
-
MKDEXT_HIGHLIGHT = (1 << 10)
|
59
|
+
MKDEXT_HIGHLIGHT = (1 << 10),
|
60
|
+
MKDEXT_FOOTNOTES = (1 << 11),
|
61
|
+
MKDEXT_QUOTE = (1 << 12)
|
65
62
|
};
|
66
63
|
|
67
64
|
/* sd_callbacks - functions for rendering parsed data */
|
@@ -70,7 +67,7 @@ struct sd_callbacks {
|
|
70
67
|
void (*blockcode)(struct buf *ob, const struct buf *text, const struct buf *lang, void *opaque);
|
71
68
|
void (*blockquote)(struct buf *ob, const struct buf *text, void *opaque);
|
72
69
|
void (*blockhtml)(struct buf *ob,const struct buf *text, void *opaque);
|
73
|
-
void (*header)(struct buf *ob, const struct buf *text, int level, void *opaque);
|
70
|
+
void (*header)(struct buf *ob, const struct buf *text, int level, char *anchor, void *opaque);
|
74
71
|
void (*hrule)(struct buf *ob, void *opaque);
|
75
72
|
void (*list)(struct buf *ob, const struct buf *text, int flags, void *opaque);
|
76
73
|
void (*listitem)(struct buf *ob, const struct buf *text, int flags, void *opaque);
|
@@ -78,7 +75,8 @@ struct sd_callbacks {
|
|
78
75
|
void (*table)(struct buf *ob, const struct buf *header, const struct buf *body, void *opaque);
|
79
76
|
void (*table_row)(struct buf *ob, const struct buf *text, void *opaque);
|
80
77
|
void (*table_cell)(struct buf *ob, const struct buf *text, int flags, void *opaque);
|
81
|
-
|
78
|
+
void (*footnotes)(struct buf *ob, const struct buf *text, void *opaque);
|
79
|
+
void (*footnote_def)(struct buf *ob, const struct buf *text, unsigned int num, void *opaque);
|
82
80
|
|
83
81
|
/* span level callbacks - NULL or return 0 prints the span verbatim */
|
84
82
|
int (*autolink)(struct buf *ob, const struct buf *link, enum mkd_autolink type, void *opaque);
|
@@ -87,6 +85,7 @@ struct sd_callbacks {
|
|
87
85
|
int (*emphasis)(struct buf *ob, const struct buf *text, void *opaque);
|
88
86
|
int (*underline)(struct buf *ob, const struct buf *text, void *opaque);
|
89
87
|
int (*highlight)(struct buf *ob, const struct buf *text, void *opaque);
|
88
|
+
int (*quote)(struct buf *ob, const struct buf *text, void *opaque);
|
90
89
|
int (*image)(struct buf *ob, const struct buf *link, const struct buf *title, const struct buf *alt, void *opaque);
|
91
90
|
int (*linebreak)(struct buf *ob, void *opaque);
|
92
91
|
int (*link)(struct buf *ob, const struct buf *link, const struct buf *title, const struct buf *content, void *opaque);
|
@@ -94,6 +93,7 @@ struct sd_callbacks {
|
|
94
93
|
int (*triple_emphasis)(struct buf *ob, const struct buf *text, void *opaque);
|
95
94
|
int (*strikethrough)(struct buf *ob, const struct buf *text, void *opaque);
|
96
95
|
int (*superscript)(struct buf *ob, const struct buf *text, void *opaque);
|
96
|
+
int (*footnote_ref)(struct buf *ob, unsigned int num, void *opaque);
|
97
97
|
|
98
98
|
/* low level callbacks - NULL copies input directly into the output */
|
99
99
|
void (*entity)(struct buf *ob, const struct buf *entity, void *opaque);
|
@@ -131,9 +131,6 @@ sd_markdown_render(struct buf *ob, const uint8_t *document, size_t doc_size, str
|
|
131
131
|
extern void
|
132
132
|
sd_markdown_free(struct sd_markdown *md);
|
133
133
|
|
134
|
-
extern void
|
135
|
-
sd_version(int *major, int *minor, int *revision);
|
136
|
-
|
137
134
|
#ifdef __cplusplus
|
138
135
|
}
|
139
136
|
#endif
|
data/ext/redcarpet/rc_markdown.c
CHANGED
@@ -53,6 +53,9 @@ static void rb_redcarpet_md_flags(VALUE hash, unsigned int *enabled_extensions_p
|
|
53
53
|
if (rb_hash_lookup(hash, CSTR2SYM("highlight")) == Qtrue)
|
54
54
|
extensions |= MKDEXT_HIGHLIGHT;
|
55
55
|
|
56
|
+
if (rb_hash_lookup(hash, CSTR2SYM("quote")) == Qtrue)
|
57
|
+
extensions |= MKDEXT_QUOTE;
|
58
|
+
|
56
59
|
if (rb_hash_lookup(hash, CSTR2SYM("lax_spacing")) == Qtrue)
|
57
60
|
extensions |= MKDEXT_LAX_SPACING;
|
58
61
|
|
@@ -62,6 +65,9 @@ static void rb_redcarpet_md_flags(VALUE hash, unsigned int *enabled_extensions_p
|
|
62
65
|
if (rb_hash_lookup(hash, CSTR2SYM("superscript")) == Qtrue)
|
63
66
|
extensions |= MKDEXT_SUPERSCRIPT;
|
64
67
|
|
68
|
+
if (rb_hash_lookup(hash, CSTR2SYM("footnotes")) == Qtrue)
|
69
|
+
extensions |= MKDEXT_FOOTNOTES;
|
70
|
+
|
65
71
|
*enabled_extensions_p = extensions;
|
66
72
|
}
|
67
73
|
|
data/ext/redcarpet/rc_render.c
CHANGED
@@ -61,9 +61,9 @@ rndr_raw_block(struct buf *ob, const struct buf *text, void *opaque)
|
|
61
61
|
}
|
62
62
|
|
63
63
|
static void
|
64
|
-
rndr_header(struct buf *ob, const struct buf *text, int level, void *opaque)
|
64
|
+
rndr_header(struct buf *ob, const struct buf *text, int level, char *anchor, void *opaque)
|
65
65
|
{
|
66
|
-
BLOCK_CALLBACK("header",
|
66
|
+
BLOCK_CALLBACK("header", 3, buf2str(text), INT2FIX(level), rb_str_new2(anchor));
|
67
67
|
}
|
68
68
|
|
69
69
|
static void
|
@@ -130,7 +130,17 @@ rndr_tablecell(struct buf *ob, const struct buf *text, int align, void *opaque)
|
|
130
130
|
BLOCK_CALLBACK("table_cell", 2, buf2str(text), rb_align);
|
131
131
|
}
|
132
132
|
|
133
|
+
static void
|
134
|
+
rndr_footnotes(struct buf *ob, const struct buf *text, void *opaque)
|
135
|
+
{
|
136
|
+
BLOCK_CALLBACK("footnotes", 1, buf2str(text));
|
137
|
+
}
|
133
138
|
|
139
|
+
static void
|
140
|
+
rndr_footnote_def(struct buf *ob, const struct buf *text, unsigned int num, void *opaque)
|
141
|
+
{
|
142
|
+
BLOCK_CALLBACK("footnote_def", 2, buf2str(text), INT2FIX(num));
|
143
|
+
}
|
134
144
|
|
135
145
|
|
136
146
|
/***
|
@@ -173,6 +183,12 @@ rndr_highlight(struct buf *ob, const struct buf *text, void *opaque)
|
|
173
183
|
SPAN_CALLBACK("highlight", 1, buf2str(text));
|
174
184
|
}
|
175
185
|
|
186
|
+
static int
|
187
|
+
rndr_quote(struct buf *ob, const struct buf *text, void *opaque)
|
188
|
+
{
|
189
|
+
SPAN_CALLBACK("quote", 1, buf2str(text));
|
190
|
+
}
|
191
|
+
|
176
192
|
static int
|
177
193
|
rndr_image(struct buf *ob, const struct buf *link, const struct buf *title, const struct buf *alt, void *opaque)
|
178
194
|
{
|
@@ -215,6 +231,12 @@ rndr_superscript(struct buf *ob, const struct buf *text, void *opaque)
|
|
215
231
|
SPAN_CALLBACK("superscript", 1, buf2str(text));
|
216
232
|
}
|
217
233
|
|
234
|
+
static int
|
235
|
+
rndr_footnote_ref(struct buf *ob, unsigned int num, void *opaque)
|
236
|
+
{
|
237
|
+
SPAN_CALLBACK("footnote_ref", 1, INT2FIX(num));
|
238
|
+
}
|
239
|
+
|
218
240
|
/**
|
219
241
|
* direct writes
|
220
242
|
*/
|
@@ -275,6 +297,8 @@ static struct sd_callbacks rb_redcarpet_callbacks = {
|
|
275
297
|
rndr_table,
|
276
298
|
rndr_tablerow,
|
277
299
|
rndr_tablecell,
|
300
|
+
rndr_footnotes,
|
301
|
+
rndr_footnote_def,
|
278
302
|
|
279
303
|
rndr_autolink,
|
280
304
|
rndr_codespan,
|
@@ -282,6 +306,7 @@ static struct sd_callbacks rb_redcarpet_callbacks = {
|
|
282
306
|
rndr_emphasis,
|
283
307
|
rndr_underline,
|
284
308
|
rndr_highlight,
|
309
|
+
rndr_quote,
|
285
310
|
rndr_image,
|
286
311
|
rndr_linebreak,
|
287
312
|
rndr_link,
|
@@ -289,6 +314,7 @@ static struct sd_callbacks rb_redcarpet_callbacks = {
|
|
289
314
|
rndr_triple_emphasis,
|
290
315
|
rndr_strikethrough,
|
291
316
|
rndr_superscript,
|
317
|
+
rndr_footnote_ref,
|
292
318
|
|
293
319
|
rndr_entity,
|
294
320
|
rndr_normal_text,
|
@@ -309,6 +335,8 @@ static const char *rb_redcarpet_method_names[] = {
|
|
309
335
|
"table",
|
310
336
|
"table_row",
|
311
337
|
"table_cell",
|
338
|
+
"footnotes",
|
339
|
+
"footnote_def",
|
312
340
|
|
313
341
|
"autolink",
|
314
342
|
"codespan",
|
@@ -316,6 +344,7 @@ static const char *rb_redcarpet_method_names[] = {
|
|
316
344
|
"emphasis",
|
317
345
|
"underline",
|
318
346
|
"highlight",
|
347
|
+
"quote",
|
319
348
|
"image",
|
320
349
|
"linebreak",
|
321
350
|
"link",
|
@@ -323,6 +352,7 @@ static const char *rb_redcarpet_method_names[] = {
|
|
323
352
|
"triple_emphasis",
|
324
353
|
"strikethrough",
|
325
354
|
"superscript",
|
355
|
+
"footnote_ref",
|
326
356
|
|
327
357
|
"entity",
|
328
358
|
"normal_text",
|
@@ -439,12 +469,26 @@ static VALUE rb_redcarpet_html_init(int argc, VALUE *argv, VALUE self)
|
|
439
469
|
return Qnil;
|
440
470
|
}
|
441
471
|
|
442
|
-
static VALUE rb_redcarpet_htmltoc_init(VALUE self)
|
472
|
+
static VALUE rb_redcarpet_htmltoc_init(int argc, VALUE *argv, VALUE self)
|
443
473
|
{
|
444
474
|
struct rb_redcarpet_rndr *rndr;
|
475
|
+
int nesting_level = 6;
|
476
|
+
VALUE hash, key = Qnil;
|
477
|
+
|
445
478
|
Data_Get_Struct(self, struct rb_redcarpet_rndr, rndr);
|
446
479
|
|
447
|
-
|
480
|
+
if (rb_scan_args(argc, argv, "01", &hash) == 1) {
|
481
|
+
Check_Type(hash, T_HASH);
|
482
|
+
|
483
|
+
key = CSTR2SYM("nesting_level");
|
484
|
+
|
485
|
+
if (RTEST(rb_hash_aref(hash, key))) {
|
486
|
+
Check_Type(rb_hash_aref(hash, key), T_FIXNUM);
|
487
|
+
nesting_level = NUM2INT(rb_hash_aref(hash, key));
|
488
|
+
}
|
489
|
+
}
|
490
|
+
|
491
|
+
sdhtml_toc_renderer(&rndr->callbacks, (struct html_renderopt *)&rndr->options.html, nesting_level);
|
448
492
|
rb_redcarpet__overload(self, rb_cRenderHTML_TOC);
|
449
493
|
|
450
494
|
return Qnil;
|
@@ -478,7 +522,7 @@ void Init_redcarpet_rndr()
|
|
478
522
|
rb_define_method(rb_cRenderHTML, "initialize", rb_redcarpet_html_init, -1);
|
479
523
|
|
480
524
|
rb_cRenderHTML_TOC = rb_define_class_under(rb_mRender, "HTML_TOC", rb_cRenderBase);
|
481
|
-
rb_define_method(rb_cRenderHTML_TOC, "initialize", rb_redcarpet_htmltoc_init,
|
525
|
+
rb_define_method(rb_cRenderHTML_TOC, "initialize", rb_redcarpet_htmltoc_init, -1);
|
482
526
|
|
483
527
|
rb_mSmartyPants = rb_define_module_under(rb_mRender, "SmartyPants");
|
484
528
|
rb_define_method(rb_mSmartyPants, "postprocess", rb_redcarpet_smartypants_render, 1);
|
data/ext/redcarpet/stack.c
CHANGED
@@ -51,15 +51,6 @@ redcarpet_stack_init(struct stack *st, size_t initial_size)
|
|
51
51
|
return redcarpet_stack_grow(st, initial_size);
|
52
52
|
}
|
53
53
|
|
54
|
-
void *
|
55
|
-
redcarpet_stack_pop(struct stack *st)
|
56
|
-
{
|
57
|
-
if (!st->size)
|
58
|
-
return NULL;
|
59
|
-
|
60
|
-
return st->item[--st->size];
|
61
|
-
}
|
62
|
-
|
63
54
|
int
|
64
55
|
redcarpet_stack_push(struct stack *st, void *item)
|
65
56
|
{
|
@@ -69,13 +60,3 @@ redcarpet_stack_push(struct stack *st, void *item)
|
|
69
60
|
st->item[st->size++] = item;
|
70
61
|
return 0;
|
71
62
|
}
|
72
|
-
|
73
|
-
void *
|
74
|
-
redcarpet_stack_top(struct stack *st)
|
75
|
-
{
|
76
|
-
if (!st->size)
|
77
|
-
return NULL;
|
78
|
-
|
79
|
-
return st->item[st->size - 1];
|
80
|
-
}
|
81
|
-
|
data/ext/redcarpet/stack.h
CHANGED
data/lib/redcarpet.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'redcarpet.so'
|
2
2
|
|
3
3
|
module Redcarpet
|
4
|
-
VERSION = '3.
|
4
|
+
VERSION = '3.1.0'
|
5
5
|
|
6
6
|
class Markdown
|
7
7
|
attr_reader :renderer
|
@@ -68,9 +68,9 @@ class RedcarpetCompat
|
|
68
68
|
def to_html(*_dummy)
|
69
69
|
@markdown.render(@text)
|
70
70
|
end
|
71
|
-
|
71
|
+
|
72
72
|
private
|
73
|
-
|
73
|
+
|
74
74
|
EXTENSION_MAP = {
|
75
75
|
# old name => new name
|
76
76
|
:autolink => :autolink,
|
@@ -95,10 +95,10 @@ class RedcarpetCompat
|
|
95
95
|
:smart => nil,
|
96
96
|
:strict => nil
|
97
97
|
}
|
98
|
-
|
99
|
-
RENDERER_OPTIONS = [:filter_html, :no_images, :no_links, :no_styles,
|
98
|
+
|
99
|
+
RENDERER_OPTIONS = [:filter_html, :no_images, :no_links, :no_styles,
|
100
100
|
:safe_links_only, :with_toc_data, :hard_wrap, :prettify, :xhtml]
|
101
|
-
|
101
|
+
|
102
102
|
def rename_extensions(exts)
|
103
103
|
exts.map do |old_name|
|
104
104
|
if new_name = EXTENSION_MAP[old_name]
|
@@ -108,7 +108,7 @@ class RedcarpetCompat
|
|
108
108
|
end
|
109
109
|
end.compact
|
110
110
|
end
|
111
|
-
|
111
|
+
|
112
112
|
# Returns two hashes, the extensions and renderer options
|
113
113
|
# given the extension list
|
114
114
|
def parse_extensions_and_renderer_options(exts)
|
@@ -116,7 +116,7 @@ class RedcarpetCompat
|
|
116
116
|
exts.partition {|ext| !RENDERER_OPTIONS.include?(ext) }.
|
117
117
|
map {|list| list_to_truthy_hash(list) }
|
118
118
|
end
|
119
|
-
|
119
|
+
|
120
120
|
# Turns a list of symbols into a hash of <tt>symbol => true</tt>.
|
121
121
|
def list_to_truthy_hash(list)
|
122
122
|
list.inject({}) {|h, k| h[k] = true; h }
|
@@ -1,4 +1,3 @@
|
|
1
|
-
|
2
1
|
module Redcarpet
|
3
2
|
module Render
|
4
3
|
# Markdown-stripping renderer. Turns Markdown into plaintext
|
@@ -16,6 +15,9 @@ module Redcarpet
|
|
16
15
|
:triple_emphasis, :strikethrough,
|
17
16
|
:superscript,
|
18
17
|
|
18
|
+
# footnotes
|
19
|
+
:footnotes, :footnote_def, :footnote_ref,
|
20
|
+
|
19
21
|
# low level rendering
|
20
22
|
:entity, :normal_text
|
21
23
|
].each do |method|
|
@@ -33,7 +35,7 @@ module Redcarpet
|
|
33
35
|
text + "\n"
|
34
36
|
end
|
35
37
|
|
36
|
-
def header(text, header_level)
|
38
|
+
def header(text, header_level, anchor)
|
37
39
|
text + "\n"
|
38
40
|
end
|
39
41
|
end
|
data/redcarpet.gemspec
CHANGED
@@ -1,14 +1,15 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
Gem::Specification.new do |s|
|
3
3
|
s.name = 'redcarpet'
|
4
|
-
s.version = '3.
|
4
|
+
s.version = '3.1.0'
|
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 = '
|
7
|
+
s.date = '2014-02-08'
|
8
8
|
s.email = 'vicent@github.com'
|
9
9
|
s.homepage = 'http://github.com/vmg/redcarpet'
|
10
10
|
s.authors = ["Natacha Porté", "Vicent Martí"]
|
11
11
|
s.license = 'MIT'
|
12
|
+
s.required_ruby_version = '>= 1.9.2'
|
12
13
|
# = MANIFEST =
|
13
14
|
s.files = %w[
|
14
15
|
COPYING
|
@@ -43,6 +44,7 @@ Gem::Specification.new do |s|
|
|
43
44
|
test/test_helper.rb
|
44
45
|
test/custom_render_test.rb
|
45
46
|
test/html_render_test.rb
|
47
|
+
test/html_toc_render_test.rb
|
46
48
|
test/markdown_test.rb
|
47
49
|
test/pathological_inputs_test.rb
|
48
50
|
test/redcarpet_compat_test.rb
|
@@ -60,6 +62,4 @@ Gem::Specification.new do |s|
|
|
60
62
|
s.add_development_dependency "nokogiri", "~> 1.6.0"
|
61
63
|
s.add_development_dependency "rake-compiler", "~> 0.8.3"
|
62
64
|
s.add_development_dependency "test-unit", "~> 2.5.4"
|
63
|
-
s.add_development_dependency "bluecloth", "~> 2.2.0"
|
64
|
-
s.add_development_dependency "kramdown", "~> 1.0.2"
|
65
65
|
end
|
data/test/html_render_test.rb
CHANGED
@@ -11,6 +11,8 @@ class HTMLRenderTest < Test::Unit::TestCase
|
|
11
11
|
:safe_links => Redcarpet::Render::HTML.new(:safe_links_only => true),
|
12
12
|
:escape_html => Redcarpet::Render::HTML.new(:escape_html => true),
|
13
13
|
:hard_wrap => Redcarpet::Render::HTML.new(:hard_wrap => true),
|
14
|
+
:toc_data => Redcarpet::Render::HTML.new(:with_toc_data => true),
|
15
|
+
:prettify => Redcarpet::Render::HTML.new(:prettify => true)
|
14
16
|
}
|
15
17
|
end
|
16
18
|
|
@@ -131,9 +133,91 @@ HTML
|
|
131
133
|
assert output.include? '<a href="http://bar.com">'
|
132
134
|
end
|
133
135
|
|
134
|
-
def
|
135
|
-
|
136
|
-
|
137
|
-
|
136
|
+
def test_that_footnotes_work
|
137
|
+
markdown = <<-MD
|
138
|
+
This is a footnote.[^1]
|
139
|
+
|
140
|
+
[^1]: It provides additional information.
|
141
|
+
MD
|
142
|
+
|
143
|
+
html = <<HTML
|
144
|
+
<p>This is a footnote.<sup id="fnref1"><a href="#fn1" rel="footnote">1</a></sup></p>
|
145
|
+
|
146
|
+
<div class="footnotes">
|
147
|
+
<hr>
|
148
|
+
<ol>
|
149
|
+
|
150
|
+
<li id="fn1">
|
151
|
+
<p>It provides additional information. <a href="#fnref1" rev="footnote">↩</a></p>
|
152
|
+
</li>
|
153
|
+
|
154
|
+
</ol>
|
155
|
+
</div>
|
156
|
+
HTML
|
157
|
+
|
158
|
+
renderer = Redcarpet::Markdown.new(Redcarpet::Render::HTML, :footnotes => true)
|
159
|
+
output = renderer.render(markdown)
|
160
|
+
assert_equal html, output
|
161
|
+
end
|
162
|
+
|
163
|
+
def test_footnotes_enabled_but_missing_marker
|
164
|
+
markdown = <<MD
|
165
|
+
Some text without a marker
|
166
|
+
|
167
|
+
[^1] And a trailing definition
|
168
|
+
MD
|
169
|
+
html = <<HTML
|
170
|
+
<p>Some text without a marker</p>
|
171
|
+
|
172
|
+
<p>[^1] And a trailing definition</p>
|
173
|
+
HTML
|
174
|
+
|
175
|
+
renderer = Redcarpet::Markdown.new(Redcarpet::Render::HTML, :footnotes => true)
|
176
|
+
output = renderer.render(markdown)
|
177
|
+
assert_equal html, output
|
178
|
+
end
|
179
|
+
|
180
|
+
def test_footnotes_enabled_but_missing_definition
|
181
|
+
markdown = "Some text with a marker[^1] but no definition."
|
182
|
+
html = "<p>Some text with a marker[^1] but no definition.</p>\n"
|
183
|
+
|
184
|
+
renderer = Redcarpet::Markdown.new(Redcarpet::Render::HTML, :footnotes => true)
|
185
|
+
output = renderer.render(markdown)
|
186
|
+
assert_equal html, output
|
187
|
+
end
|
188
|
+
|
189
|
+
def test_autolink_short_domains
|
190
|
+
markdown = "Example of uri ftp://auto/short/domains. Email auto@l.n and link http://a/u/t/o/s/h/o/r/t"
|
191
|
+
renderer = Redcarpet::Markdown.new(Redcarpet::Render::HTML, :autolink => true)
|
192
|
+
output = renderer.render(markdown)
|
193
|
+
|
194
|
+
assert output.include? '<a href="ftp://auto/short/domains">ftp://auto/short/domains</a>'
|
195
|
+
assert output.include? 'mailto:auto@l.n'
|
196
|
+
assert output.include? '<a href="http://a/u/t/o/s/h/o/r/t">http://a/u/t/o/s/h/o/r/t</a>'
|
197
|
+
end
|
198
|
+
|
199
|
+
def test_toc_heading_id
|
200
|
+
markdown = "# First level heading\n## Second level heading"
|
201
|
+
output = render_with(@rndr[:toc_data], markdown)
|
202
|
+
assert_match /<h1 id="first-level-heading">/, output
|
203
|
+
assert_match /<h2 id="second-level-heading">/, output
|
204
|
+
end
|
205
|
+
|
206
|
+
def test_that_prettify_works
|
207
|
+
text = <<-Markdown
|
208
|
+
Foo
|
209
|
+
|
210
|
+
~~~ruby
|
211
|
+
some
|
212
|
+
code
|
213
|
+
~~~
|
214
|
+
|
215
|
+
Bar
|
216
|
+
Markdown
|
217
|
+
|
218
|
+
renderer = Redcarpet::Markdown.new(@rndr[:prettify], fenced_code_blocks: true)
|
219
|
+
output = renderer.render(text)
|
220
|
+
|
221
|
+
assert output.include?("<code class=\"prettyprint ruby\">")
|
138
222
|
end
|
139
223
|
end
|