tight-redcarpet 3.1.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.
- checksums.yaml +7 -0
- data/COPYING +14 -0
- data/Gemfile +9 -0
- data/README.markdown +386 -0
- data/Rakefile +60 -0
- data/bin/redcarpet +43 -0
- data/ext/redcarpet/autolink.c +296 -0
- data/ext/redcarpet/autolink.h +49 -0
- data/ext/redcarpet/buffer.c +196 -0
- data/ext/redcarpet/buffer.h +83 -0
- data/ext/redcarpet/extconf.rb +6 -0
- data/ext/redcarpet/houdini.h +29 -0
- data/ext/redcarpet/houdini_href_e.c +108 -0
- data/ext/redcarpet/houdini_html_e.c +83 -0
- data/ext/redcarpet/html.c +770 -0
- data/ext/redcarpet/html.h +78 -0
- data/ext/redcarpet/html_blocks.h +206 -0
- data/ext/redcarpet/html_smartypants.c +445 -0
- data/ext/redcarpet/markdown.c +2907 -0
- data/ext/redcarpet/markdown.h +141 -0
- data/ext/redcarpet/rc_markdown.c +165 -0
- data/ext/redcarpet/rc_render.c +529 -0
- data/ext/redcarpet/redcarpet.h +30 -0
- data/ext/redcarpet/stack.c +62 -0
- data/ext/redcarpet/stack.h +26 -0
- data/lib/redcarpet.rb +125 -0
- data/lib/redcarpet/compat.rb +3 -0
- data/lib/redcarpet/render_man.rb +65 -0
- data/lib/redcarpet/render_strip.rb +48 -0
- data/redcarpet.gemspec +65 -0
- data/test/custom_render_test.rb +28 -0
- data/test/html_render_test.rb +232 -0
- data/test/html_toc_render_test.rb +49 -0
- data/test/markdown_test.rb +311 -0
- data/test/pathological_inputs_test.rb +34 -0
- data/test/redcarpet_compat_test.rb +38 -0
- data/test/smarty_html_test.rb +45 -0
- data/test/smarty_pants_test.rb +48 -0
- data/test/stripdown_render_test.rb +42 -0
- data/test/test_helper.rb +18 -0
- metadata +141 -0
@@ -0,0 +1,34 @@
|
|
1
|
+
# coding: UTF-8
|
2
|
+
require 'test_helper'
|
3
|
+
|
4
|
+
# Disabled by default
|
5
|
+
# (these are the easy ones -- the evil ones are not disclosed)
|
6
|
+
class PathologicalInputsTest # < Redcarpet::TestCase
|
7
|
+
def setup
|
8
|
+
@markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML)
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_pathological_1
|
12
|
+
star = '*' * 250000
|
13
|
+
@markdown.render("#{star}#{star} hi #{star}#{star}")
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_pathological_2
|
17
|
+
crt = '^' * 255
|
18
|
+
str = "#{crt}(\\)"
|
19
|
+
@markdown.render("#{str*300}")
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_pathological_3
|
23
|
+
c = "`t`t`t`t`t`t" * 20000000
|
24
|
+
@markdown.render(c)
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_pathological_4
|
28
|
+
@markdown.render(" [^a]: #{ "A" * 10000 }\n#{ "[^a][]" * 1000000 }\n")
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_unbound_recursion
|
32
|
+
@markdown.render(("[" * 10000) + "foo" + ("](bar)" * 10000))
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# coding: UTF-8
|
2
|
+
require 'test_helper'
|
3
|
+
|
4
|
+
class RedcarpetCompatTest < Redcarpet::TestCase
|
5
|
+
def test_simple_compat_api
|
6
|
+
html = RedcarpetCompat.new("This is_just_a test").to_html
|
7
|
+
html_equal "<p>This is<em>just</em>a test</p>\n", html
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_compat_api_enables_extensions
|
11
|
+
html = RedcarpetCompat.new("This is_just_a test", :no_intra_emphasis).to_html
|
12
|
+
html_equal "<p>This is_just_a test</p>\n", html
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_compat_api_knows_fenced_code_extension
|
16
|
+
text = "```ruby\nx = 'foo'\n```"
|
17
|
+
html = RedcarpetCompat.new(text, :fenced_code).to_html
|
18
|
+
html_equal "<pre><code class=\"ruby\">x = 'foo'\n</code></pre>\n", html
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_compat_api_ignores_gh_blockcode_extension
|
22
|
+
text = "```ruby\nx = 'foo'\n```"
|
23
|
+
html = RedcarpetCompat.new(text, :fenced_code, :gh_blockcode).to_html
|
24
|
+
html_equal "<pre><code class=\"ruby\">x = 'foo'\n</code></pre>\n", html
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_compat_api_knows_no_intraemphasis_extension
|
28
|
+
html = RedcarpetCompat.new("This is_just_a test", :no_intraemphasis).to_html
|
29
|
+
html_equal "<p>This is_just_a test</p>\n", html
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_translate_outdated_extensions
|
33
|
+
# these extensions are no longer used
|
34
|
+
exts = [:gh_blockcode, :no_tables, :smart, :strict]
|
35
|
+
html = RedcarpetCompat.new('"TEST"', *exts).to_html
|
36
|
+
html_equal "<p>"TEST"</p>\n", html
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# coding: UTF-8
|
2
|
+
require 'test_helper'
|
3
|
+
|
4
|
+
class SmartyHTMLTest < Redcarpet::TestCase
|
5
|
+
def setup
|
6
|
+
@smarty_markdown = Redcarpet::Markdown.new(Redcarpet::Render::SmartyHTML)
|
7
|
+
end
|
8
|
+
|
9
|
+
def test_that_smartyhtml_converts_single_quotes
|
10
|
+
markdown = @smarty_markdown.render("They're not for sale.")
|
11
|
+
assert_equal "<p>They’re not for sale.</p>\n", markdown
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_that_smartyhtml_converts_double_quotes
|
15
|
+
rd = @smarty_markdown.render(%("Quoted text"))
|
16
|
+
assert_equal %(<p>“Quoted text”</p>\n), rd
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_that_smartyhtml_converts_double_hyphen
|
20
|
+
rd = @smarty_markdown.render("double hyphen -- ndash")
|
21
|
+
assert_equal "<p>double hyphen – ndash</p>\n", rd
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_that_smartyhtml_converts_triple_hyphen
|
25
|
+
rd = @smarty_markdown.render("triple hyphen --- mdash")
|
26
|
+
assert_equal "<p>triple hyphen — mdash</p>\n", rd
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_that_smartyhtml_ignores_double_hyphen_in_code
|
30
|
+
rd = @smarty_markdown.render("double hyphen in `--option`")
|
31
|
+
assert_equal "<p>double hyphen in <code>--option</code></p>\n", rd
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_that_smartyhtml_ignores_pre
|
35
|
+
rd = @smarty_markdown.render(" It's a test of \"pre\"\n")
|
36
|
+
expected = "It's a test of \"pre\""
|
37
|
+
assert rd.include?(expected), "\"#{rd}\" should contain \"#{expected}\""
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_that_smartyhtml_ignores_code
|
41
|
+
rd = @smarty_markdown.render("`It's a test of \"code\"`\n")
|
42
|
+
expected = "It's a test of \"code\""
|
43
|
+
assert rd.include?(expected), "\"#{rd}\" should contain \"#{expected}\""
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# coding: UTF-8
|
2
|
+
require 'test_helper'
|
3
|
+
|
4
|
+
class SmartyPantsTest < Redcarpet::TestCase
|
5
|
+
def setup
|
6
|
+
@pants = Redcarpet::Render::SmartyPants
|
7
|
+
end
|
8
|
+
|
9
|
+
def test_that_smart_converts_single_quotes_in_words_that_end_in_re
|
10
|
+
markdown = @pants.render("<p>They're not for sale.</p>")
|
11
|
+
assert_equal "<p>They’re not for sale.</p>", markdown
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_that_smart_converts_single_quotes_in_words_that_end_in_ll
|
15
|
+
markdown = @pants.render("<p>Well that'll be the day</p>")
|
16
|
+
assert_equal "<p>Well that’ll be the day</p>", markdown
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_that_smart_converts_double_quotes_to_curly_quotes
|
20
|
+
rd = @pants.render(%(<p>"Quoted text"</p>))
|
21
|
+
assert_equal %(<p>“Quoted text”</p>), rd
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_that_smart_gives_ve_suffix_a_rsquo
|
25
|
+
rd = @pants.render("<p>I've been meaning to tell you ..</p>")
|
26
|
+
assert_equal "<p>I’ve been meaning to tell you ..</p>", rd
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_that_smart_gives_m_suffix_a_rsquo
|
30
|
+
rd = @pants.render("<p>I'm not kidding</p>")
|
31
|
+
assert_equal "<p>I’m not kidding</p>", rd
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_that_smart_gives_d_suffix_a_rsquo
|
35
|
+
rd = @pants.render("<p>what'd you say?</p>")
|
36
|
+
assert_equal "<p>what’d you say?</p>", rd
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_that_backticks_are_preserved
|
40
|
+
rd = @pants.render("<p>single `backticks` in HTML should be preserved</p>")
|
41
|
+
assert_equal "<p>single `backticks` in HTML should be preserved</p>", rd
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_that_smart_converts_trailing_single_quotes_to_curly_quotes
|
45
|
+
rd = @pants.render("<p>Hopin' that this bug gets some fixin'.</p>")
|
46
|
+
assert_equal "<p>Hopin’ that this bug gets some fixin’.</p>", rd
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# coding: UTF-8
|
2
|
+
require 'test_helper'
|
3
|
+
|
4
|
+
class StripDownRender < Redcarpet::TestCase
|
5
|
+
|
6
|
+
def setup
|
7
|
+
@markdown = Redcarpet::Markdown.new(Redcarpet::Render::StripDown)
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_basics
|
11
|
+
markdown = <<-Markdown
|
12
|
+
# [Foo bar](https://github.com)
|
13
|
+
Markdown
|
14
|
+
html = @markdown.render(markdown)
|
15
|
+
html_equal "Foo bar\n", html
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_insert_new_lines_char
|
19
|
+
markdown = <<-Markdown
|
20
|
+
# Foo bar
|
21
|
+
|
22
|
+
Hello world! Please visit [this site](https://github.com/).
|
23
|
+
|
24
|
+
class Foo
|
25
|
+
end
|
26
|
+
|
27
|
+
Look at this 
|
28
|
+
And this: 
|
29
|
+
Markdown
|
30
|
+
plaintext = <<-Plaintext
|
31
|
+
Foo bar
|
32
|
+
Hello world! Please visit this site.
|
33
|
+
class Foo
|
34
|
+
end
|
35
|
+
Look at this picture http://example.org/picture.png
|
36
|
+
And this: http://example.org/image.jpg
|
37
|
+
Plaintext
|
38
|
+
|
39
|
+
html = @markdown.render(markdown)
|
40
|
+
html_equal plaintext, html
|
41
|
+
end
|
42
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
# coding: UTF-8
|
2
|
+
Encoding.default_internal = 'UTF-8' if defined? Encoding
|
3
|
+
|
4
|
+
gem 'test-unit', '>= 2' # necessary when not using bundle exec
|
5
|
+
|
6
|
+
require 'test/unit'
|
7
|
+
require 'nokogiri'
|
8
|
+
|
9
|
+
require 'redcarpet'
|
10
|
+
require 'redcarpet/render_strip'
|
11
|
+
require 'redcarpet/render_man'
|
12
|
+
|
13
|
+
class Redcarpet::TestCase < Test::Unit::TestCase
|
14
|
+
def html_equal(html_a, html_b)
|
15
|
+
assert_equal Nokogiri::HTML::DocumentFragment.parse(html_a).to_html,
|
16
|
+
Nokogiri::HTML::DocumentFragment.parse(html_b).to_html
|
17
|
+
end
|
18
|
+
end
|
metadata
ADDED
@@ -0,0 +1,141 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: tight-redcarpet
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 3.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Natacha Porté
|
8
|
+
- Vicent Martí
|
9
|
+
- Igor Bochkariov
|
10
|
+
autorequire:
|
11
|
+
bindir: bin
|
12
|
+
cert_chain: []
|
13
|
+
date: 2014-07-04 00:00:00.000000000 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: nokogiri
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
18
|
+
requirements:
|
19
|
+
- - "~>"
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 1.6.0
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
requirements:
|
26
|
+
- - "~>"
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
version: 1.6.0
|
29
|
+
- !ruby/object:Gem::Dependency
|
30
|
+
name: rake-compiler
|
31
|
+
requirement: !ruby/object:Gem::Requirement
|
32
|
+
requirements:
|
33
|
+
- - "~>"
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: 0.8.3
|
36
|
+
type: :development
|
37
|
+
prerelease: false
|
38
|
+
version_requirements: !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
40
|
+
- - "~>"
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: 0.8.3
|
43
|
+
- !ruby/object:Gem::Dependency
|
44
|
+
name: test-unit
|
45
|
+
requirement: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - "~>"
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: 2.5.4
|
50
|
+
type: :development
|
51
|
+
prerelease: false
|
52
|
+
version_requirements: !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
54
|
+
- - "~>"
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: 2.5.4
|
57
|
+
description: A fast, safe and extensible Markdown to (X)HTML parser patched to have
|
58
|
+
smaller headings and no quote-escaping
|
59
|
+
email: ujifgc@github.com
|
60
|
+
executables:
|
61
|
+
- redcarpet
|
62
|
+
extensions:
|
63
|
+
- ext/redcarpet/extconf.rb
|
64
|
+
extra_rdoc_files:
|
65
|
+
- COPYING
|
66
|
+
files:
|
67
|
+
- COPYING
|
68
|
+
- Gemfile
|
69
|
+
- README.markdown
|
70
|
+
- Rakefile
|
71
|
+
- bin/redcarpet
|
72
|
+
- ext/redcarpet/autolink.c
|
73
|
+
- ext/redcarpet/autolink.h
|
74
|
+
- ext/redcarpet/buffer.c
|
75
|
+
- ext/redcarpet/buffer.h
|
76
|
+
- ext/redcarpet/extconf.rb
|
77
|
+
- ext/redcarpet/houdini.h
|
78
|
+
- ext/redcarpet/houdini_href_e.c
|
79
|
+
- ext/redcarpet/houdini_html_e.c
|
80
|
+
- ext/redcarpet/html.c
|
81
|
+
- ext/redcarpet/html.h
|
82
|
+
- ext/redcarpet/html_blocks.h
|
83
|
+
- ext/redcarpet/html_smartypants.c
|
84
|
+
- ext/redcarpet/markdown.c
|
85
|
+
- ext/redcarpet/markdown.h
|
86
|
+
- ext/redcarpet/rc_markdown.c
|
87
|
+
- ext/redcarpet/rc_render.c
|
88
|
+
- ext/redcarpet/redcarpet.h
|
89
|
+
- ext/redcarpet/stack.c
|
90
|
+
- ext/redcarpet/stack.h
|
91
|
+
- lib/redcarpet.rb
|
92
|
+
- lib/redcarpet/compat.rb
|
93
|
+
- lib/redcarpet/render_man.rb
|
94
|
+
- lib/redcarpet/render_strip.rb
|
95
|
+
- redcarpet.gemspec
|
96
|
+
- test/custom_render_test.rb
|
97
|
+
- test/html_render_test.rb
|
98
|
+
- test/html_toc_render_test.rb
|
99
|
+
- test/markdown_test.rb
|
100
|
+
- test/pathological_inputs_test.rb
|
101
|
+
- test/redcarpet_compat_test.rb
|
102
|
+
- test/smarty_html_test.rb
|
103
|
+
- test/smarty_pants_test.rb
|
104
|
+
- test/stripdown_render_test.rb
|
105
|
+
- test/test_helper.rb
|
106
|
+
homepage: http://github.com/ujifgc/redcarpet
|
107
|
+
licenses:
|
108
|
+
- MIT
|
109
|
+
metadata: {}
|
110
|
+
post_install_message:
|
111
|
+
rdoc_options: []
|
112
|
+
require_paths:
|
113
|
+
- lib
|
114
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
115
|
+
requirements:
|
116
|
+
- - ">="
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: 1.9.2
|
119
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
120
|
+
requirements:
|
121
|
+
- - ">="
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: '0'
|
124
|
+
requirements: []
|
125
|
+
rubyforge_project:
|
126
|
+
rubygems_version: 2.2.2
|
127
|
+
signing_key:
|
128
|
+
specification_version: 4
|
129
|
+
summary: Markdown that smells nice (patch level 'tight')
|
130
|
+
test_files:
|
131
|
+
- test/custom_render_test.rb
|
132
|
+
- test/html_render_test.rb
|
133
|
+
- test/html_toc_render_test.rb
|
134
|
+
- test/markdown_test.rb
|
135
|
+
- test/pathological_inputs_test.rb
|
136
|
+
- test/redcarpet_compat_test.rb
|
137
|
+
- test/smarty_html_test.rb
|
138
|
+
- test/smarty_pants_test.rb
|
139
|
+
- test/stripdown_render_test.rb
|
140
|
+
- test/test_helper.rb
|
141
|
+
has_rdoc:
|