bluecloth 2.0.6.pre120-x86-mswin32
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +363 -0
- data/LICENSE +27 -0
- data/LICENSE.discount +47 -0
- data/README +81 -0
- data/Rakefile +349 -0
- data/Rakefile.local +43 -0
- data/bin/bluecloth +84 -0
- data/ext/Csio.c +61 -0
- data/ext/VERSION +1 -0
- data/ext/amalloc.h +29 -0
- data/ext/bluecloth.c +391 -0
- data/ext/bluecloth.h +19 -0
- data/ext/config.h +55 -0
- data/ext/css.c +76 -0
- data/ext/cstring.h +75 -0
- data/ext/docheader.c +43 -0
- data/ext/extconf.rb +52 -0
- data/ext/generate.c +1602 -0
- data/ext/markdown.c +1078 -0
- data/ext/markdown.h +146 -0
- data/ext/mkdio.c +303 -0
- data/ext/mkdio.h +79 -0
- data/ext/resource.c +155 -0
- data/ext/version.c +28 -0
- data/ext/xml.c +82 -0
- data/ext/xmlpage.c +48 -0
- data/lib/1.8/bluecloth_ext.so +0 -0
- data/lib/1.9/bluecloth_ext.so +0 -0
- data/lib/bluecloth.rb +164 -0
- data/rake/191_compat.rb +26 -0
- data/rake/dependencies.rb +76 -0
- data/rake/helpers.rb +434 -0
- data/rake/hg.rb +273 -0
- data/rake/manual.rb +782 -0
- data/rake/packaging.rb +126 -0
- data/rake/publishing.rb +269 -0
- data/rake/rdoc.rb +30 -0
- data/rake/style.rb +62 -0
- data/rake/svn.rb +668 -0
- data/rake/testing.rb +187 -0
- data/rake/verifytask.rb +64 -0
- data/rake/win32.rb +190 -0
- data/spec/bluecloth/101_changes_spec.rb +141 -0
- data/spec/bluecloth/autolinks_spec.rb +49 -0
- data/spec/bluecloth/blockquotes_spec.rb +145 -0
- data/spec/bluecloth/code_spans_spec.rb +164 -0
- data/spec/bluecloth/emphasis_spec.rb +164 -0
- data/spec/bluecloth/entities_spec.rb +65 -0
- data/spec/bluecloth/hrules_spec.rb +90 -0
- data/spec/bluecloth/images_spec.rb +92 -0
- data/spec/bluecloth/inline_html_spec.rb +238 -0
- data/spec/bluecloth/links_spec.rb +171 -0
- data/spec/bluecloth/lists_spec.rb +294 -0
- data/spec/bluecloth/paragraphs_spec.rb +75 -0
- data/spec/bluecloth/titles_spec.rb +305 -0
- data/spec/bluecloth_spec.rb +281 -0
- data/spec/bugfix_spec.rb +172 -0
- data/spec/contributions_spec.rb +85 -0
- data/spec/data/antsugar.txt +34 -0
- data/spec/data/markdowntest/Amps and angle encoding.html +17 -0
- data/spec/data/markdowntest/Amps and angle encoding.text +21 -0
- data/spec/data/markdowntest/Auto links.html +18 -0
- data/spec/data/markdowntest/Auto links.text +13 -0
- data/spec/data/markdowntest/Backslash escapes.html +118 -0
- data/spec/data/markdowntest/Backslash escapes.text +120 -0
- data/spec/data/markdowntest/Blockquotes with code blocks.html +15 -0
- data/spec/data/markdowntest/Blockquotes with code blocks.text +11 -0
- data/spec/data/markdowntest/Code Blocks.html +18 -0
- data/spec/data/markdowntest/Code Blocks.text +14 -0
- data/spec/data/markdowntest/Code Spans.html +5 -0
- data/spec/data/markdowntest/Code Spans.text +5 -0
- data/spec/data/markdowntest/Hard-wrapped paragraphs with list-like lines.html +8 -0
- data/spec/data/markdowntest/Hard-wrapped paragraphs with list-like lines.text +8 -0
- data/spec/data/markdowntest/Horizontal rules.html +71 -0
- data/spec/data/markdowntest/Horizontal rules.text +67 -0
- data/spec/data/markdowntest/Inline HTML (Advanced).html +15 -0
- data/spec/data/markdowntest/Inline HTML (Advanced).text +15 -0
- data/spec/data/markdowntest/Inline HTML (Simple).html +72 -0
- data/spec/data/markdowntest/Inline HTML (Simple).text +69 -0
- data/spec/data/markdowntest/Inline HTML comments.html +13 -0
- data/spec/data/markdowntest/Inline HTML comments.text +13 -0
- data/spec/data/markdowntest/Links, inline style.html +11 -0
- data/spec/data/markdowntest/Links, inline style.text +12 -0
- data/spec/data/markdowntest/Links, reference style.html +52 -0
- data/spec/data/markdowntest/Links, reference style.text +71 -0
- data/spec/data/markdowntest/Links, shortcut references.html +9 -0
- data/spec/data/markdowntest/Links, shortcut references.text +20 -0
- data/spec/data/markdowntest/Literal quotes in titles.html +3 -0
- data/spec/data/markdowntest/Literal quotes in titles.text +7 -0
- data/spec/data/markdowntest/Markdown Documentation - Basics.html +314 -0
- data/spec/data/markdowntest/Markdown Documentation - Basics.text +306 -0
- data/spec/data/markdowntest/Markdown Documentation - Syntax.html +942 -0
- data/spec/data/markdowntest/Markdown Documentation - Syntax.text +888 -0
- data/spec/data/markdowntest/Nested blockquotes.html +9 -0
- data/spec/data/markdowntest/Nested blockquotes.text +5 -0
- data/spec/data/markdowntest/Ordered and unordered lists.html +148 -0
- data/spec/data/markdowntest/Ordered and unordered lists.text +131 -0
- data/spec/data/markdowntest/Strong and em together.html +7 -0
- data/spec/data/markdowntest/Strong and em together.text +7 -0
- data/spec/data/markdowntest/Tabs.html +25 -0
- data/spec/data/markdowntest/Tabs.text +21 -0
- data/spec/data/markdowntest/Tidyness.html +8 -0
- data/spec/data/markdowntest/Tidyness.text +5 -0
- data/spec/data/ml-announce.txt +17 -0
- data/spec/data/re-overflow.txt +67 -0
- data/spec/data/re-overflow2.txt +281 -0
- data/spec/discount_spec.rb +184 -0
- data/spec/lib/constants.rb +5 -0
- data/spec/lib/helpers.rb +137 -0
- data/spec/lib/matchers.rb +235 -0
- data/spec/markdowntest_spec.rb +79 -0
- metadata +205 -0
data/spec/lib/helpers.rb
ADDED
@@ -0,0 +1,137 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
# encoding: utf-8
|
3
|
+
|
4
|
+
require 'spec'
|
5
|
+
require 'bluecloth'
|
6
|
+
|
7
|
+
|
8
|
+
module BlueCloth::SpecHelpers
|
9
|
+
|
10
|
+
###############
|
11
|
+
module_function
|
12
|
+
###############
|
13
|
+
|
14
|
+
end
|
15
|
+
|
16
|
+
|
17
|
+
# Override the badly-formatted output of the RSpec HTML formatter
|
18
|
+
require 'spec/runner/formatter/html_formatter'
|
19
|
+
|
20
|
+
class Spec::Runner::Formatter::HtmlFormatter
|
21
|
+
def example_failed( example, counter, failure )
|
22
|
+
failure_style = failure.pending_fixed? ? 'pending_fixed' : 'failed'
|
23
|
+
|
24
|
+
unless @header_red
|
25
|
+
@output.puts " <script type=\"text/javascript\">makeRed('rspec-header');</script>"
|
26
|
+
@header_red = true
|
27
|
+
end
|
28
|
+
|
29
|
+
unless @example_group_red
|
30
|
+
css_class = 'example_group_%d' % [current_example_group_number||0]
|
31
|
+
@output.puts " <script type=\"text/javascript\">makeRed('#{css_class}');</script>"
|
32
|
+
@example_group_red = true
|
33
|
+
end
|
34
|
+
|
35
|
+
move_progress()
|
36
|
+
|
37
|
+
@output.puts " <dd class=\"spec #{failure_style}\">",
|
38
|
+
" <span class=\"failed_spec_name\">#{h(example.description)}</span>",
|
39
|
+
" <div class=\"failure\" id=\"failure_#{counter}\">"
|
40
|
+
if failure.exception
|
41
|
+
backtrace = format_backtrace( failure.exception.backtrace )
|
42
|
+
message = failure.exception.message
|
43
|
+
|
44
|
+
@output.puts " <div class=\"message\"><code>#{h message}</code></div>",
|
45
|
+
" <div class=\"backtrace\"><pre>#{backtrace}</pre></div>"
|
46
|
+
end
|
47
|
+
|
48
|
+
if extra = extra_failure_content( failure )
|
49
|
+
@output.puts( extra )
|
50
|
+
end
|
51
|
+
|
52
|
+
@output.puts " </div>",
|
53
|
+
" </dd>"
|
54
|
+
@output.flush
|
55
|
+
end
|
56
|
+
|
57
|
+
|
58
|
+
alias_method :default_global_styles, :global_styles
|
59
|
+
|
60
|
+
def global_styles
|
61
|
+
css = default_global_styles()
|
62
|
+
css << %Q{
|
63
|
+
/* Stuff added by #{__FILE__} */
|
64
|
+
|
65
|
+
/* Overrides */
|
66
|
+
#rspec-header {
|
67
|
+
-webkit-box-shadow: #333 0 2px 5px;
|
68
|
+
margin-bottom: 1em;
|
69
|
+
}
|
70
|
+
|
71
|
+
.example_group dt {
|
72
|
+
-webkit-box-shadow: #333 0 2px 3px;
|
73
|
+
}
|
74
|
+
|
75
|
+
/* Style for log output */
|
76
|
+
dd.log-message {
|
77
|
+
background: #eee;
|
78
|
+
padding: 0 2em;
|
79
|
+
margin: 0.2em 1em;
|
80
|
+
border-bottom: 1px dotted #999;
|
81
|
+
border-top: 1px dotted #999;
|
82
|
+
text-indent: -1em;
|
83
|
+
}
|
84
|
+
|
85
|
+
/* Parts of the message */
|
86
|
+
dd.log-message .log-time {
|
87
|
+
font-weight: bold;
|
88
|
+
}
|
89
|
+
dd.log-message .log-time:after {
|
90
|
+
content: ": ";
|
91
|
+
}
|
92
|
+
dd.log-message .log-level {
|
93
|
+
font-variant: small-caps;
|
94
|
+
border: 1px solid #ccc;
|
95
|
+
padding: 1px 2px;
|
96
|
+
}
|
97
|
+
dd.log-message .log-name {
|
98
|
+
font-size: 1.2em;
|
99
|
+
color: #1e51b2;
|
100
|
+
}
|
101
|
+
dd.log-message .log-name:before { content: "«"; }
|
102
|
+
dd.log-message .log-name:after { content: "»"; }
|
103
|
+
|
104
|
+
dd.log-message .log-message-text {
|
105
|
+
padding-left: 4px;
|
106
|
+
font-family: Monaco, "Andale Mono", "Vera Sans Mono", mono;
|
107
|
+
}
|
108
|
+
|
109
|
+
|
110
|
+
/* Distinguish levels */
|
111
|
+
dd.log-message.debug { color: #666; }
|
112
|
+
dd.log-message.info {}
|
113
|
+
|
114
|
+
dd.log-message.warn,
|
115
|
+
dd.log-message.error {
|
116
|
+
background: #ff9;
|
117
|
+
}
|
118
|
+
dd.log-message.error .log-level,
|
119
|
+
dd.log-message.error .log-message-text {
|
120
|
+
color: #900;
|
121
|
+
}
|
122
|
+
dd.log-message.fatal {
|
123
|
+
background: #900;
|
124
|
+
color: white;
|
125
|
+
font-weight: bold;
|
126
|
+
border: 0;
|
127
|
+
}
|
128
|
+
dd.log-message.fatal .log-name {
|
129
|
+
color: white;
|
130
|
+
}
|
131
|
+
}
|
132
|
+
|
133
|
+
return css
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
|
@@ -0,0 +1,235 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'bluecloth'
|
4
|
+
require 'diff/lcs'
|
5
|
+
require 'diff/lcs/callbacks'
|
6
|
+
require 'spec/lib/constants'
|
7
|
+
require 'rbconfig'
|
8
|
+
|
9
|
+
|
10
|
+
### Fixturing functions
|
11
|
+
module BlueCloth::Matchers
|
12
|
+
|
13
|
+
### Matcher for comparing output of a BlueCloth-generated HTML fragment against a known-good
|
14
|
+
### string.
|
15
|
+
class TransformMatcher
|
16
|
+
|
17
|
+
### Create a new matcher for the given +html+
|
18
|
+
def initialize( html )
|
19
|
+
@html = html
|
20
|
+
end
|
21
|
+
|
22
|
+
### Strip tab indentation from the expected HTML output.
|
23
|
+
def without_indentation
|
24
|
+
if indent = @html[/\A\t+/]
|
25
|
+
indent.gsub!( /\A\n/m, '' )
|
26
|
+
@html.gsub!( /^#{indent}/m, '' )
|
27
|
+
end
|
28
|
+
|
29
|
+
return self
|
30
|
+
end
|
31
|
+
|
32
|
+
|
33
|
+
### Returns true if the HTML generated by the given +bluecloth+ object matches the
|
34
|
+
### expected HTML, comparing only the salient document structures.
|
35
|
+
def matches?( bluecloth )
|
36
|
+
@bluecloth = bluecloth
|
37
|
+
@output_html = bluecloth.to_html.gsub( /\n\n\n/, "\n\n" )
|
38
|
+
return @output_html.strip == @html.strip
|
39
|
+
end
|
40
|
+
|
41
|
+
### Build a failure message for the matching case.
|
42
|
+
def failure_message
|
43
|
+
if self.should_output_html?
|
44
|
+
patch = self.make_html_patch( @html, @output_html )
|
45
|
+
return %{
|
46
|
+
<p>Expected the generated html:<br />
|
47
|
+
<pre><code>#@output_html</code></pre>
|
48
|
+
to be the same as:<br />
|
49
|
+
<pre><code>#@html</code></pre>
|
50
|
+
</p>
|
51
|
+
<p>Diffs:</p>
|
52
|
+
#{patch}
|
53
|
+
}
|
54
|
+
else
|
55
|
+
patch = self.make_patch( @html, @output_html )
|
56
|
+
return ("Expected the generated html:\n\n %p\n\nto be the same as:\n\n" +
|
57
|
+
" %p\n\nDiffs:\n\n%s") % [ @output_html, @html, patch ]
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
### Build a failure message for the non-matching case.
|
62
|
+
def negative_failure_message
|
63
|
+
return "Expected the generated html:\n\n %p\n\nnot to be the same as:\n\n %p\n\n" %
|
64
|
+
[ @output_html, @html ]
|
65
|
+
end
|
66
|
+
|
67
|
+
|
68
|
+
### Returns true if it appears HTML output should be used instead of plain-text. This
|
69
|
+
### will be true if running from TextMate or if the HTML_LOGGING environment variable
|
70
|
+
### is set.
|
71
|
+
def should_output_html?
|
72
|
+
return false
|
73
|
+
# return ENV['HTML_LOGGING'] ||
|
74
|
+
# (ENV['TM_FILENAME'] && ENV['TM_FILENAME'] =~ /_spec\.rb/)
|
75
|
+
end
|
76
|
+
|
77
|
+
|
78
|
+
### Compute a patch between the given +expected+ output and the +actual+ output
|
79
|
+
### and return it as a string.
|
80
|
+
def make_patch( expected, actual )
|
81
|
+
diffs = Diff::LCS.sdiff( expected.split("\n"), actual.split("\n"),
|
82
|
+
Diff::LCS::ContextDiffCallbacks )
|
83
|
+
|
84
|
+
maxcol = diffs.flatten.
|
85
|
+
collect {|d| [d.old_element.to_s.length, d.new_element.to_s.length ] }.
|
86
|
+
flatten.max || 0
|
87
|
+
maxcol += 4
|
88
|
+
|
89
|
+
patch = " %#{maxcol}s | %s\n" % [ "Expected", "Actual" ]
|
90
|
+
patch << diffs.collect do |changeset|
|
91
|
+
changeset.collect do |change|
|
92
|
+
"%s [%03d, %03d]: %#{maxcol}s | %-#{maxcol}s" % [
|
93
|
+
change.action,
|
94
|
+
change.old_position,
|
95
|
+
change.new_position,
|
96
|
+
change.old_element.inspect,
|
97
|
+
change.new_element.inspect,
|
98
|
+
]
|
99
|
+
end.join("\n")
|
100
|
+
end.join("\n---\n")
|
101
|
+
end
|
102
|
+
|
103
|
+
### Compute a patch similar to #make_patch, but output HTML instead of plain text.
|
104
|
+
def make_html_patch( expected, actual )
|
105
|
+
diffs = Diff::LCS.sdiff( expected.split("\n"), actual.split("\n"),
|
106
|
+
Diff::LCS::ContextDiffCallbacks )
|
107
|
+
|
108
|
+
patch = %{
|
109
|
+
<table>
|
110
|
+
<caption>Diffs</caption>
|
111
|
+
<thead>
|
112
|
+
<tr><th>Op</th><th>Pos</th><th>Expected</th><th>Actual</th></tr>
|
113
|
+
</thead>
|
114
|
+
<tbody>
|
115
|
+
}
|
116
|
+
patch << diffs.collect do |changeset|
|
117
|
+
changeset.collect do |change|
|
118
|
+
"<tr><td>%s</td><td>[%03d, %03d]</td><td>%s</td><td>%s</td></tr>" % [
|
119
|
+
change.action,
|
120
|
+
change.old_position,
|
121
|
+
change.new_position,
|
122
|
+
change.old_element.inspect,
|
123
|
+
change.new_element.inspect,
|
124
|
+
]
|
125
|
+
end.join("\n")
|
126
|
+
end.join( "</tbody><tbody>" )
|
127
|
+
patch << %{</tbody></table>\n}
|
128
|
+
end
|
129
|
+
|
130
|
+
end
|
131
|
+
|
132
|
+
### Variant of the regular TransformMatcher that normalizes the two strings using the 'tidy'
|
133
|
+
### library before comparing.
|
134
|
+
class TidyTransformMatcher < TransformMatcher
|
135
|
+
|
136
|
+
TIDY_OPTIONS = {}
|
137
|
+
@tidy = nil
|
138
|
+
|
139
|
+
### Fetch the class-global Tidy object, creating it if necessary
|
140
|
+
def self::tidy_object
|
141
|
+
unless @tidy
|
142
|
+
require 'tidy'
|
143
|
+
soext = Config::CONFIG['LIBRUBY_ALIASES'].sub( /.*\./, '' )
|
144
|
+
Tidy.path = "libtidy.#{soext}"
|
145
|
+
@tidy = Tidy.new( TIDY_OPTIONS )
|
146
|
+
end
|
147
|
+
|
148
|
+
return @tidy
|
149
|
+
end
|
150
|
+
|
151
|
+
|
152
|
+
### Set the matcher's expected output to a tidied version of the input +html+.
|
153
|
+
def initialize( html )
|
154
|
+
@html = self.class.tidy_object.clean( html )
|
155
|
+
end
|
156
|
+
|
157
|
+
|
158
|
+
### Returns true if the HTML generated by the given +bluecloth+ object matches the
|
159
|
+
### expected HTML after normalizing them both with 'tidy'.
|
160
|
+
def matches?( bluecloth )
|
161
|
+
@bluecloth = bluecloth
|
162
|
+
@output_html = self.class.tidy_object.clean( bluecloth.to_html )
|
163
|
+
return @output_html == @html
|
164
|
+
end
|
165
|
+
|
166
|
+
end
|
167
|
+
|
168
|
+
|
169
|
+
class TransformRegexpMatcher
|
170
|
+
|
171
|
+
### Create a new matcher for the given +regexp+
|
172
|
+
def initialize( regexp )
|
173
|
+
@regexp = regexp
|
174
|
+
end
|
175
|
+
|
176
|
+
### Returns true if the regexp associated with this matcher matches the output generated
|
177
|
+
### by the specified +bluecloth+ object.
|
178
|
+
def matches?( bluecloth )
|
179
|
+
@bluecloth = bluecloth
|
180
|
+
@output_html = bluecloth.to_html
|
181
|
+
return @output_html =~ @regexp
|
182
|
+
end
|
183
|
+
|
184
|
+
### Build a failure message for the matching case.
|
185
|
+
def failure_message
|
186
|
+
return "Expected the generated html:\n\n %pto match the regexp:\n\n%p\n\n" %
|
187
|
+
[ @output_html, @regexp ]
|
188
|
+
end
|
189
|
+
|
190
|
+
|
191
|
+
### Build a failure message for the negative matching case.
|
192
|
+
def negative_failure_message
|
193
|
+
return "Expected the generated html:\n\n %pnot to match the regexp:\n\n%p\n\n" %
|
194
|
+
[ @output_html, @regexp ]
|
195
|
+
end
|
196
|
+
end
|
197
|
+
|
198
|
+
|
199
|
+
### Create a new BlueCloth object out of the given +string+ and +options+ and
|
200
|
+
### return it.
|
201
|
+
def the_markdown( string, *options )
|
202
|
+
return BlueCloth.new( string, *options )
|
203
|
+
end
|
204
|
+
|
205
|
+
|
206
|
+
### Strip indentation from the given +string+, create a new BlueCloth object
|
207
|
+
### out of the result and any +options+, and return it.
|
208
|
+
def the_indented_markdown( string, *options )
|
209
|
+
if indent = string[/\A\t+/]
|
210
|
+
indent.gsub!( /\A\n/m, '' )
|
211
|
+
$stderr.puts "Source indent is: %p" % [ indent ] if $DEBUG
|
212
|
+
string.gsub!( /^#{indent}/m, '' )
|
213
|
+
end
|
214
|
+
|
215
|
+
return BlueCloth.new( string, *options )
|
216
|
+
end
|
217
|
+
|
218
|
+
|
219
|
+
### Generate a matcher that expects to equal the given +html+.
|
220
|
+
def be_transformed_into( html )
|
221
|
+
return BlueCloth::Matchers::TransformMatcher.new( html )
|
222
|
+
end
|
223
|
+
|
224
|
+
### Generate a matcher that expects to match a normalized version of the specified +html+.
|
225
|
+
def be_transformed_into_normalized_html( html )
|
226
|
+
return BlueCloth::Matchers::TidyTransformMatcher.new( html )
|
227
|
+
end
|
228
|
+
|
229
|
+
### Generate a matcher that expects to match the given +regexp+.
|
230
|
+
def be_transformed_into_html_matching( regexp )
|
231
|
+
return BlueCloth::Matchers::TransformMatcher.new( regexp )
|
232
|
+
end
|
233
|
+
|
234
|
+
end # module BlueCloth::Matchers
|
235
|
+
|
@@ -0,0 +1,79 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
BEGIN {
|
4
|
+
require 'pathname'
|
5
|
+
basedir = Pathname.new( __FILE__ ).dirname.parent
|
6
|
+
|
7
|
+
libdir = basedir + 'lib'
|
8
|
+
extdir = basedir + 'ext'
|
9
|
+
|
10
|
+
$LOAD_PATH.unshift( libdir ) unless $LOAD_PATH.include?( libdir )
|
11
|
+
$LOAD_PATH.unshift( extdir ) unless $LOAD_PATH.include?( extdir )
|
12
|
+
}
|
13
|
+
|
14
|
+
require 'spec'
|
15
|
+
require 'bluecloth'
|
16
|
+
|
17
|
+
require 'spec/lib/helpers'
|
18
|
+
require 'spec/lib/constants'
|
19
|
+
require 'spec/lib/matchers'
|
20
|
+
|
21
|
+
require 'rbconfig'
|
22
|
+
require 'dl'
|
23
|
+
|
24
|
+
|
25
|
+
#####################################################################
|
26
|
+
### C O N T E X T S
|
27
|
+
#####################################################################
|
28
|
+
|
29
|
+
describe BlueCloth, "-- MarkdownTest 1.0.3: " do
|
30
|
+
include BlueCloth::TestConstants,
|
31
|
+
BlueCloth::Matchers
|
32
|
+
|
33
|
+
before( :all ) do
|
34
|
+
soext = Config::CONFIG['LIBRUBY_ALIASES'].sub( /.*\./, '' )
|
35
|
+
@dlname = "libtidy.#{soext}"
|
36
|
+
|
37
|
+
begin
|
38
|
+
DL.dlopen( @dlname )
|
39
|
+
rescue RuntimeError => err
|
40
|
+
@have_libtidy = false
|
41
|
+
@tidy_error = err.message
|
42
|
+
rescue DL::DLError => err
|
43
|
+
@have_libtidy = false
|
44
|
+
@tidy_error = err.message
|
45
|
+
else
|
46
|
+
@have_libtidy = true
|
47
|
+
@tidy_error = nil
|
48
|
+
end
|
49
|
+
|
50
|
+
begin
|
51
|
+
require 'tidy'
|
52
|
+
rescue LoadError, NameError => err
|
53
|
+
@have_libtidy = false
|
54
|
+
@tidy_error = err.message
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
|
59
|
+
before( :each ) do
|
60
|
+
pending( "These tests require the tidy library: #@tidy_error" ) unless @have_libtidy
|
61
|
+
end
|
62
|
+
|
63
|
+
|
64
|
+
markdowntest_dir = Pathname.new( __FILE__ ).dirname + 'data/markdowntest'
|
65
|
+
pattern = markdowntest_dir + '*.text'
|
66
|
+
Pathname.glob( pattern.to_s ).each do |textfile|
|
67
|
+
resultfile = Pathname.new( textfile.to_s.sub(/\.text/, '.html') )
|
68
|
+
|
69
|
+
it textfile.basename( '.text' ) do
|
70
|
+
markdown = textfile.read
|
71
|
+
expected = resultfile.read
|
72
|
+
options = { :smartypants => false }
|
73
|
+
|
74
|
+
the_markdown( markdown, options ).should be_transformed_into_normalized_html( expected )
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
end
|
79
|
+
|