bluecloth 2.0.5 → 2.0.6.pre120
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.
- data/ChangeLog +242 -678
- data/LICENSE +1 -1
- data/README +2 -2
- data/Rakefile +99 -68
- data/Rakefile.local +21 -41
- data/ext/VERSION +1 -1
- data/ext/bluecloth.c +18 -4
- data/ext/bluecloth.h +19 -0
- data/ext/config.h +8 -0
- data/ext/cstring.h +3 -2
- data/ext/extconf.rb +8 -1
- data/ext/generate.c +148 -27
- data/ext/markdown.c +135 -27
- data/ext/markdown.h +3 -2
- data/ext/mkdio.h +1 -0
- data/lib/bluecloth.rb +12 -9
- data/rake/dependencies.rb +1 -1
- data/rake/helpers.rb +24 -2
- data/rake/hg.rb +273 -0
- data/rake/manual.rb +3 -3
- data/rake/packaging.rb +33 -35
- data/rake/publishing.rb +16 -68
- data/rake/rdoc.rb +1 -1
- data/rake/style.rb +1 -1
- data/rake/svn.rb +577 -549
- data/rake/testing.rb +4 -20
- data/rake/win32.rb +13 -9
- data/spec/bluecloth/blockquotes_spec.rb +24 -22
- data/spec/bluecloth_spec.rb +31 -0
- data/spec/bugfix_spec.rb +37 -1
- data/spec/discount_spec.rb +117 -0
- data/spec/markdowntest_spec.rb +8 -8
- metadata +19 -138
data/rake/testing.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#
|
2
2
|
# Rake tasklib for testing tasks
|
3
|
-
|
3
|
+
|
4
4
|
#
|
5
5
|
# Authors:
|
6
6
|
# * Michael Granger <ged@FaerieMUD.org>
|
@@ -29,7 +29,7 @@ task :test do
|
|
29
29
|
log "Running specs"
|
30
30
|
Rake::Task['spec:quiet'].invoke
|
31
31
|
end
|
32
|
-
|
32
|
+
|
33
33
|
unless TEST_FILES.empty?
|
34
34
|
log "Running unit tests"
|
35
35
|
Rake::Task[:unittests].invoke
|
@@ -101,7 +101,7 @@ end
|
|
101
101
|
### Test::Unit tests
|
102
102
|
begin
|
103
103
|
require 'rake/testtask'
|
104
|
-
|
104
|
+
|
105
105
|
Rake::TestTask.new( :unittests ) do |task|
|
106
106
|
task.libs += [LIBDIR]
|
107
107
|
task.test_files = TEST_FILES
|
@@ -116,7 +116,7 @@ rescue LoadError => err
|
|
116
116
|
task :unittests => :no_rspec
|
117
117
|
end
|
118
118
|
|
119
|
-
|
119
|
+
|
120
120
|
### RCov (via RSpec) tasks
|
121
121
|
begin
|
122
122
|
gem 'rcov'
|
@@ -136,16 +136,6 @@ begin
|
|
136
136
|
task.rcov = true
|
137
137
|
end
|
138
138
|
end
|
139
|
-
# unless TEST_FILES.empty?
|
140
|
-
# require 'rcov/rcovtask'
|
141
|
-
|
142
|
-
# Rcov::RcovTask.new do |task|
|
143
|
-
# task.libs += [LIBDIR]
|
144
|
-
# task.test_files = TEST_FILES
|
145
|
-
# task.verbose = true
|
146
|
-
# task.rcov_opts = RCOV_OPTS
|
147
|
-
# end
|
148
|
-
# end
|
149
139
|
|
150
140
|
|
151
141
|
### Task: rcov
|
@@ -168,12 +158,6 @@ begin
|
|
168
158
|
task.rcov = true
|
169
159
|
end
|
170
160
|
|
171
|
-
### Task: verify coverage
|
172
|
-
desc "Build coverage statistics"
|
173
|
-
VerifyTask.new( :verify => :rcov ) do |task|
|
174
|
-
task.threshold = COVERAGE_MINIMUM
|
175
|
-
end
|
176
|
-
|
177
161
|
desc "Run RCov in 'spec-only' mode to check coverage from specs"
|
178
162
|
Spec::Rake::SpecTask.new( :speconly ) do |task|
|
179
163
|
task.spec_files = SPEC_FILES
|
data/rake/win32.rb
CHANGED
@@ -13,6 +13,7 @@
|
|
13
13
|
# * Aaron Patterson
|
14
14
|
# http://tenderlovemaking.com/2008/11/21/cross-compiling-ruby-gems-for-win32/
|
15
15
|
|
16
|
+
require 'rubygems'
|
16
17
|
require 'rake'
|
17
18
|
require 'pathname'
|
18
19
|
require 'rubygems/platform'
|
@@ -67,7 +68,7 @@ def untar( tarfile, targetdir )
|
|
67
68
|
raise "No such directory: #{targetdir}" unless targetdir.directory?
|
68
69
|
|
69
70
|
reader = Archive::Tar::Reader.new( tarfile.to_s, TAR_OPTS )
|
70
|
-
|
71
|
+
|
71
72
|
mkdir_p( targetdir )
|
72
73
|
reader.each( true ) do |header, body|
|
73
74
|
path = targetdir + header[:path]
|
@@ -84,7 +85,7 @@ def untar( tarfile, targetdir )
|
|
84
85
|
when :directory
|
85
86
|
trace " #{path}"
|
86
87
|
path.mkpath
|
87
|
-
|
88
|
+
|
88
89
|
when :link
|
89
90
|
linktarget = targetdir + header[:dest]
|
90
91
|
trace " #{path} => #{linktarget}"
|
@@ -96,16 +97,16 @@ def untar( tarfile, targetdir )
|
|
96
97
|
path.make_symlink( linktarget )
|
97
98
|
end
|
98
99
|
end
|
99
|
-
|
100
|
+
|
100
101
|
end
|
101
102
|
|
102
103
|
|
103
104
|
begin
|
104
105
|
require 'archive/tar'
|
105
|
-
|
106
|
+
|
106
107
|
namespace :win32 do
|
107
108
|
directory XCOMPILER_DIR.to_s
|
108
|
-
|
109
|
+
|
109
110
|
file XCOMPILER_DL => XCOMPILER_DIR do
|
110
111
|
# openuri can't handle this -- passive ftp required?
|
111
112
|
# run 'wget', '-O', XCOMPILER_DL, RUBY_DL_URI
|
@@ -140,7 +141,7 @@ begin
|
|
140
141
|
mv 'Makefile.in', 'Makefile.in.orig'
|
141
142
|
mv 'Makefile.in.new', 'Makefile.in'
|
142
143
|
end
|
143
|
-
|
144
|
+
|
144
145
|
run *CONFIGURE_CMD
|
145
146
|
run 'make', 'ruby'
|
146
147
|
run 'make', 'rubyw.exe'
|
@@ -158,7 +159,7 @@ begin
|
|
158
159
|
sh 'make'
|
159
160
|
end
|
160
161
|
end
|
161
|
-
|
162
|
+
|
162
163
|
desc "Build a binary gem for win32 systems"
|
163
164
|
task :gem => ['win32:build', PKGDIR.to_s] + WIN32_GEMSPEC.files do
|
164
165
|
when_writing( "Creating win32 GEM" ) do
|
@@ -171,16 +172,19 @@ begin
|
|
171
172
|
end
|
172
173
|
|
173
174
|
rescue LoadError => err
|
175
|
+
trace "Couldn't load the win32 tasks: %s: %s" % [ err.class.name, err.message ]
|
176
|
+
|
174
177
|
task :no_win32_build do
|
175
178
|
abort "No win32 build: %s: %s" % [ err.class.name, err.message ]
|
176
179
|
end
|
177
|
-
|
180
|
+
|
178
181
|
namespace :win32 do
|
179
182
|
desc "Build a binary Gem for Win32 systems, installing a cross " +
|
180
183
|
"compiled Ruby if necessary"
|
184
|
+
task :gem => :no_win32_build
|
181
185
|
task :build => :no_win32_build
|
182
186
|
end
|
183
|
-
|
187
|
+
|
184
188
|
end
|
185
189
|
|
186
190
|
|
@@ -113,28 +113,30 @@ describe BlueCloth, "blockquotes" do
|
|
113
113
|
|
114
114
|
# Blockquotes with a <pre> section
|
115
115
|
it "supports block-level HTML inside of blockquotes" do
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
116
|
+
pending "a fix in Discount" do
|
117
|
+
the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation
|
118
|
+
> The best approximation of the problem is the following code:
|
119
|
+
>
|
120
|
+
> <pre>
|
121
|
+
> foo + bar; foo.factorize; foo.display
|
122
|
+
> </pre>
|
123
|
+
>
|
124
|
+
> This should result in an error on any little-endian platform.
|
125
|
+
>
|
126
|
+
> <div>- Garrick Mettronne</div>
|
127
|
+
---
|
128
|
+
<blockquote><p>The best approximation of the problem is the following code:</p>
|
129
|
+
|
130
|
+
<pre>
|
131
|
+
foo + bar; foo.factorize; foo.display
|
132
|
+
</pre>
|
133
|
+
|
134
|
+
<p>This should result in an error on any little-endian platform.</p>
|
135
|
+
|
136
|
+
<div>- Garrick Mettronne</div>
|
137
|
+
</blockquote>
|
138
|
+
---
|
139
|
+
end
|
138
140
|
end
|
139
141
|
|
140
142
|
|
data/spec/bluecloth_spec.rb
CHANGED
@@ -60,6 +60,20 @@ describe BlueCloth do
|
|
60
60
|
end
|
61
61
|
|
62
62
|
|
63
|
+
it "handles non-string content safely" do
|
64
|
+
BlueCloth.new( nil ).text.should == ''
|
65
|
+
end
|
66
|
+
|
67
|
+
|
68
|
+
it "inherits the taintedness of its input" do
|
69
|
+
str = "a string"
|
70
|
+
BlueCloth.new( str ).should_not be_tainted()
|
71
|
+
|
72
|
+
str.taint
|
73
|
+
BlueCloth.new( str ).should be_tainted()
|
74
|
+
end
|
75
|
+
|
76
|
+
|
63
77
|
it "allows output to be rendered several times" do
|
64
78
|
bc = BlueCloth.new( "Some text" )
|
65
79
|
bc.to_html.should == bc.to_html
|
@@ -245,6 +259,23 @@ describe BlueCloth do
|
|
245
259
|
end
|
246
260
|
end
|
247
261
|
|
262
|
+
|
263
|
+
describe "encoding under Ruby 1.9.x" do
|
264
|
+
|
265
|
+
before( :each ) do
|
266
|
+
pending "only valid under a version of Ruby that has the Encoding class" unless
|
267
|
+
Object.const_defined?( :Encoding )
|
268
|
+
end
|
269
|
+
|
270
|
+
|
271
|
+
it "outputs HTML in the same encoding as the source string" do
|
272
|
+
utf8 = "a string".encode( "UTF-8" )
|
273
|
+
out = BlueCloth.new( utf8 ).to_html
|
274
|
+
|
275
|
+
out.encoding.name.should == 'UTF-8'
|
276
|
+
end
|
277
|
+
end
|
278
|
+
|
248
279
|
end
|
249
280
|
|
250
281
|
# vim: set nosta noet ts=4 sw=4:
|
data/spec/bugfix_spec.rb
CHANGED
@@ -120,7 +120,7 @@ describe BlueCloth, "bugfixes" do
|
|
120
120
|
the_indented_markdown( <<-"END_MARKDOWN" ).should be_transformed_into(<<-"END_HTML").without_indentation
|
121
121
|
This line of markdown below will hang you if you're running BlueCloth 1.x.
|
122
122
|
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
123
|
-
|
123
|
+
|
124
124
|
END_MARKDOWN
|
125
125
|
<p>This line of markdown below will hang you if you're running BlueCloth 1.x.</p>
|
126
126
|
|
@@ -128,6 +128,42 @@ describe BlueCloth, "bugfixes" do
|
|
128
128
|
END_HTML
|
129
129
|
end
|
130
130
|
|
131
|
+
it "recognizes closing block tags even when they're not on their own line" do
|
132
|
+
the_indented_markdown( <<-"END_MARKDOWN" ).should be_transformed_into(<<-"END_HTML").without_indentation
|
133
|
+
Para 1
|
134
|
+
|
135
|
+
<div><pre>HTML block
|
136
|
+
</pre></div>
|
137
|
+
|
138
|
+
Para 2 [Link](#anchor)
|
139
|
+
END_MARKDOWN
|
140
|
+
<p>Para 1</p>
|
141
|
+
|
142
|
+
<div><pre>HTML block
|
143
|
+
</pre></div>
|
144
|
+
|
145
|
+
<p>Para 2 <a href=\"#anchor\">Link</a></p>
|
146
|
+
END_HTML
|
147
|
+
end
|
148
|
+
|
149
|
+
it "correctly wraps lines after a code block in a list item" do
|
150
|
+
the_indented_markdown( <<-"END_MARKDOWN" ).should be_transformed_into(<<-"END_HTML").without_indentation
|
151
|
+
* testing
|
152
|
+
|
153
|
+
pre
|
154
|
+
|
155
|
+
more li
|
156
|
+
END_MARKDOWN
|
157
|
+
<ul>
|
158
|
+
<li><p>testing</p>
|
159
|
+
|
160
|
+
<pre><code>pre
|
161
|
+
</code></pre>
|
162
|
+
|
163
|
+
<p>more li</p></li>
|
164
|
+
</ul>
|
165
|
+
END_HTML
|
166
|
+
end
|
131
167
|
|
132
168
|
end
|
133
169
|
|
data/spec/discount_spec.rb
CHANGED
@@ -60,6 +60,123 @@ describe BlueCloth, "implementation of Discount-specific features" do
|
|
60
60
|
end
|
61
61
|
|
62
62
|
end
|
63
|
+
|
64
|
+
|
65
|
+
describe "Markdown-Extra tables" do
|
66
|
+
|
67
|
+
it "renders the example from orc's blog" do
|
68
|
+
the_indented_markdown( <<-"END_MARKDOWN", :strict => false ).should be_transformed_into(<<-"END_HTML").without_indentation
|
69
|
+
a | b
|
70
|
+
-----|-----
|
71
|
+
hello|sailor
|
72
|
+
END_MARKDOWN
|
73
|
+
<table>
|
74
|
+
<thead>
|
75
|
+
<tr>
|
76
|
+
<th> a </th>
|
77
|
+
<th> b</th>
|
78
|
+
</tr>
|
79
|
+
</thead>
|
80
|
+
<tbody>
|
81
|
+
<tr>
|
82
|
+
<td>hello</td>
|
83
|
+
<td>sailor</td>
|
84
|
+
</tr>
|
85
|
+
</tbody>
|
86
|
+
</table>
|
87
|
+
END_HTML
|
88
|
+
end
|
89
|
+
|
90
|
+
it "renders simple markdown-extra tables" do
|
91
|
+
the_indented_markdown( <<-"END_MARKDOWN", :strict => false ).should be_transformed_into(<<-"END_HTML").without_indentation
|
92
|
+
First Header | Second Header
|
93
|
+
------------- | -------------
|
94
|
+
Content Cell | Content Cell
|
95
|
+
END_MARKDOWN
|
96
|
+
<table>
|
97
|
+
<thead>
|
98
|
+
<tr>
|
99
|
+
<th>First Header </th>
|
100
|
+
<th> Second Header</th>
|
101
|
+
</tr>
|
102
|
+
</thead>
|
103
|
+
<tbody>
|
104
|
+
<tr>
|
105
|
+
<td>Content Cell </td>
|
106
|
+
<td> Content Cell</td>
|
107
|
+
</tr>
|
108
|
+
</tbody>
|
109
|
+
</table>
|
110
|
+
END_HTML
|
111
|
+
|
112
|
+
end
|
113
|
+
|
114
|
+
it "renders tables with leading and trailing pipes" do
|
115
|
+
pending "Discount doesn't support this kind (yet?)" do
|
116
|
+
the_indented_markdown( <<-"END_MARKDOWN", :tables => true ).should be_transformed_into(<<-"END_HTML").without_indentation
|
117
|
+
| First Header | Second Header |
|
118
|
+
| ------------- | ------------- |
|
119
|
+
| Content Cell | Content Cell |
|
120
|
+
| Content Cell | Content Cell |
|
121
|
+
END_MARKDOWN
|
122
|
+
<table>
|
123
|
+
<thead>
|
124
|
+
<tr>
|
125
|
+
<th>First Header </th>
|
126
|
+
<th> Second Header</th>
|
127
|
+
</tr>
|
128
|
+
</thead>
|
129
|
+
<tbody>
|
130
|
+
<tr>
|
131
|
+
<td>Content Cell </td>
|
132
|
+
<td> Content Cell</td>
|
133
|
+
</tr>
|
134
|
+
<tr>
|
135
|
+
<td>Content Cell </td>
|
136
|
+
<td> Content Cell</td>
|
137
|
+
</tr>
|
138
|
+
</tbody>
|
139
|
+
</table>
|
140
|
+
END_HTML
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
it "renders tables with aligned columns" do
|
145
|
+
pending "Discount doesn't support this kind (yet?)" do
|
146
|
+
the_indented_markdown( <<-"END_MARKDOWN", :tables => true ).should be_transformed_into(<<-"END_HTML").without_indentation
|
147
|
+
| Item | Value |
|
148
|
+
| --------- | -----:|
|
149
|
+
| Computer | $1600 |
|
150
|
+
| Phone | $12 |
|
151
|
+
| Pipe | $1 |
|
152
|
+
END_MARKDOWN
|
153
|
+
<table>
|
154
|
+
<thead>
|
155
|
+
<tr>
|
156
|
+
<th>Item </th>
|
157
|
+
<th align="right"> Value</th>
|
158
|
+
</tr>
|
159
|
+
</thead>
|
160
|
+
<tbody>
|
161
|
+
<tr>
|
162
|
+
<td>Computer </td>
|
163
|
+
<td align="right"> $1600</td>
|
164
|
+
</tr>
|
165
|
+
<tr>
|
166
|
+
<td>Phone </td>
|
167
|
+
<td align="right"> $12</td>
|
168
|
+
</tr>
|
169
|
+
<tr>
|
170
|
+
<td>Pipe </td>
|
171
|
+
<td align="right"> $1</td>
|
172
|
+
</tr>
|
173
|
+
</tbody>
|
174
|
+
</table>
|
175
|
+
END_HTML
|
176
|
+
end
|
177
|
+
end
|
178
|
+
end
|
179
|
+
|
63
180
|
end
|
64
181
|
|
65
182
|
|
data/spec/markdowntest_spec.rb
CHANGED
@@ -3,10 +3,10 @@
|
|
3
3
|
BEGIN {
|
4
4
|
require 'pathname'
|
5
5
|
basedir = Pathname.new( __FILE__ ).dirname.parent
|
6
|
-
|
6
|
+
|
7
7
|
libdir = basedir + 'lib'
|
8
8
|
extdir = basedir + 'ext'
|
9
|
-
|
9
|
+
|
10
10
|
$LOAD_PATH.unshift( libdir ) unless $LOAD_PATH.include?( libdir )
|
11
11
|
$LOAD_PATH.unshift( extdir ) unless $LOAD_PATH.include?( extdir )
|
12
12
|
}
|
@@ -33,7 +33,7 @@ describe BlueCloth, "-- MarkdownTest 1.0.3: " do
|
|
33
33
|
before( :all ) do
|
34
34
|
soext = Config::CONFIG['LIBRUBY_ALIASES'].sub( /.*\./, '' )
|
35
35
|
@dlname = "libtidy.#{soext}"
|
36
|
-
|
36
|
+
|
37
37
|
begin
|
38
38
|
DL.dlopen( @dlname )
|
39
39
|
rescue RuntimeError => err
|
@@ -46,7 +46,7 @@ describe BlueCloth, "-- MarkdownTest 1.0.3: " do
|
|
46
46
|
@have_libtidy = true
|
47
47
|
@tidy_error = nil
|
48
48
|
end
|
49
|
-
|
49
|
+
|
50
50
|
begin
|
51
51
|
require 'tidy'
|
52
52
|
rescue LoadError, NameError => err
|
@@ -55,12 +55,12 @@ describe BlueCloth, "-- MarkdownTest 1.0.3: " do
|
|
55
55
|
end
|
56
56
|
|
57
57
|
end
|
58
|
-
|
58
|
+
|
59
59
|
before( :each ) do
|
60
60
|
pending( "These tests require the tidy library: #@tidy_error" ) unless @have_libtidy
|
61
61
|
end
|
62
|
-
|
63
|
-
|
62
|
+
|
63
|
+
|
64
64
|
markdowntest_dir = Pathname.new( __FILE__ ).dirname + 'data/markdowntest'
|
65
65
|
pattern = markdowntest_dir + '*.text'
|
66
66
|
Pathname.glob( pattern.to_s ).each do |textfile|
|
@@ -70,7 +70,7 @@ describe BlueCloth, "-- MarkdownTest 1.0.3: " do
|
|
70
70
|
markdown = textfile.read
|
71
71
|
expected = resultfile.read
|
72
72
|
options = { :smartypants => false }
|
73
|
-
|
73
|
+
|
74
74
|
the_markdown( markdown, options ).should be_transformed_into_normalized_html( expected )
|
75
75
|
end
|
76
76
|
end
|