bluefeather 0.10

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 (46) hide show
  1. data/Rakefile.rb +168 -0
  2. data/bin/bluefeather +4 -0
  3. data/doc/author-and-license.bfdoc +16 -0
  4. data/doc/base.css +135 -0
  5. data/doc/basic-usage.bfdoc +265 -0
  6. data/doc/black.css +130 -0
  7. data/doc/class-reference.bfdoc +105 -0
  8. data/doc/difference.bfdoc +63 -0
  9. data/doc/en/author-and-license.bfdoc +20 -0
  10. data/doc/en/base.css +136 -0
  11. data/doc/en/basic-usage.bfdoc +266 -0
  12. data/doc/en/black.css +130 -0
  13. data/doc/en/class-reference.bfdoc +6 -0
  14. data/doc/en/difference.bfdoc +72 -0
  15. data/doc/en/format-extension.bfdoc +324 -0
  16. data/doc/en/index.bfdoc +41 -0
  17. data/doc/en/metadata-reference.bfdoc +7 -0
  18. data/doc/format-extension.bfdoc +325 -0
  19. data/doc/index.bfdoc +36 -0
  20. data/doc/metadata-reference.bfdoc +86 -0
  21. data/lib/bluefeather.rb +1872 -0
  22. data/lib/bluefeather/cui.rb +207 -0
  23. data/license/gpl-2.0.txt +339 -0
  24. data/license/gpl.ja.txt +416 -0
  25. data/original-tests/00_Class.tests.rb +42 -0
  26. data/original-tests/05_Markdown.tests.rb +1530 -0
  27. data/original-tests/10_Bug.tests.rb +44 -0
  28. data/original-tests/15_Contrib.tests.rb +130 -0
  29. data/original-tests/bftestcase.rb +278 -0
  30. data/original-tests/data/antsugar.txt +34 -0
  31. data/original-tests/data/ml-announce.txt +17 -0
  32. data/original-tests/data/re-overflow.txt +67 -0
  33. data/original-tests/data/re-overflow2.txt +281 -0
  34. data/readme_en.txt +37 -0
  35. data/readme_ja.txt +33 -0
  36. data/spec/auto-link.rb +100 -0
  37. data/spec/code-block.rb +91 -0
  38. data/spec/dl.rb +182 -0
  39. data/spec/escape-char.rb +18 -0
  40. data/spec/footnote.rb +34 -0
  41. data/spec/header-id.rb +38 -0
  42. data/spec/lib/common.rb +103 -0
  43. data/spec/table.rb +70 -0
  44. data/spec/toc.rb +64 -0
  45. data/spec/warning.rb +61 -0
  46. metadata +99 -0
