bluecloth 2.0.7 → 2.0.9

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.
Files changed (47) hide show
  1. data.tar.gz.sig +0 -0
  2. data/ChangeLog +36 -6
  3. data/Rakefile +46 -26
  4. data/Rakefile.local +13 -6
  5. data/ext/VERSION +1 -1
  6. data/ext/bluecloth.c +46 -21
  7. data/ext/bluecloth.h +13 -2
  8. data/ext/cstring.h +3 -1
  9. data/ext/emmatch.c +188 -0
  10. data/ext/generate.c +203 -248
  11. data/ext/html5.c +24 -0
  12. data/ext/markdown.c +122 -98
  13. data/ext/markdown.h +16 -2
  14. data/ext/mkdio.c +43 -9
  15. data/ext/mkdio.h +11 -0
  16. data/ext/resource.c +1 -1
  17. data/ext/tags.c +110 -0
  18. data/ext/tags.h +18 -0
  19. data/lib/bluecloth.rb +33 -26
  20. data/rake/documentation.rb +115 -0
  21. data/rake/helpers.rb +375 -308
  22. data/rake/hg.rb +17 -3
  23. data/rake/manual.rb +11 -6
  24. data/rake/packaging.rb +7 -1
  25. data/rake/publishing.rb +162 -88
  26. data/spec/bluecloth/101_changes_spec.rb +1 -0
  27. data/spec/bluecloth/autolinks_spec.rb +1 -0
  28. data/spec/bluecloth/blockquotes_spec.rb +1 -0
  29. data/spec/bluecloth/code_spans_spec.rb +1 -0
  30. data/spec/bluecloth/emphasis_spec.rb +1 -0
  31. data/spec/bluecloth/entities_spec.rb +1 -0
  32. data/spec/bluecloth/hrules_spec.rb +1 -0
  33. data/spec/bluecloth/images_spec.rb +1 -0
  34. data/spec/bluecloth/inline_html_spec.rb +25 -61
  35. data/spec/bluecloth/lists_spec.rb +1 -0
  36. data/spec/bluecloth/paragraphs_spec.rb +1 -0
  37. data/spec/bluecloth/titles_spec.rb +1 -0
  38. data/spec/bluecloth_spec.rb +22 -6
  39. data/spec/bugfix_spec.rb +79 -2
  40. data/spec/contributions_spec.rb +1 -0
  41. data/spec/discount_spec.rb +46 -2
  42. data/spec/lib/helpers.rb +8 -8
  43. data/spec/lib/matchers.rb +5 -17
  44. data/spec/markdowntest_spec.rb +2 -34
  45. metadata +48 -17
  46. metadata.gz.sig +0 -0
  47. data/rake/rdoc.rb +0 -30
@@ -8,6 +8,7 @@ BEGIN {
8
8
  libdir = basedir + 'lib'
9
9
  extdir = basedir + 'ext'
10
10
 
11
+ $LOAD_PATH.unshift( basedir ) unless $LOAD_PATH.include?( basedir )
11
12
  $LOAD_PATH.unshift( libdir ) unless $LOAD_PATH.include?( libdir )
12
13
  $LOAD_PATH.unshift( extdir ) unless $LOAD_PATH.include?( extdir )
13
14
  }
@@ -8,6 +8,7 @@ BEGIN {
8
8
  libdir = basedir + 'lib'
9
9
  extdir = basedir + 'ext'
10
10
 
11
+ $LOAD_PATH.unshift( basedir ) unless $LOAD_PATH.include?( basedir )
11
12
  $LOAD_PATH.unshift( libdir ) unless $LOAD_PATH.include?( libdir )
12
13
  $LOAD_PATH.unshift( extdir ) unless $LOAD_PATH.include?( extdir )
13
14
  }
@@ -8,6 +8,7 @@ BEGIN {
8
8
  libdir = basedir + 'lib'
9
9
  extdir = basedir + 'ext'
10
10
 
11
+ $LOAD_PATH.unshift( basedir ) unless $LOAD_PATH.include?( basedir )
11
12
  $LOAD_PATH.unshift( libdir ) unless $LOAD_PATH.include?( libdir )
12
13
  $LOAD_PATH.unshift( extdir ) unless $LOAD_PATH.include?( extdir )
13
14
  }
@@ -8,6 +8,7 @@ BEGIN {
8
8
  libdir = basedir + 'lib'
9
9
  extdir = basedir + 'ext'
10
10
 
11
+ $LOAD_PATH.unshift( basedir ) unless $LOAD_PATH.include?( basedir )
11
12
  $LOAD_PATH.unshift( libdir ) unless $LOAD_PATH.include?( libdir )
12
13
  $LOAD_PATH.unshift( extdir ) unless $LOAD_PATH.include?( extdir )
13
14
  }
