rtomayko-rdiscount 1.3.4 → 1.3.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -19,13 +19,13 @@ Installation, Hacking
19
19
  RDiscount Gem releases are published to RubyForge and can be installed as
20
20
  follows:
21
21
 
22
- $ [sudo] gem install rdiscount
22
+ $ [sudo] gem install rdiscount
23
23
 
24
24
  The RDiscount sources are available via Git:
25
25
 
26
- $ git clone git://github.com/rtomayko/rdiscount.git
27
- $ cd rdiscount
28
- $ rake --tasks
26
+ $ git clone git://github.com/rtomayko/rdiscount.git
27
+ $ cd rdiscount
28
+ $ rake --tasks
29
29
 
30
30
  For more information, see [the project page](http://github.com/rtomayko/rdiscount).
31
31
 
@@ -35,19 +35,19 @@ Usage
35
35
  RDiscount implements the basic protocol popularized by RedCloth and adopted
36
36
  by BlueCloth:
37
37
 
38
- require 'rdiscount'
39
- markdown = RDiscount.new("Hello World!")
40
- puts markdown.to_html
38
+ require 'rdiscount'
39
+ markdown = RDiscount.new("Hello World!")
40
+ puts markdown.to_html
41
41
 
42
42
  Inject RDiscount into your BlueCloth-using code by replacing your bluecloth
43
43
  require statements with the following:
44
44
 
45
- begin
46
- require 'rdiscount'
47
- BlueCloth = RDiscount
48
- rescue LoadError
49
- require 'bluecloth'
50
- end
45
+ begin
46
+ require 'rdiscount'
47
+ BlueCloth = RDiscount
48
+ rescue LoadError
49
+ require 'bluecloth'
50
+ end
51
51
 
52
52
  COPYING
53
53
  -------
@@ -55,4 +55,4 @@ COPYING
55
55
  Discount is free software; it is released under a BSD-style license
56
56
  that allows you to do as you wish with it as long as you don't attempt
57
57
  to claim it as your own work. RDiscount adopts Discount's license
58
- verbatim. See the file COPYING for more information.
58
+ verbatim. See the file `COPYING` for more information.
data/Rakefile CHANGED
@@ -1,6 +1,6 @@
1
1
  require 'rake/clean'
2
2
 
3
- task :default => 'test:unit'
3
+ task :default => :test
4
4
 
5
5
  # PACKAGING =================================================================
6
6
 
@@ -189,22 +189,45 @@ static Line *
189
189
  htmlblock(Paragraph *p, char *tag)
190
190
  {
191
191
  Line *t = p->text, *ret;
192
- int closesize;
192
+ int closesize, tagsize;
193
193
  char close[MAXTAG+4];
194
194
 
195
- if ( selfclose(t, tag) || (strlen(tag) >= MAXTAG) ) {
195
+ char *ps, *pse;
196
+ int depth;
197
+
198
+ tagsize = strlen(tag);
199
+
200
+ if ( selfclose(t, tag) || (tagsize >= MAXTAG) ) {
196
201
  ret = t->next;
197
202
  t->next = 0;
198
203
  return ret;
199
204
  }
200
205
 
201
206
  closesize = sprintf(close, "</%s>", tag);
207
+ depth = 0;
202
208
 
203
209
  for ( ; t ; t = t->next) {
204
- if ( strncasecmp(T(t->text), close, closesize) == 0 ) {
205
- ret = t->next;
206
- t->next = 0;
207
- return ret;
210
+ ps = T(t->text);
211
+ pse = ps + (S(t->text) - (tagsize + 1));
212
+ for ( ; ps < pse; ps++ ) {
213
+ if ( *ps == '<' ) {
214
+ /* check for close tag */
215
+ if ( strncasecmp(ps, close, closesize) == 0 ) {
216
+ depth--;
217
+ if ( depth == 0 ) {
218
+ ret = t->next;
219
+ t->next = 0;
220
+ return ret;
221
+ }
222
+ continue;
223
+ }
224
+
225
+ /* check for nested open tag */
226
+ if ( (strncasecmp(ps + 1, tag, tagsize) == 0) &&
227
+ (ps[tagsize + 1] == '>' || ps[tagsize + 1] == ' ') ) {
228
+ depth++;
229
+ }
230
+ }
208
231
  }
209
232
  }
210
233
  return 0;
@@ -24,7 +24,7 @@
24
24
  # end
25
25
  #
26
26
  class RDiscount
27
- VERSION = '1.3.4'
27
+ VERSION = '1.3.5'
28
28
 
29
29
  # Original Markdown formatted text.
30
30
  attr_reader :text
@@ -1,8 +1,8 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'rdiscount'
3
- s.version = '1.3.4'
3
+ s.version = '1.3.5'
4
4
  s.summary = "Fast Implementation of Gruber's Markdown in C"
5
- s.date = '2009-03-04'
5
+ s.date = '2009-07-26'
6
6
  s.email = 'r@tomayko.com'
7
7
  s.homepage = 'http://github.com/rtomayko/rdiscount'
8
8
  s.has_rdoc = true
@@ -82,6 +82,18 @@ class MarkdownTest < Test::Unit::TestCase
82
82
  assert_equal "<p><a href=\"/search?query=Markdown+Test&amp;page=2\">Page 2</a></p>\n", markdown.to_html
83
83
  end
84
84
 
85
+ def test_simple_inline_html
86
+ markdown = Markdown.new("before\n\n<div>\n foo\n</div>\nafter")
87
+ assert_equal "<p>before</p>\n\n<div>\n foo\n</div>\n\n\n<p>after</p>\n",
88
+ markdown.to_html
89
+ end
90
+
91
+ def test_that_html_blocks_do_not_require_their_own_end_tag_line
92
+ markdown = Markdown.new("Para 1\n\n<div><pre>HTML block\n</pre></div>\n\nPara 2 [Link](#anchor)")
93
+ assert_equal "<p>Para 1</p>\n\n<div><pre>HTML block\n</pre></div>\n\n\n<p>Para 2 <a href=\"#anchor\">Link</a></p>\n",
94
+ markdown.to_html
95
+ end
96
+
85
97
  # Build tests for each file in the MarkdownTest test suite
86
98
 
87
99
  Dir["#{MARKDOWN_TEST_DIR}/Tests/*.text"].each do |text_file|
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rtomayko-rdiscount
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.4
4
+ version: 1.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Tomayko
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2009-03-04 00:00:00 -08:00
13
+ date: 2009-07-26 00:00:00 -07:00
14
14
  default_executable:
15
15
  dependencies: []
16
16