rdiscount 1.3.4 → 1.3.5
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/README.markdown +14 -14
- data/Rakefile +1 -1
- data/ext/markdown.c +29 -6
- data/lib/rdiscount.rb +1 -1
- data/rdiscount.gemspec +2 -2
- data/test/markdown_test.rb +12 -0
- metadata +6 -4
data/README.markdown
CHANGED
@@ -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
|
-
|
22
|
+
$ [sudo] gem install rdiscount
|
23
23
|
|
24
24
|
The RDiscount sources are available via Git:
|
25
25
|
|
26
|
-
|
27
|
-
|
28
|
-
|
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
|
-
|
39
|
-
|
40
|
-
|
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
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
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
data/ext/markdown.c
CHANGED
@@ -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
|
-
|
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
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
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;
|
data/lib/rdiscount.rb
CHANGED
data/rdiscount.gemspec
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'rdiscount'
|
3
|
-
s.version = '1.3.
|
3
|
+
s.version = '1.3.5'
|
4
4
|
s.summary = "Fast Implementation of Gruber's Markdown in C"
|
5
|
-
s.date = '2009-
|
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
|
data/test/markdown_test.rb
CHANGED
@@ -82,6 +82,18 @@ class MarkdownTest < Test::Unit::TestCase
|
|
82
82
|
assert_equal "<p><a href=\"/search?query=Markdown+Test&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: rdiscount
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
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-
|
13
|
+
date: 2009-07-26 00:00:00 -07:00
|
14
14
|
default_executable:
|
15
15
|
dependencies: []
|
16
16
|
|
@@ -51,6 +51,8 @@ files:
|
|
51
51
|
- test/rdiscount_test.rb
|
52
52
|
has_rdoc: true
|
53
53
|
homepage: http://github.com/rtomayko/rdiscount
|
54
|
+
licenses: []
|
55
|
+
|
54
56
|
post_install_message:
|
55
57
|
rdoc_options: []
|
56
58
|
|
@@ -71,9 +73,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
71
73
|
requirements: []
|
72
74
|
|
73
75
|
rubyforge_project: wink
|
74
|
-
rubygems_version: 1.3.
|
76
|
+
rubygems_version: 1.3.4
|
75
77
|
signing_key:
|
76
|
-
specification_version:
|
78
|
+
specification_version: 3
|
77
79
|
summary: Fast Implementation of Gruber's Markdown in C
|
78
80
|
test_files:
|
79
81
|
- test/markdown_test.rb
|