@@ -8,6 +8,7 @@ BEGIN {
8
8
  libdir = basedir + 'lib'
9
9
  extdir = basedir + 'ext'
10
10
 
11
+ $LOAD_PATH.unshift( basedir ) unless $LOAD_PATH.include?( basedir )
11
12
  $LOAD_PATH.unshift( libdir ) unless $LOAD_PATH.include?( libdir )
12
13
  $LOAD_PATH.unshift( extdir ) unless $LOAD_PATH.include?( extdir )
13
14
  }
@@ -8,6 +8,7 @@ BEGIN {
8
8
  libdir = basedir + 'lib'
9
9
  extdir = basedir + 'ext'
10
10
 
11
+ $LOAD_PATH.unshift( basedir ) unless $LOAD_PATH.include?( basedir )
11
12
  $LOAD_PATH.unshift( libdir ) unless $LOAD_PATH.include?( libdir )
12
13
  $LOAD_PATH.unshift( extdir ) unless $LOAD_PATH.include?( extdir )
13
14
  }
@@ -123,67 +124,6 @@ describe BlueCloth, "document with inline HTML" do
123
124
  end
124
125
 
125
126
 
126
- it "preserves MathML block" do
127
- pending "discount doesn't support this, it explicitly matches block-level HTML elements only"
128
- the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation
129
- Examples
130
- --------
131
-
132
- Now that we have met some of the key players, it is time to see what we can
133
- do. Here are some examples and comments which illustrate the use of the basic
134
- layout and token elements. Consider the expression x2 + 4x + 4 = 0. A basic
135
- MathML presentation encoding for this would be:
136
-
137
- <math>
138
- <mrow>
139
- <msup>
140
- <mi>x</mi>
141
- <mn>2</mn>
142
- </msup>
143
- <mo>+</mo>
144
- <mn>4</mn>
145
- <mi>x</mi>
146
- <mo>+</mo>
147
- <mn>4</mn>
148
- <mo>=</mo>
149
- <mn>0</mn>
150
- </mrow>
151
- </math>
152
-
153
- This encoding will display as you would expect. However, if we were interested
154
- in reusing this expression in unknown situations, we would likely want to spend
155
- a little more effort analyzing and encoding the logical expression structure.
156
- ---
157
- <h2>Examples</h2>
158
-
159
- <p>Now that we have met some of the key players, it is time to see what we can
160
- do. Here are some examples and comments which illustrate the use of the basic
161
- layout and token elements. Consider the expression x2 + 4x + 4 = 0. A basic
162
- MathML presentation encoding for this would be:</p>
163
-
164
- <math>
165
- <mrow>
166
- <msup>
167
- <mi>x</mi>
168
- <mn>2</mn>
169
- </msup>
170
- <mo>+</mo>
171
- <mn>4</mn>
172
- <mi>x</mi>
173
- <mo>+</mo>
174
- <mn>4</mn>
175
- <mo>=</mo>
176
- <mn>0</mn>
177
- </mrow>
178
- </math>
179
-
180
- <p>This encoding will display as you would expect. However, if we were interested
181
- in reusing this expression in unknown situations, we would likely want to spend
182
- a little more effort analyzing and encoding the logical expression structure.</p>
183
- ---
184
- end
185
-
186
-
187
127
  it "preserves span-level HTML" do
188
128
  the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation
189
129
  This is some stuff with a <span class="foo">spanned bit of text</span> in
@@ -232,6 +172,30 @@ describe BlueCloth, "document with inline HTML" do
232
172
  ---
233
173
  end
234
174
 
175
+ it "preserves HTML5 tags" do
176
+ the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation
177
+ <aside>
178
+ <p>This is a sidebar that explains some stuff.</p>
179
+ </aside>
180
+
181
+ The main content.
182
+
183
+ <footer>
184
+ <p>Copyright &copy; 2010 by J. Random Hacker.</p>
185
+ </footer>
186
+ ---
187
+ <aside>
188
+ <p>This is a sidebar that explains some stuff.</p>
189
+ </aside>
190
+
191
+ <p>The main content.</p>
192
+
193
+ <footer>
194
+ <p>Copyright &copy; 2010 by J. Random Hacker.</p>
195
+ </footer>
196
+ ---
197
+ end
198
+
235
199
 
236
200
  end
237
201
 