data/spec/auto-link.rb ADDED
@@ -0,0 +1,100 @@
1
+ require 'pathname'
2
+ require(Pathname.new(__FILE__).parent + 'lib/common.rb')
3
+
4
+
5
+ describe 'Auto Link:' do
6
+ before(:each) do
7
+ @html = BlueFeather.parse(@src)
8
+ @doc = Hpricot(@html)
9
+ end
10
+
11
+ describe 'Valid URL:' do
12
+
13
+ data = [
14
+ 'http://www.example.com/',
15
+ 'https://www.example.com/',
16
+ 'skype:example-id',
17
+ 'mailto:nobody@example.net',
18
+ ]
19
+
20
+ data.each do |url|
21
+ src = "<#{url}>"
22
+ describe src do
23
+ before(:all) do
24
+ @src = src
25
+ end
26
+
27
+ specify 'p > a' do
28
+ @doc.should have_elements(1, 'p')
29
+ @doc.should have_elements(1, 'p a')
30
+ end
31
+
32
+ specify 'text' do
33
+ @doc.at('a').inner_text.should == url
34
+ end
35
+
36
+ specify 'href' do
37
+ @doc.at('a')['href'].should == url
38
+ end
39
+
40
+ end
41
+ end
42
+ end
43
+
44
+ describe 'Invalid URL:' do
45
+
46
+ data = [
47
+ 'http//www.example.com/',
48
+ ]
49
+
50
+ data.each do |url|
51
+ src = "<#{url}>"
52
+ describe src do
53
+ before(:all) do
54
+ @src = src
55
+ end
56
+
57
+ specify 'no anchor' do
58
+ @doc.should have_element('p')
59
+ @doc.should_not have_element('p a')
60
+ end
61
+
62
+ end
63
+ end
64
+
65
+
66
+ end
67
+
68
+
69
+
70
+ describe 'Valid Address:' do
71
+
72
+ data = [
73
+ 'nobody.user@example.com',
74
+ 'nobody.user@example.com',
75
+ '.nobody..user.@example.com',
76
+ ]
77
+
78
+ data.each do |address|
79
+ src = "<#{address}>"
80
+ describe src do
81
+ before(:all) do
82
+ @src = src
83
+ end
84
+
85
+ specify 'overview' do
86
+ @doc.should have_elements(1, 'p')
87
+ @doc.should have_elements(1, 'p a')
88
+ end
89
+
90
+
91
+ end
92
+ end
93
+
94
+ end
95
+
96
+
97
+
98
+
99
+
100
+ end
@@ -0,0 +1,91 @@
1
+ require 'pathname'
2
+ require(Pathname.new(__FILE__).parent + 'lib/common.rb')
3
+
4
+
5
+ describe 'Normal Code Block:' do
6
+ before(:each) do
7
+ @bf = BlueFeather::Parser.new
8
+ @html = @bf.parse_text(@src)
9
+ @doc = Hpricot(@html)
10
+ end
11
+
12
+
13
+ describe '> ol:' do
14
+ before(:all) do
15
+ @src = " 1. item-1\n 2. item-2\n 3. item-3\n"
16
+ end
17
+
18
+ specify 'basic' do
19
+ @doc.should have_elements(1, 'pre code')
20
+ @doc.should_not have_element('ol')
21
+ end
22
+ end
23
+ end
24
+
25
+ describe 'Fenced Code Block:' do
26
+ before(:each) do
27
+ @bf = BlueFeather::Parser.new
28
+ @html = @bf.parse_text(@src)
29
+ @doc = Hpricot(@html)
30
+ end
31
+
32
+
33
+ describe 'Basic:' do
34
+ share_as :Examples do
35
+ specify 'overview' do
36
+ @doc.should have_elements(1, 'pre code')
37
+ @doc.should_not have_element('p')
38
+ end
39
+
40
+ specify 'body' do
41
+ @doc.at('pre code').inner_text.should == "Fenced Code\nBlock\n"
42
+ end
43
+ end
44
+
45
+ share_as :NegativeExamples do
46
+ specify 'overview' do
47
+ @doc.should_not have_elements(1, 'pre code')
48
+ @doc.should have_elements(1, 'p')
49
+ end
50
+ end
51
+
52
+
53
+ describe 'Standard:' do
54
+ include Examples
55
+ before(:all) do
56
+ @src = "~~~\nFenced Code\nBlock\n~~~"
57
+ end
58
+ end
59
+
60
+ describe 'Many Symbols:' do
61
+ include Examples
62
+ before(:all) do
63
+ @src = "~~~~~~\nFenced Code\nBlock\n~~~~~~"
64
+ end
65
+ end
66
+
67
+ describe 'Original Code Block:' do
68
+ include Examples
69
+ before(:all) do
70
+ @src = " Fenced Code\n Block"
71
+ end
72
+ end
73
+
74
+ describe 'Bad (wrong number of symbols):' do
75
+ include NegativeExamples
76
+ before(:all) do
77
+ @src = "~~~~~~\nFenced Code\nBlock\n~~~"
78
+ end
79
+ end
80
+
81
+ describe 'Bad (symbols is not on line-head.):' do
82
+ include NegativeExamples
83
+ before(:all) do
84
+ @src = " ~~~\nFenced Code\nBlock\n ~~~"
85
+ end
86
+ end
87
+
88
+
89
+ end
90
+
91
+ end
data/spec/dl.rb ADDED
@@ -0,0 +1,182 @@
1
+ require 'pathname'
2
+ require(Pathname.new(__FILE__).parent + 'lib/common.rb')
3
+
4
+
5
+ describe 'Definition List:' do
6
+ before(:each) do
7
+ @bf = BlueFeather::Parser.new
8
+ @html = @bf.parse_text(@src)
9
+ @doc = Hpricot(@html)
10
+ end
11
+
12
+ describe 'Basic:' do
13
+ describe 'most standard:'do
14
+ before(:all) do
15
+ @src = ("dt1\n:dd1\n\ndt2\n:dd2-\ndouble-line")
16
+ end
17
+
18
+ specify 'overview' do
19
+ @doc.should have_elements(1, 'dl')
20
+ @doc.should have_elements(2, 'dl dt')
21
+ @doc.should have_elements(2, 'dl dd')
22
+ end
23
+
24
+ specify 'text' do
25
+ @doc.search('dl dt')[0].inner_text.should == "dt1"
26
+ @doc.search('dl dt')[1].inner_text.should == "dt2"
27
+ @doc.search('dl dd')[0].inner_text.should == "dd1"
28
+ @doc.search('dl dd')[1].inner_text.should == "dd2-\ndouble-line"
29
+ end
30
+
31
+ end
32
+
33
+ describe 'double dt:'do
34
+ before(:all) do
35
+ @src = ("dt1\ndt2\n:dd")
36
+ end
37
+
38
+ specify 'overview' do
39
+ @doc.should have_elements(1, 'dl')
40
+ @doc.should have_elements(2, 'dl dt')
41
+ @doc.should have_elements(1, 'dl dd')
42
+ end
43
+
44
+ specify 'text' do
45
+ @doc.search('dl dt')[0].inner_text.should == 'dt1'
46
+ @doc.search('dl dt')[1].inner_text.should == 'dt2'
47
+ @doc.at('dl dd').inner_text.should == "dd"
48
+ end
49
+ end
50
+
51
+ describe 'double dd:'do
52
+ before(:all) do
53
+ @src = ("dt\n:dd1\n:dd2")
54
+ end
55
+
56
+ specify 'overview' do
57
+ @doc.should have_elements(1, 'dl')
58
+ @doc.should have_elements(1, 'dl dt')
59
+ @doc.should have_elements(2, 'dl dd')
60
+ end
61
+
62
+ specify 'text' do
63
+ @doc.search('dl dd')[0].inner_text.should == "dd1"
64
+ @doc.search('dl dd')[1].inner_text.should == "dd2"
65
+ @doc.at('dl dt').inner_text.should == 'dt'
66
+ end
67
+ end
68
+
69
+
70
+ end
71
+
72
+
73
+ describe '> code-block > ol:' do
74
+ before(:all) do
75
+ @src = <<-SRC
76
+ title
77
+
78
+ :
79
+
80
+ 1. olitem-1
81
+ 2. olitem-2
82
+ 3. olitem-3
83
+
84
+ SRC
85
+ end
86
+
87
+ specify 'overview' do
88
+ @doc.should have_elements(1, 'dl dt')
89
+ @doc.should have_elements(1, 'dl dd')
90
+ end
91
+
92
+ specify 'dt text' do
93
+ @doc.at('dt').inner_text.should == 'title'
94
+ end
95
+
96
+ specify 'ol in code-block' do
97
+ @doc.should have_element('dd pre code')
98
+
99
+ code = @doc / 'dd pre code'
100
+ code.inner_text.should =~ /\A1.+\n2.+\n3.+\n\z/
101
+ end
102
+
103
+ end
104
+
105
+ describe '> code-block > ol(with paragraphs):' do
106
+ before(:all) do
107
+ @src = <<-SRC
108
+ title
109
+
110
+ :paragraph1
111
+
112
+ 1. olitem-1
113
+ 2. olitem-2
114
+ 3. olitem-3
115
+
116
+ paragraph2
117
+
118
+ SRC
119
+ end
120
+
121
+ specify 'overview' do
122
+ @doc.should have_elements(1, 'dl dt')
123
+ @doc.should have_elements(1, 'dl dd')
124
+ @doc.should have_elements(2, 'dl dd p')
125
+ end
126
+
127
+ specify 'dt text' do
128
+ @doc.at('dt').inner_text.should == 'title'
129
+ end
130
+
131
+ specify 'ol in code-block' do
132
+ @doc.should have_element('dd pre code')
133
+
134
+ code = @doc / 'dd pre code'
135
+ code.inner_text.should =~ /\A1.+\n2.+\n3.+\n\z/
136
+ end
137
+
138
+ specify 'paragraphs' do
139
+ paragraphs = @doc / 'dl dd p'
140
+ paragraphs[0].inner_text.should == 'paragraph1'
141
+ paragraphs[1].inner_text.should == 'paragraph2'
142
+ end
143
+
144
+ end
145
+
146
+
147
+ describe 'blockquote > code-block > ol and paragraphs:' do
148
+ before(:all) do
149
+ @src = <<-SRC
150
+ >title
151
+ >
152
+ >:paragraph1
153
+ >
154
+ > 1. olitem-1
155
+ > 2. olitem-2
156
+ > 3. olitem-3
157
+ >
158
+ > paragraph2
159
+
160
+ SRC
161
+ end
162
+
163
+ specify 'overview' do
164
+ @doc.should have_elements(1, 'blockquote dl dt')
165
+ @doc.should have_elements(1, 'blockquote dl dd')
166
+ @doc.should have_elements(2, 'blockquote dl dd p')
167
+ end
168
+
169
+ specify 'dt text' do
170
+ @doc.at('blockquote dt').inner_text.should == 'title'
171
+ end
172
+
173
+ specify 'paragraphs' do
174
+ paragraphs = @doc / 'blockquote dl dd p'
175
+ paragraphs[0].inner_text.should == 'paragraph1'
176
+ paragraphs[1].inner_text.should == 'paragraph2'
177
+ end
178
+
179
+ end
180
+
181
+
182
+ end
@@ -0,0 +1,18 @@
1
+ require 'pathname'
2
+ require(Pathname.new(__FILE__).parent + 'lib/common.rb')
3
+
4
+
5
+ describe 'Escape Characters:' do
6
+ before(:each) do
7
+ @bf = BlueFeather::Parser.new
8
+ end
9
+
10
+ '\\`*_{}[]()#.!|:~'.each_char do |c|
11
+ specify "'#{c}'" do
12
+ @bf.parse_text("\\#{c}").should == "<p>#{c}</p>"
13
+ end
14
+ end
15
+
16
+
17
+
18
+ end
data/spec/footnote.rb ADDED
@@ -0,0 +1,34 @@
1
+ require 'pathname'
2
+ require(Pathname.new(__FILE__).parent + 'lib/common.rb')
3
+
4
+ describe 'Footnote:' do
5
+ before(:all) do
6
+ @bf = BlueFeather::Parser.new
7
+ end
8
+
9
+ describe 'simple:' do
10
+ before(:all) do
11
+ @html = @bf.parse_text("[^testid]\n\n[^testid]: none")
12
+ @doc = Hpricot(@html)
13
+ end
14
+
15
+ specify "reference a" do
16
+ a = @doc.at('p sup a')
17
+ a['href'].should == '#footnote:testid'
18
+ a.inner_html.should == '[1]'
19
+ end
20
+
21
+ specify "reference id" do
22
+ @doc.at('p sup')['id'].should == 'footnote-ref:testid'
23
+ end
24
+
25
+ specify "footnotes" do
26
+ div = @doc.at('div.footnotes')
27
+ div.should have_element('hr')
28
+ div.at('ol li')['id'].should == 'footnote:testid'
29
+ div.at('ol li p a')['href'].should == '#footnote-ref:testid'
30
+ end
31
+ end
32
+
33
+
34
+ end
data/spec/header-id.rb ADDED
@@ -0,0 +1,38 @@
1
+ require 'pathname'
2
+ require(Pathname.new(__FILE__).parent + 'lib/common.rb')
3
+
4
+
5
+ describe 'Header ID:' do
6
+ before(:each) do
7
+ @bf = BlueFeather::Parser.new
8
+ @html = @bf.parse_text(@src)
9
+ @doc = Hpricot(@html)
10
+ end
11
+
12
+
13
+ describe 'basic:' do
14
+ before(:all) do
15
+ @src = '## h2 ## {#test-id}'
16
+ end
17
+
18
+ specify 'correct id' do
19
+ @doc.should have_element('h2#test-id')
20
+ end
21
+
22
+ end
23
+
24
+
25
+ describe 'use span transform format:' do
26
+ before(:all) do
27
+ @src = '## h2 ## {#the_test_id}'
28
+ end
29
+
30
+ specify 'correct id' do
31
+ @doc.should have_element('h2#the_test_id')
32
+ end
33
+
34
+ end
35
+
36
+
37
+
38
+ end