wikicloth 0.7.1 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.textile +3 -3
- data/Rakefile +19 -11
- data/lang/de.yml +24 -0
- data/lang/en.yml +35 -0
- data/lib/wikicloth.rb +47 -26
- data/lib/wikicloth/core_ext.rb +4 -0
- data/lib/wikicloth/extension.rb +60 -0
- data/lib/wikicloth/extensions/lua.rb +82 -0
- data/lib/wikicloth/extensions/lua/COPYING +18 -0
- data/lib/wikicloth/extensions/lua/luawrapper.lua +245 -0
- data/lib/wikicloth/extensions/math.rb +39 -0
- data/lib/wikicloth/extensions/poem.rb +15 -0
- data/lib/wikicloth/extensions/references.rb +48 -0
- data/lib/wikicloth/extensions/source.rb +46 -0
- data/lib/wikicloth/i18n.rb +108 -0
- data/lib/wikicloth/namespaces.rb +62 -0
- data/lib/wikicloth/parser.rb +21 -15
- data/lib/wikicloth/section.rb +1 -5
- data/lib/wikicloth/version.rb +1 -1
- data/lib/wikicloth/wiki_buffer.rb +151 -39
- data/lib/wikicloth/wiki_buffer/html_element.rb +24 -59
- data/lib/wikicloth/wiki_buffer/link.rb +3 -2
- data/lib/wikicloth/wiki_buffer/table.rb +2 -2
- data/lib/wikicloth/wiki_buffer/var.rb +80 -28
- data/lib/wikicloth/wiki_link_handler.rb +22 -29
- data/sample_documents/lua.wiki +58 -0
- data/test/locales.yml +264 -0
- data/test/test_helper.rb +1 -0
- data/test/wiki_cloth_test.rb +142 -27
- data/wikicloth.gemspec +2 -1
- metadata +34 -8
- data/lib/wikicloth/lexer.rb +0 -105
- data/lib/wikicloth/token.rb +0 -41
@@ -0,0 +1,58 @@
|
|
1
|
+
The <code><lua></code> tag allows you to embed Lua code in your templates and wiki documents.
|
2
|
+
|
3
|
+
<source lang="lua">
|
4
|
+
<lua where="wall">
|
5
|
+
function bottle(x)
|
6
|
+
if x > 1 then
|
7
|
+
return x .. " bottles of beer"
|
8
|
+
elseif x == 1 then
|
9
|
+
return "One bottle of beer"
|
10
|
+
else
|
11
|
+
return "No more bottles of beer"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
function count(x)
|
16
|
+
output = "<pre>"
|
17
|
+
for beer = x, 1, -1 do
|
18
|
+
output = output .. bottle(beer) .. " on the " .. where .. ",\n"
|
19
|
+
output = output .. bottle(beer) .. ",\n"
|
20
|
+
output = output .. "Take one down, pass it around,\n"
|
21
|
+
output = output .. bottle(beer-1) .. " on the " .. where .. ".\n"
|
22
|
+
output = output .. "\n\n"
|
23
|
+
end
|
24
|
+
return output .. "</pre>"
|
25
|
+
end
|
26
|
+
</lua>
|
27
|
+
|
28
|
+
==99 Bottles of Beer==
|
29
|
+
{{#luaexpr:count(99)}}
|
30
|
+
</source>
|
31
|
+
|
32
|
+
==In Action==
|
33
|
+
<lua where="floor">
|
34
|
+
function bottle(x)
|
35
|
+
if x > 1 then
|
36
|
+
return x .. " bottles of beer"
|
37
|
+
elseif x == 1 then
|
38
|
+
return "One bottle of beer"
|
39
|
+
else
|
40
|
+
return "No more bottles of beer"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
function count(x)
|
45
|
+
output = "<pre>"
|
46
|
+
for beer = x, 1, -1 do
|
47
|
+
output = output .. bottle(beer) .. " on the " .. where .. ",\n"
|
48
|
+
output = output .. bottle(beer) .. ",\n"
|
49
|
+
output = output .. "Take one down, pass it around,\n"
|
50
|
+
output = output .. bottle(beer-1) .. " on the " .. where .. ".\n"
|
51
|
+
output = output .. "\n\n"
|
52
|
+
end
|
53
|
+
return output .. "</pre>"
|
54
|
+
end
|
55
|
+
</lua>
|
56
|
+
|
57
|
+
==99 Bottles of Beer==
|
58
|
+
{{#luaexpr:count(99)}}
|
data/test/locales.yml
ADDED
@@ -0,0 +1,264 @@
|
|
1
|
+
:af:
|
2
|
+
hello: "world"
|
3
|
+
:am:
|
4
|
+
hello: "world"
|
5
|
+
:ang:
|
6
|
+
hello: "world"
|
7
|
+
:ar:
|
8
|
+
hello: "world"
|
9
|
+
:arc:
|
10
|
+
hello: "world"
|
11
|
+
:ast:
|
12
|
+
hello: "world"
|
13
|
+
:az:
|
14
|
+
hello: "world"
|
15
|
+
:bn:
|
16
|
+
hello: "world"
|
17
|
+
:zh_min_nan:
|
18
|
+
hello: "world"
|
19
|
+
:ba:
|
20
|
+
hello: "world"
|
21
|
+
:be:
|
22
|
+
hello: "world"
|
23
|
+
:be_x_old:
|
24
|
+
hello: "world"
|
25
|
+
:bar:
|
26
|
+
hello: "world"
|
27
|
+
:bs:
|
28
|
+
hello: "world"
|
29
|
+
:br:
|
30
|
+
hello: "world"
|
31
|
+
:bg:
|
32
|
+
hello: "world"
|
33
|
+
:ca:
|
34
|
+
hello: "world"
|
35
|
+
:ceb:
|
36
|
+
hello: "world"
|
37
|
+
:cs:
|
38
|
+
hello: "world"
|
39
|
+
:co:
|
40
|
+
hello: "world"
|
41
|
+
:cy:
|
42
|
+
hello: "world"
|
43
|
+
:da:
|
44
|
+
hello: "world"
|
45
|
+
:de:
|
46
|
+
hello: "world"
|
47
|
+
:dv:
|
48
|
+
hello: "world"
|
49
|
+
:et:
|
50
|
+
hello: "world"
|
51
|
+
:el:
|
52
|
+
hello: "world"
|
53
|
+
:es:
|
54
|
+
hello: "world"
|
55
|
+
:eo:
|
56
|
+
hello: "world"
|
57
|
+
:eu:
|
58
|
+
hello: "world"
|
59
|
+
:fa:
|
60
|
+
hello: "world"
|
61
|
+
:fo:
|
62
|
+
hello: "world"
|
63
|
+
:fr:
|
64
|
+
hello: "world"
|
65
|
+
:fy:
|
66
|
+
hello: "world"
|
67
|
+
:ga:
|
68
|
+
hello: "world"
|
69
|
+
:gd:
|
70
|
+
hello: "world"
|
71
|
+
:gl:
|
72
|
+
hello: "world"
|
73
|
+
:gan:
|
74
|
+
hello: "world"
|
75
|
+
:ko:
|
76
|
+
hello: "world"
|
77
|
+
:hy:
|
78
|
+
hello: "world"
|
79
|
+
:hi:
|
80
|
+
hello: "world"
|
81
|
+
:hr:
|
82
|
+
hello: "world"
|
83
|
+
:io:
|
84
|
+
hello: "world"
|
85
|
+
:id:
|
86
|
+
hello: "world"
|
87
|
+
:is:
|
88
|
+
hello: "world"
|
89
|
+
:it:
|
90
|
+
hello: "world"
|
91
|
+
:he:
|
92
|
+
hello: "world"
|
93
|
+
:jv:
|
94
|
+
hello: "world"
|
95
|
+
:kn:
|
96
|
+
hello: "world"
|
97
|
+
:pam:
|
98
|
+
hello: "world"
|
99
|
+
:ka:
|
100
|
+
hello: "world"
|
101
|
+
:sw:
|
102
|
+
hello: "world"
|
103
|
+
:ku:
|
104
|
+
hello: "world"
|
105
|
+
:la:
|
106
|
+
hello: "world"
|
107
|
+
:lv:
|
108
|
+
hello: "world"
|
109
|
+
:lb:
|
110
|
+
hello: "world"
|
111
|
+
:lt:
|
112
|
+
hello: "world"
|
113
|
+
:hu:
|
114
|
+
hello: "world"
|
115
|
+
:mk:
|
116
|
+
hello: "world"
|
117
|
+
:mg:
|
118
|
+
hello: "world"
|
119
|
+
:ml:
|
120
|
+
hello: "world"
|
121
|
+
:mr:
|
122
|
+
hello: "world"
|
123
|
+
:arz:
|
124
|
+
hello: "world"
|
125
|
+
:ms:
|
126
|
+
hello: "world"
|
127
|
+
:nah:
|
128
|
+
hello: "world"
|
129
|
+
:nl:
|
130
|
+
hello: "world"
|
131
|
+
:ja:
|
132
|
+
hello: "world"
|
133
|
+
:no:
|
134
|
+
hello: "world"
|
135
|
+
:nn:
|
136
|
+
hello: "world"
|
137
|
+
:oc:
|
138
|
+
hello: "world"
|
139
|
+
:uz:
|
140
|
+
hello: "world"
|
141
|
+
:pap:
|
142
|
+
hello: "world"
|
143
|
+
:nds:
|
144
|
+
hello: "world"
|
145
|
+
:pl:
|
146
|
+
hello: "world"
|
147
|
+
:pt:
|
148
|
+
hello: "world"
|
149
|
+
:ksh:
|
150
|
+
hello: "world"
|
151
|
+
:ro:
|
152
|
+
hello: "world"
|
153
|
+
:qu:
|
154
|
+
hello: "world"
|
155
|
+
:ru:
|
156
|
+
hello: "world"
|
157
|
+
:sa:
|
158
|
+
hello: "world"
|
159
|
+
:sco:
|
160
|
+
hello: "world"
|
161
|
+
:sq:
|
162
|
+
hello: "world"
|
163
|
+
:scn:
|
164
|
+
hello: "world"
|
165
|
+
:simple:
|
166
|
+
hello: "world"
|
167
|
+
:sk:
|
168
|
+
hello: "world"
|
169
|
+
:sl:
|
170
|
+
hello: "world"
|
171
|
+
:sr:
|
172
|
+
hello: "world"
|
173
|
+
:sh:
|
174
|
+
hello: "world"
|
175
|
+
:fi:
|
176
|
+
hello: "world"
|
177
|
+
:sv:
|
178
|
+
hello: "world"
|
179
|
+
:tl:
|
180
|
+
hello: "world"
|
181
|
+
:ta:
|
182
|
+
hello: "world"
|
183
|
+
:th:
|
184
|
+
hello: "world"
|
185
|
+
:tg:
|
186
|
+
hello: "world"
|
187
|
+
:tr:
|
188
|
+
hello: "world"
|
189
|
+
:uk:
|
190
|
+
hello: "world"
|
191
|
+
:ur:
|
192
|
+
hello: "world"
|
193
|
+
:vi:
|
194
|
+
hello: "world"
|
195
|
+
:zh_classical:
|
196
|
+
hello: "world"
|
197
|
+
:yi:
|
198
|
+
hello: "world"
|
199
|
+
:bat_smg:
|
200
|
+
hello: "world"
|
201
|
+
:zh:
|
202
|
+
hello: "world"
|
203
|
+
:lo:
|
204
|
+
hello: "world"
|
205
|
+
:en:
|
206
|
+
hello: "world"
|
207
|
+
:gn:
|
208
|
+
hello: "world"
|
209
|
+
:map_bms:
|
210
|
+
hello: "world"
|
211
|
+
:pdc:
|
212
|
+
hello: "world"
|
213
|
+
:eml:
|
214
|
+
hello: "world"
|
215
|
+
:ki:
|
216
|
+
hello: "world"
|
217
|
+
:hak:
|
218
|
+
hello: "world"
|
219
|
+
:ia:
|
220
|
+
hello: "world"
|
221
|
+
:ky:
|
222
|
+
hello: "world"
|
223
|
+
:lad:
|
224
|
+
hello: "world"
|
225
|
+
:nds_nl:
|
226
|
+
hello: "world"
|
227
|
+
:ne:
|
228
|
+
hello: "world"
|
229
|
+
:nrm:
|
230
|
+
hello: "world"
|
231
|
+
:nov:
|
232
|
+
hello: "world"
|
233
|
+
:sm:
|
234
|
+
hello: "world"
|
235
|
+
:si:
|
236
|
+
hello: "world"
|
237
|
+
:su:
|
238
|
+
hello: "world"
|
239
|
+
:kab:
|
240
|
+
hello: "world"
|
241
|
+
:te:
|
242
|
+
hello: "world"
|
243
|
+
:vec:
|
244
|
+
hello: "world"
|
245
|
+
:fiu_vro:
|
246
|
+
hello: "world"
|
247
|
+
:wa:
|
248
|
+
hello: "world"
|
249
|
+
:war:
|
250
|
+
hello: "world"
|
251
|
+
:wuu:
|
252
|
+
hello: "world"
|
253
|
+
:zh_yue:
|
254
|
+
hello: "world"
|
255
|
+
:diq:
|
256
|
+
hello: "world"
|
257
|
+
:als:
|
258
|
+
hello: "world"
|
259
|
+
:bjn:
|
260
|
+
hello: "world"
|
261
|
+
:ce:
|
262
|
+
hello: "world"
|
263
|
+
:ht:
|
264
|
+
hello: "world"
|
data/test/test_helper.rb
CHANGED
data/test/wiki_cloth_test.rb
CHANGED
@@ -35,6 +35,135 @@ end
|
|
35
35
|
|
36
36
|
class WikiClothTest < ActiveSupport::TestCase
|
37
37
|
|
38
|
+
test "nested bold/italic markup" do
|
39
|
+
wiki = WikiParser.new(:data => "''Mars goes around the Sun once in a Martian '''year''', or 1.88 Earth '''years'''.''")
|
40
|
+
data = wiki.to_html
|
41
|
+
assert data.include?("<i>Mars goes around the Sun once in a Martian <b>year</b>, or 1.88 Earth <b>years</b>.</i>")
|
42
|
+
end
|
43
|
+
|
44
|
+
test "google charts math tag" do
|
45
|
+
wiki = WikiParser.new(:data => "<math>1+1=2</math>", :math_formatter => :google)
|
46
|
+
data = wiki.to_html
|
47
|
+
assert data.include?("https://chart.googleapis.com/chart")
|
48
|
+
end
|
49
|
+
|
50
|
+
test "uc lc ucfirst lcfirst" do
|
51
|
+
wiki = WikiParser.new(:data => "{{uc:hello}} -- {{lc:BOO}} -- {{ucfirst:john}} -- {{lcfirst:TEST}}")
|
52
|
+
data = wiki.to_html
|
53
|
+
assert data =~ /HELLO/
|
54
|
+
assert data !~ /hello/
|
55
|
+
assert data =~ /boo/
|
56
|
+
assert data !~ /BOO/
|
57
|
+
assert data =~ /John/
|
58
|
+
assert data !~ /john/
|
59
|
+
assert data =~ /tEST/
|
60
|
+
assert data !~ /TEST/
|
61
|
+
end
|
62
|
+
|
63
|
+
test "plural parser function" do
|
64
|
+
wiki = WikiParser.new(:data => "{{plural:1|is|are}}")
|
65
|
+
data = wiki.to_html
|
66
|
+
assert data =~ /is/
|
67
|
+
|
68
|
+
wiki = WikiParser.new(:data => "{{plural:2|is|are}}")
|
69
|
+
data = wiki.to_html
|
70
|
+
assert data =~ /are/
|
71
|
+
|
72
|
+
wiki = WikiParser.new(:data => "{{plural:14/2|is|are}}")
|
73
|
+
data = wiki.to_html
|
74
|
+
assert data =~ /are/
|
75
|
+
|
76
|
+
wiki = WikiParser.new(:data => "{{plural:14/2-6|is|are}}")
|
77
|
+
data = wiki.to_html
|
78
|
+
assert data =~ /is/
|
79
|
+
end
|
80
|
+
|
81
|
+
test "parser functions on multiple lines" do
|
82
|
+
wiki = WikiParser.new(:data => "{{
|
83
|
+
#if:
|
84
|
+
|hello world
|
85
|
+
|{{
|
86
|
+
#if:test
|
87
|
+
|boo
|
88
|
+
|
|
89
|
+
}}
|
90
|
+
}}")
|
91
|
+
data = wiki.to_html
|
92
|
+
assert data =~ /boo/
|
93
|
+
end
|
94
|
+
|
95
|
+
test "wiki variables" do
|
96
|
+
wiki = WikiParser.new(:data => "{{PAGENAME}}", :params => { "PAGENAME" => "Main_Page" })
|
97
|
+
data = wiki.to_html
|
98
|
+
assert data =~ /Main_Page/
|
99
|
+
end
|
100
|
+
|
101
|
+
test "references" do
|
102
|
+
wiki = WikiParser.new(:data => "hello <ref name=\"test\">This is a reference</ref> world <ref name=\"test\"/>")
|
103
|
+
data = wiki.to_html
|
104
|
+
assert data !~ /This is a reference/
|
105
|
+
assert data =~ /sup/
|
106
|
+
assert data =~ /cite_ref-test_1-0/
|
107
|
+
assert data =~ /cite_ref-test_1-1/
|
108
|
+
|
109
|
+
wiki = WikiParser.new(:data => "hello <ref name=\"test\">This is a reference</ref> world <ref name=\"test\"/>\n==References==\n<references/>")
|
110
|
+
data = wiki.to_html
|
111
|
+
assert data =~ /This is a reference/
|
112
|
+
|
113
|
+
# reference groups
|
114
|
+
wiki = WikiParser.new(:data => "hello <ref>one</ref><ref>two</ref><ref group=\"other\">three</ref><ref>four</ref>\n==References==\n<references/>")
|
115
|
+
data = wiki.to_html
|
116
|
+
assert data =~ /one/
|
117
|
+
assert data =~ /two/
|
118
|
+
assert data !~ /three/
|
119
|
+
assert data =~ /four/
|
120
|
+
|
121
|
+
wiki = WikiParser.new(:data => "hello <ref>one</ref><ref>two</ref><ref group=\"other\">three</ref><ref>four</ref>\n==References==\n<references group=\"other\"/>")
|
122
|
+
data = wiki.to_html
|
123
|
+
assert data !~ /one/
|
124
|
+
assert data !~ /two/
|
125
|
+
assert data =~ /three/
|
126
|
+
assert data !~ /four/
|
127
|
+
end
|
128
|
+
|
129
|
+
test "localised language names" do
|
130
|
+
wiki = WikiParser.new(:data => "{{#language:de}}", :locale => :de)
|
131
|
+
assert wiki.to_html =~ /Deutsch/
|
132
|
+
|
133
|
+
wiki = WikiParser.new(:data => "{{#language:de}}", :locale => :en)
|
134
|
+
assert wiki.to_html =~ /German/
|
135
|
+
end
|
136
|
+
|
137
|
+
test "localised behavior switches" do
|
138
|
+
wiki = WikiParser.new(:data => "==test==", :locale => :de)
|
139
|
+
assert wiki.to_html =~ /Bearbeiten/
|
140
|
+
wiki = WikiParser.new(:data => "__ABSCHNITTE_NICHT_BEARBEITEN__\n==test==")
|
141
|
+
data = wiki.to_html
|
142
|
+
assert data =~ /edit/
|
143
|
+
wiki = WikiParser.new(:data => "__ABSCHNITTE_NICHT_BEARBEITEN__\n==test==", :locale => :de)
|
144
|
+
data = wiki.to_html
|
145
|
+
assert data !~ /ABSCHNITTE_NICHT_BEARBEITEN/
|
146
|
+
assert data !~ /Bearbeiten/
|
147
|
+
end
|
148
|
+
|
149
|
+
test "namespace localisation" do
|
150
|
+
assert WikiCloth::Parser.localise_ns("File") == "File"
|
151
|
+
assert WikiCloth::Parser.localise_ns("Image") == "File"
|
152
|
+
assert WikiCloth::Parser.localise_ns("Datei") == "File"
|
153
|
+
assert WikiCloth::Parser.localise_ns("File",:de) == "Datei"
|
154
|
+
wiki = WikiParser.new(:data => "{{ns:File}}", :locale => :de)
|
155
|
+
assert wiki.to_html =~ /Datei/
|
156
|
+
|
157
|
+
wiki = WikiParser.new(:data => "{{ns:Image}}", :locale => :de)
|
158
|
+
assert wiki.to_html =~ /Datei/
|
159
|
+
end
|
160
|
+
|
161
|
+
test "headings inside of pre tags" do
|
162
|
+
wiki = WikiParser.new(:data => "<pre>\n\n== heading ==\n\n</pre>")
|
163
|
+
data = wiki.to_html
|
164
|
+
assert data !~ /h2/
|
165
|
+
end
|
166
|
+
|
38
167
|
test "math tag" do
|
39
168
|
wiki = WikiParser.new(:data => "<math>1-\frac{k}{|E(G_j)|}</math>")
|
40
169
|
begin
|
@@ -50,7 +179,7 @@ class WikiClothTest < ActiveSupport::TestCase
|
|
50
179
|
data = wiki.to_html
|
51
180
|
assert wiki.external_links.size == 38
|
52
181
|
assert wiki.references.size == 76
|
53
|
-
assert wiki.internal_links.size == 322
|
182
|
+
assert wiki.internal_links.size == 432 #322
|
54
183
|
assert wiki.categories.size == 27
|
55
184
|
assert wiki.languages.size == 101
|
56
185
|
end
|
@@ -181,6 +310,12 @@ EOS
|
|
181
310
|
assert data =~ /busted/
|
182
311
|
end
|
183
312
|
|
313
|
+
test "nested lists" do
|
314
|
+
wiki = WikiParser.new(:data => "# one\n#* eee\n#* eee\n# two\n# three")
|
315
|
+
data = wiki.to_html
|
316
|
+
assert data.include?("<ol><li>one<ul><li>eee</li><li>eee</li></ul></li><li>two</li><li>three</li></ol>")
|
317
|
+
end
|
318
|
+
|
184
319
|
test "lists" do
|
185
320
|
wiki = WikiParser.new(:data => "* item 1\n* item 2\n* item 3\n")
|
186
321
|
data = wiki.to_html
|
@@ -208,7 +343,7 @@ EOS
|
|
208
343
|
data = wiki.to_html
|
209
344
|
assert data =~ /<i>testing<\/i>/
|
210
345
|
assert data =~ /<b>123<\/b>/
|
211
|
-
assert data =~ /<b
|
346
|
+
assert data =~ /<i><b>echo<\/b><\/i>/
|
212
347
|
end
|
213
348
|
|
214
349
|
test "sanitize html" do
|
@@ -228,18 +363,10 @@ EOS
|
|
228
363
|
test "disable edit stuff" do
|
229
364
|
wiki = WikiParser.new(:data => "= Hallo =")
|
230
365
|
data = wiki.to_html
|
231
|
-
|
232
|
-
assert_equal data, "\n<p><h1><span class=\"editsection\">[<a href=\"?section=Hallo\" title=\"Edit section: Hallo\">edit</a>]</span> <span class=\"mw-headline\" id=\"Hallo\"><a name=\"Hallo\">Hallo</a></span></h1></p>"
|
233
|
-
else
|
234
|
-
assert_equal data, "\n<p><h1><span class=\"editsection\">[<a href=\"?section=Hallo\" title=\"Edit section: Hallo\">edit</a>]</span> <span id=\"Hallo\" class=\"mw-headline\"><a name=\"Hallo\">Hallo</a></span></h1></p>"
|
235
|
-
end
|
366
|
+
assert data =~ /editsection/
|
236
367
|
|
237
368
|
data = wiki.to_html(:noedit => true)
|
238
|
-
|
239
|
-
assert_equal data, "\n<p><h1><span class=\"mw-headline\" id=\"Hallo\"><a name=\"Hallo\">Hallo</a></span></h1></p>"
|
240
|
-
else
|
241
|
-
assert_equal data, "\n<p><h1><span id=\"Hallo\" class=\"mw-headline\"><a name=\"Hallo\">Hallo</a></span></h1></p>"
|
242
|
-
end
|
369
|
+
assert data !~ /editsection/
|
243
370
|
end
|
244
371
|
|
245
372
|
test "render toc" do
|
@@ -269,11 +396,7 @@ EOS
|
|
269
396
|
test "empty item in toc" do
|
270
397
|
wiki = WikiCloth::WikiCloth.new({:data => "__TOC__\n=A="})
|
271
398
|
data = wiki.render
|
272
|
-
|
273
|
-
assert_equal data, "\n<p><table id=\"toc\" class=\"toc\" summary=\"Contents\"><tr><td><div style=\"font-weight:bold\">Table of Contents</div><ul></li><li><a href=\"#A\">A</a></li></ul></td></tr></table>\n<h1><span class=\"editsection\">[<a href=\"?section=A\" title=\"Edit section: A\">edit</a>]</span> <span class=\"mw-headline\" id=\"A\"><a name=\"A\">A</a></span></h1></p>"
|
274
|
-
else
|
275
|
-
assert_equal data, "\n<p><table id=\"toc\" class=\"toc\" summary=\"Contents\"><tr><td><div style=\"font-weight:bold\">Table of Contents</div><ul></li><li><a href=\"#A\">A</a></li></ul></td></tr></table>\n<h1><span class=\"editsection\">[<a href=\"?section=A\" title=\"Edit section: A\">edit</a>]</span> <span id=\"A\" class=\"mw-headline\"><a name=\"A\">A</a></span></h1></p>"
|
276
|
-
end
|
399
|
+
assert data.include?("<table id=\"toc\" class=\"toc\" summary=\"Contents\"><tr><td><div style=\"font-weight:bold\">Table of Contents</div><ul></li><li><a href=\"#A\">A</a></li></ul></td></tr></table>")
|
277
400
|
end
|
278
401
|
|
279
402
|
test "pre at beginning" do
|
@@ -285,20 +408,12 @@ EOS
|
|
285
408
|
test "toc declared as list" do
|
286
409
|
wiki = WikiCloth::WikiCloth.new({:data => "__TOC__\n=A=\n==B==\n===C==="})
|
287
410
|
data = wiki.render
|
288
|
-
|
289
|
-
assert_equal data, "\n<p><table id=\"toc\" class=\"toc\" summary=\"Contents\"><tr><td><div style=\"font-weight:bold\">Table of Contents</div><ul></li><li><a href=\"#A\">A</a><ul><li><a href=\"#B\">B</a><ul><li><a href=\"#C\">C</a></li></ul></ul></ul></td></tr></table>\n<h1><span class=\"editsection\">[<a href=\"?section=A\" title=\"Edit section: A\">edit</a>]</span> <span class=\"mw-headline\" id=\"A\"><a name=\"A\">A</a></span></h1>\n<h2><span class=\"editsection\">[<a href=\"?section=B\" title=\"Edit section: B\">edit</a>]</span> <span class=\"mw-headline\" id=\"B\"><a name=\"B\">B</a></span></h2>\n<h3><span class=\"editsection\">[<a href=\"?section=C\" title=\"Edit section: C\">edit</a>]</span> <span class=\"mw-headline\" id=\"C\"><a name=\"C\">C</a></span></h3></p>"
|
290
|
-
else
|
291
|
-
assert_equal data, "\n<p><table id=\"toc\" class=\"toc\" summary=\"Contents\"><tr><td><div style=\"font-weight:bold\">Table of Contents</div><ul></li><li><a href=\"#A\">A</a><ul><li><a href=\"#B\">B</a><ul><li><a href=\"#C\">C</a></li></ul></ul></ul></td></tr></table>\n<h1><span class=\"editsection\">[<a href=\"?section=A\" title=\"Edit section: A\">edit</a>]</span> <span id=\"A\" class=\"mw-headline\"><a name=\"A\">A</a></span></h1>\n<h2><span class=\"editsection\">[<a href=\"?section=B\" title=\"Edit section: B\">edit</a>]</span> <span id=\"B\" class=\"mw-headline\"><a name=\"B\">B</a></span></h2>\n<h3><span class=\"editsection\">[<a href=\"?section=C\" title=\"Edit section: C\">edit</a>]</span> <span id=\"C\" class=\"mw-headline\"><a name=\"C\">C</a></span></h3></p>"
|
292
|
-
end
|
411
|
+
assert data.include?("<table id=\"toc\" class=\"toc\" summary=\"Contents\"><tr><td><div style=\"font-weight:bold\">Table of Contents</div><ul></li><li><a href=\"#A\">A</a><ul><li><a href=\"#B\">B</a><ul><li><a href=\"#C\">C</a></li></ul></ul></ul></td></tr></table>")
|
293
412
|
end
|
294
413
|
|
295
414
|
test "toc numbered" do
|
296
415
|
wiki = WikiCloth::WikiCloth.new({:data => "=A=\n=B=\n==C==\n==D==\n===E===\n===F===\n====G====\n====H====\n==I==\n=J=\n=K=\n===L===\n===M===\n====N====\n====O===="})
|
297
416
|
data = wiki.render(:noedit => true, :toc_numbered => true)
|
298
|
-
|
299
|
-
assert_equal data, "\n<p><table id=\"toc\" class=\"toc\" summary=\"Contents\"><tr><td><div style=\"font-weight:bold\">Table of Contents</div><ul></li><li><a href=\"#A\">1 A</a></li><li><a href=\"#B\">2 B</a><ul><li><a href=\"#C\">2.1 C</a></li><li><a href=\"#D\">2.2 D</a><ul><li><a href=\"#E\">2.2.1 E</a></li><li><a href=\"#F\">2.2.2 F</a><ul><li><a href=\"#G\">2.2.2.1 G</a></li><li><a href=\"#H\">2.2.2.2 H</a></li></ul></ul><li><a href=\"#I\">2.3 I</a></li></ul><li><a href=\"#J\">3 J</a></li><li><a href=\"#K\">4 K</a><ul><ul><li><a href=\"#L\">4.1 L</a></li><li><a href=\"#M\">4.2 M</a><ul><li><a href=\"#N\">4.2.1 N</a></li><li><a href=\"#O\">4.2.2 O</a></li></ul></ul></ul></ul></td></tr></table><h1><span class=\"mw-headline\" id=\"A\"><a name=\"A\">A</a></span></h1>\n<h1><span class=\"mw-headline\" id=\"B\"><a name=\"B\">B</a></span></h1>\n<h2><span class=\"mw-headline\" id=\"C\"><a name=\"C\">C</a></span></h2>\n<h2><span class=\"mw-headline\" id=\"D\"><a name=\"D\">D</a></span></h2>\n<h3><span class=\"mw-headline\" id=\"E\"><a name=\"E\">E</a></span></h3>\n<h3><span class=\"mw-headline\" id=\"F\"><a name=\"F\">F</a></span></h3>\n<h4><span class=\"mw-headline\" id=\"G\"><a name=\"G\">G</a></span></h4>\n<h4><span class=\"mw-headline\" id=\"H\"><a name=\"H\">H</a></span></h4>\n<h2><span class=\"mw-headline\" id=\"I\"><a name=\"I\">I</a></span></h2>\n<h1><span class=\"mw-headline\" id=\"J\"><a name=\"J\">J</a></span></h1>\n<h1><span class=\"mw-headline\" id=\"K\"><a name=\"K\">K</a></span></h1>\n<h3><span class=\"mw-headline\" id=\"L\"><a name=\"L\">L</a></span></h3>\n<h3><span class=\"mw-headline\" id=\"M\"><a name=\"M\">M</a></span></h3>\n<h4><span class=\"mw-headline\" id=\"N\"><a name=\"N\">N</a></span></h4>\n<h4><span class=\"mw-headline\" id=\"O\"><a name=\"O\">O</a></span></h4></p>"
|
300
|
-
else
|
301
|
-
assert_equal data, "\n<p><table id=\"toc\" class=\"toc\" summary=\"Contents\"><tr><td><div style=\"font-weight:bold\">Table of Contents</div><ul></li><li><a href=\"#A\">1 A</a></li><li><a href=\"#B\">2 B</a><ul><li><a href=\"#C\">2.1 C</a></li><li><a href=\"#D\">2.2 D</a><ul><li><a href=\"#E\">2.2.1 E</a></li><li><a href=\"#F\">2.2.2 F</a><ul><li><a href=\"#G\">2.2.2.1 G</a></li><li><a href=\"#H\">2.2.2.2 H</a></li></ul></ul><li><a href=\"#I\">2.3 I</a></li></ul><li><a href=\"#J\">3 J</a></li><li><a href=\"#K\">4 K</a><ul><ul><li><a href=\"#L\">4.1 L</a></li><li><a href=\"#M\">4.2 M</a><ul><li><a href=\"#N\">4.2.1 N</a></li><li><a href=\"#O\">4.2.2 O</a></li></ul></ul></ul></ul></td></tr></table><h1><span id=\"A\" class=\"mw-headline\"><a name=\"A\">A</a></span></h1>\n<h1><span id=\"B\" class=\"mw-headline\"><a name=\"B\">B</a></span></h1>\n<h2><span id=\"C\" class=\"mw-headline\"><a name=\"C\">C</a></span></h2>\n<h2><span id=\"D\" class=\"mw-headline\"><a name=\"D\">D</a></span></h2>\n<h3><span id=\"E\" class=\"mw-headline\"><a name=\"E\">E</a></span></h3>\n<h3><span id=\"F\" class=\"mw-headline\"><a name=\"F\">F</a></span></h3>\n<h4><span id=\"G\" class=\"mw-headline\"><a name=\"G\">G</a></span></h4>\n<h4><span id=\"H\" class=\"mw-headline\"><a name=\"H\">H</a></span></h4>\n<h2><span id=\"I\" class=\"mw-headline\"><a name=\"I\">I</a></span></h2>\n<h1><span id=\"J\" class=\"mw-headline\"><a name=\"J\">J</a></span></h1>\n<h1><span id=\"K\" class=\"mw-headline\"><a name=\"K\">K</a></span></h1>\n<h3><span id=\"L\" class=\"mw-headline\"><a name=\"L\">L</a></span></h3>\n<h3><span id=\"M\" class=\"mw-headline\"><a name=\"M\">M</a></span></h3>\n<h4><span id=\"N\" class=\"mw-headline\"><a name=\"N\">N</a></span></h4>\n<h4><span id=\"O\" class=\"mw-headline\"><a name=\"O\">O</a></span></h4></p>"
|
302
|
-
end
|
417
|
+
assert data.include?("<table id=\"toc\" class=\"toc\" summary=\"Contents\"><tr><td><div style=\"font-weight:bold\">Table of Contents</div><ul></li><li><a href=\"#A\">1 A</a></li><li><a href=\"#B\">2 B</a><ul><li><a href=\"#C\">2.1 C</a></li><li><a href=\"#D\">2.2 D</a><ul><li><a href=\"#E\">2.2.1 E</a></li><li><a href=\"#F\">2.2.2 F</a><ul><li><a href=\"#G\">2.2.2.1 G</a></li><li><a href=\"#H\">2.2.2.2 H</a></li></ul></ul><li><a href=\"#I\">2.3 I</a></li></ul><li><a href=\"#J\">3 J</a></li><li><a href=\"#K\">4 K</a><ul><ul><li><a href=\"#L\">4.1 L</a></li><li><a href=\"#M\">4.2 M</a><ul><li><a href=\"#N\">4.2.1 N</a></li><li><a href=\"#O\">4.2.2 O</a></li></ul></ul></ul></ul></td></tr></table>")
|
303
418
|
end
|
304
419
|
end
|