@@ -8,6 +8,7 @@ BEGIN {
8
8
  libdir = basedir + 'lib'
9
9
  extdir = basedir + 'ext'
10
10
 
11
+ $LOAD_PATH.unshift( basedir ) unless $LOAD_PATH.include?( basedir )
11
12
  $LOAD_PATH.unshift( libdir ) unless $LOAD_PATH.include?( libdir )
12
13
  $LOAD_PATH.unshift( extdir ) unless $LOAD_PATH.include?( extdir )
13
14
  }
@@ -8,6 +8,7 @@ BEGIN {
8
8
  libdir = basedir + 'lib'
9
9
  extdir = basedir + 'ext'
10
10
 
11
+ $LOAD_PATH.unshift( basedir ) unless $LOAD_PATH.include?( basedir )
11
12
  $LOAD_PATH.unshift( libdir ) unless $LOAD_PATH.include?( libdir )
12
13
  $LOAD_PATH.unshift( extdir ) unless $LOAD_PATH.include?( extdir )
13
14
  }
@@ -8,6 +8,7 @@ BEGIN {
8
8
  libdir = basedir + 'lib'
9
9
  extdir = basedir + 'ext'
10
10
 
11
+ $LOAD_PATH.unshift( basedir ) unless $LOAD_PATH.include?( basedir )
11
12
  $LOAD_PATH.unshift( libdir ) unless $LOAD_PATH.include?( libdir )
12
13
  $LOAD_PATH.unshift( extdir ) unless $LOAD_PATH.include?( extdir )
13
14
  }
@@ -8,6 +8,7 @@ BEGIN {
8
8
  libdir = basedir + 'lib'
9
9
  extdir = basedir + 'ext'
10
10
 
11
+ $LOAD_PATH.unshift( basedir ) unless $LOAD_PATH.include?( basedir )
11
12
  $LOAD_PATH.unshift( libdir ) unless $LOAD_PATH.include?( libdir )
12
13
  $LOAD_PATH.unshift( extdir ) unless $LOAD_PATH.include?( extdir )
13
14
  }
@@ -268,14 +269,29 @@ describe BlueCloth do
268
269
  end
269
270
 
270
271
 
271
- it "outputs HTML in the same encoding as the source string" do
272
- pending "until I can figure out what the right way to do m17n in the C API is" do
273
- utf8 = "a string".encode( "UTF-8" )
274
- out = BlueCloth.new( utf8 ).to_html
272
+ it "outputs HTML in UTF8 if given a UTF8 string" do
273
+ input = "a ∫‡®îñg".encode( Encoding::UTF_8 )
274
+ output = BlueCloth.new( input ).to_html
275
275
 
276
- out.encoding.name.should == 'UTF-8'
277
- end
276
+ output.encoding.should == Encoding::UTF_8
277
+ end
278
+
279
+ it "outputs HTML in KOI8-U if given a KOI8-U string" do
280
+ input = "Почему Молчишь".encode( Encoding::KOI8_U )
281
+ output = BlueCloth.new( input ).to_html
282
+
283
+ output.should == "<p>\xF0\xCF\xDE\xC5\xCD\xD5 \xED\xCF\xCC\xDE\xC9\xDB\xD8</p>".
284
+ force_encoding( Encoding::KOI8_U )
278
285
  end
286
+
287
+ it "outputs HTML in Shift-JIS if given a Shift-JIS string" do
288
+ input = "日本語".encode( Encoding::SHIFT_JIS )
289
+ output = BlueCloth.new( input ).to_html
290
+
291
+ output.should == "<p>\x93\xFA\x96{\x8C\xEA</p>".
292
+ force_encoding( Encoding::SHIFT_JIS )
293
+ end
294
+
279
295
  end
280
296
 
281
297
  end
data/spec/bugfix_spec.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ # coding: utf-8
2
3
 
3
4
  BEGIN {
4
5
  require 'pathname'
@@ -7,6 +8,7 @@ BEGIN {
7
8
  libdir = basedir + 'lib'
8
9
  extdir = basedir + 'ext'
9
10
 
11
+ $LOAD_PATH.unshift( basedir ) unless $LOAD_PATH.include?( basedir )
10
12
  $LOAD_PATH.unshift( libdir ) unless $LOAD_PATH.include?( libdir )
11
13
  $LOAD_PATH.unshift( extdir ) unless $LOAD_PATH.include?( extdir )
12
14
  }
@@ -157,14 +159,89 @@ describe BlueCloth, "bugfixes" do
157
159
  <ul>
158
160
  <li><p>testing</p>
159
161
 
160
- <pre><code>pre
162
+ <pre><code> pre
161
163
  </code></pre>
162
164
 
163
- <p>more li</p></li>
165
+ <p> more li</p></li>
164
166
  </ul>
165
167
  END_HTML
166
168
  end
167
169
 
170
+ it "renders heading with trailing spaces correctly (#67)" do
171
+ the_indented_markdown( <<-"END_MARKDOWN" ).should be_transformed_into(<<-"END_HTML").without_indentation
172
+ The Ant-Sugar Tales
173
+ ===================
174
+
175
+ By Candice Yellowflower
176
+
177
+ Use of Metaphor
178
+ ---------------
179
+
180
+ The author's splendid...
181
+ END_MARKDOWN
182
+ <h1>The Ant-Sugar Tales </h1>
183
+
184
+ <p>By Candice Yellowflower</p>
185
+
186
+ <h2>Use of Metaphor </h2>
187
+
188
+ <p>The author's splendid...</p>
189
+ END_HTML
190
+ end
191
+
192
+ it "renders the example from #68 correctly" do
193
+ the_indented_markdown( <<-"END_MARKDOWN" ).should be_transformed_into(<<-"END_HTML").without_indentation
194
+ START example
195
+
196
+ 1. ö
197
+ 1. ü
198
+ 1. ó
199
+ 1. ő
200
+ 1. ú
201
+ 1. é
202
+ 1. á
203
+ 1. ű
204
+ 1. í
205
+
206
+ - ö
207
+ - ü
208
+ - ó
209
+ - ő
210
+ - ú
211
+ - é
212
+ - á
213
+ - ű
214
+ - í
215
+
216
+ END example
217
+ END_MARKDOWN
218
+ <p>START example</p>
219
+
220
+ <ol>
221
+ <li>ö</li>
222
+ <li>ü</li>
223
+ <li>ó</li>
224
+ <li>ő</li>
225
+ <li>ú</li>
226
+ <li>é</li>
227
+ <li>á</li>
228
+ <li>ű</li>
229
+ <li><p>í</p></li>
230
+ <li><p>ö</p></li>
231
+ <li>ü</li>
232
+ <li>ó</li>
233
+ <li>ő</li>
234
+ <li>ú</li>
235
+ <li>é</li>
236
+ <li>á</li>
237
+ <li>ű</li>
238
+ <li>í</li>
239
+ </ol>
240
+
241
+ <p>END example</p>
242
+ END_HTML
243
+ end
244
+
168
245
  end
169
246
 
170
247
 
@@ -7,6 +7,7 @@ BEGIN {
7
7
  libdir = basedir + 'lib'
8
8
  extdir = basedir + 'ext'
9
9
 
10
+ $LOAD_PATH.unshift( basedir ) unless $LOAD_PATH.include?( basedir )
10
11
  $LOAD_PATH.unshift( libdir ) unless $LOAD_PATH.include?( libdir )
11
12
  $LOAD_PATH.unshift( extdir ) unless $LOAD_PATH.include?( extdir )
12
13
  }
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ #coding: utf-8
2
3
 
3
4
  BEGIN {
4
5
  require 'pathname'
@@ -7,6 +8,7 @@ BEGIN {
7
8
  libdir = basedir + 'lib'
8
9
  extdir = basedir + 'ext'
9
10
 
11
+ $LOAD_PATH.unshift( basedir ) unless $LOAD_PATH.include?( basedir )
10
12
  $LOAD_PATH.unshift( libdir ) unless $LOAD_PATH.include?( libdir )
11
13
  $LOAD_PATH.unshift( extdir ) unless $LOAD_PATH.include?( extdir )
12
14
  }
@@ -59,13 +61,30 @@ describe BlueCloth, "implementation of Discount-specific features" do
59
61
  should be_transformed_into( '<p>bar</p>' )
60
62
  end
61
63
 
64
+ it "renders lang: links as language-specified blocks" do
65
+ the_markdown( "[gift](lang:de)", :pseudoprotocols => true ).
66
+ should be_transformed_into( '<p><span lang="de">gift</span></p>' )
67
+ end
68
+
62
69
  end
63
70
 
64
71
 
65
72
  describe "Markdown-Extra tables" do
66
73
 
74
+ it "doesn't try to render tables if :tables isn't set" do
75
+ the_indented_markdown( <<-"END_MARKDOWN" ).should be_transformed_into(<<-"END_HTML").without_indentation
76
+ a | b
77
+ -----|-----
78
+ hello|sailor
79
+ END_MARKDOWN
80
+ <p> a | b
81
+ -----|-----
82
+ hello|sailor</p>
83
+ END_HTML
84
+ end
85
+
67
86
  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
87
+ the_indented_markdown( <<-"END_MARKDOWN", :tables => true ).should be_transformed_into(<<-"END_HTML").without_indentation
69
88
  a | b
70
89
  -----|-----
71
90
  hello|sailor
@@ -88,7 +107,7 @@ describe BlueCloth, "implementation of Discount-specific features" do
88
107
  end
89
108
 
90
109
  it "renders simple markdown-extra tables" do
91
- the_indented_markdown( <<-"END_MARKDOWN", :strict => false ).should be_transformed_into(<<-"END_HTML").without_indentation
110
+ the_indented_markdown( <<-"END_MARKDOWN", :tables => true ).should be_transformed_into(<<-"END_HTML").without_indentation
92
111
  First Header | Second Header
93
112
  ------------- | -------------
94
113
  Content Cell | Content Cell
@@ -177,6 +196,31 @@ describe BlueCloth, "implementation of Discount-specific features" do
177
196
  end
178
197
  end
179
198
 
199
+
200
+ describe "tilde strike-through" do
201
+
202
+ it "doesn't render tilde-bracketed test when :strikethrough isn't set" do
203
+ the_markdown( "~~cancelled~~" ).
204
+ should be_transformed_into( '<p>~~cancelled~~</p>' )
205
+ end
206
+
207
+ it "renders double tilde-bracketed text as strikethrough" do
208
+ the_markdown( "~~cancelled~~", :strikethrough => true ).
209
+ should be_transformed_into( '<p><del>cancelled</del></p>' )
210
+ end
211
+
212
+ it "renders tilde-bracketed text for tilde-brackets of more than two tildes" do
213
+ the_markdown( "~~~~cancelled~~~~", :strikethrough => true ).
214
+ should be_transformed_into( '<p><del>cancelled</del></p>' )
215
+ end
216
+
217
+ it "includes extra tildes in tilde-bracketed text" do
218
+ the_markdown( "~~~cancelled~~", :strikethrough => true ).
219
+ should be_transformed_into( '<p><del>~cancelled</del></p>' )
220
+ end
221
+
222
+ end
223
+
180
224
  end
181
225
 
182
226
 
data/spec/lib/helpers.rb CHANGED
@@ -20,27 +20,27 @@ require 'spec/runner/formatter/html_formatter'
20
20
  class Spec::Runner::Formatter::HtmlFormatter
21
21
  def example_failed( example, counter, failure )
22
22
  failure_style = failure.pending_fixed? ? 'pending_fixed' : 'failed'
23
-
23
+
24
24
  unless @header_red
25
25
  @output.puts " <script type=\"text/javascript\">makeRed('rspec-header');</script>"
26
26
  @header_red = true
27
27
  end
28
-
28
+
29
29
  unless @example_group_red
30
30
  css_class = 'example_group_%d' % [current_example_group_number||0]
31
31
  @output.puts " <script type=\"text/javascript\">makeRed('#{css_class}');</script>"
32
32
  @example_group_red = true
33
33
  end
34
-
34
+
35
35
  move_progress()
36
-
36
+
37
37
  @output.puts " <dd class=\"spec #{failure_style}\">",
38
38
  " <span class=\"failed_spec_name\">#{h(example.description)}</span>",
39
39
  " <div class=\"failure\" id=\"failure_#{counter}\">"
40
40
  if failure.exception
41
41
  backtrace = format_backtrace( failure.exception.backtrace )
42
42
  message = failure.exception.message
43
-
43
+
44
44
  @output.puts " <div class=\"message\"><code>#{h message}</code></div>",
45
45
  " <div class=\"backtrace\"><pre>#{backtrace}</pre></div>"
46
46
  end
@@ -48,7 +48,7 @@ class Spec::Runner::Formatter::HtmlFormatter
48
48
  if extra = extra_failure_content( failure )
49
49
  @output.puts( extra )
50
50
  end
51
-
51
+
52
52
  @output.puts " </div>",
53
53
  " </dd>"
54
54
  @output.flush
@@ -56,7 +56,7 @@ class Spec::Runner::Formatter::HtmlFormatter
56
56
 
57
57
 
58
58
  alias_method :default_global_styles, :global_styles
59
-
59
+
60
60
  def global_styles
61
61
  css = default_global_styles()
62
62
  css << %Q{
@@ -129,7 +129,7 @@ class Spec::Runner::Formatter::HtmlFormatter
129
129
  color: white;
130
130
  }
131
131
  }
132
-
132
+
133
133
  return css
134
134
  end
135
135
  end