wikitext 1.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/ext/parser.c +149 -45
- data/ext/token.c +1 -0
- data/ext/token.h +1 -0
- data/ext/wikitext_ragel.c +1718 -1947
- data/lib/wikitext/version.rb +17 -0
- data/spec/autolinking_spec.rb +462 -0
- data/spec/integration_spec.rb +1 -1
- data/spec/pre_spec.rb +77 -18
- data/spec/regressions_spec.rb +703 -1
- metadata +3 -2
data/spec/integration_spec.rb
CHANGED
@@ -87,7 +87,7 @@ describe Wikitext::Parser, 'with large slab of input text' do
|
|
87
87
|
notice how it can contain ''markup''
|
88
88
|
which would '''otherwise''' have <tt>special</tt> meaning
|
89
89
|
although explicit entities © are passed through unchanged
|
90
|
-
|
90
|
+
|
91
91
|
a normal paragraph again
|
92
92
|
|
93
93
|
{{an_image.png}}
|
data/spec/pre_spec.rb
CHANGED
@@ -29,6 +29,33 @@ describe Wikitext::Parser, 'parsing PRE blocks' do
|
|
29
29
|
@parser.parse(" foo\n bar").should == "<pre>foo\nbar</pre>\n"
|
30
30
|
end
|
31
31
|
|
32
|
+
it 'should handle "empty" lines in the middle of multiline PRE blocks' do
|
33
|
+
input = dedent <<-END
|
34
|
+
foo
|
35
|
+
|
36
|
+
bar
|
37
|
+
END
|
38
|
+
expected = dedent <<-END
|
39
|
+
<pre>foo
|
40
|
+
|
41
|
+
bar</pre>
|
42
|
+
END
|
43
|
+
@parser.parse(input).should == expected
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'should render an empty block for an empty PRE block' do
|
47
|
+
@parser.parse(' ').should == "<pre></pre>\n"
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'should sanely handle a leading empty line' do
|
51
|
+
@parser.parse(" \n foo").should == "<pre>\nfoo</pre>\n"
|
52
|
+
end
|
53
|
+
|
54
|
+
it 'should sanely handle a trailing empty line' do
|
55
|
+
@parser.parse(" foo\n \n").should == "<pre>foo\n</pre>\n"
|
56
|
+
@parser.parse(" foo\n ").should == "<pre>foo\n</pre>\n"
|
57
|
+
end
|
58
|
+
|
32
59
|
it 'should allow nesting inside a <blockquote> block' do
|
33
60
|
# nesting inside single blockquotes
|
34
61
|
@parser.parse("> foo").should == "<blockquote>\n <pre>foo</pre>\n</blockquote>\n"
|
@@ -236,13 +263,14 @@ describe Wikitext::Parser, 'parsing PRE_START/PRE_END blocks' do
|
|
236
263
|
@parser.parse('> </pre>').should == expected
|
237
264
|
end
|
238
265
|
|
239
|
-
it 'should
|
266
|
+
it 'should break out of UL blocks on seeing PRE_START' do
|
240
267
|
expected = dedent <<-END
|
241
268
|
<ul>
|
242
|
-
<li
|
269
|
+
<li>foo</li>
|
243
270
|
</ul>
|
271
|
+
<pre>bar</pre>
|
244
272
|
END
|
245
|
-
@parser.parse('* <pre>').should == expected
|
273
|
+
@parser.parse('* foo<pre>bar</pre>').should == expected
|
246
274
|
end
|
247
275
|
|
248
276
|
it 'should ignore PRE_END inside UL blocks' do
|
@@ -254,13 +282,14 @@ describe Wikitext::Parser, 'parsing PRE_START/PRE_END blocks' do
|
|
254
282
|
@parser.parse('* </pre>').should == expected
|
255
283
|
end
|
256
284
|
|
257
|
-
it 'should
|
285
|
+
it 'should break out of OL blocks on seeing PRE_START' do
|
258
286
|
expected = dedent <<-END
|
259
287
|
<ol>
|
260
|
-
<li
|
288
|
+
<li>foo</li>
|
261
289
|
</ol>
|
290
|
+
<pre>bar</pre>
|
262
291
|
END
|
263
|
-
@parser.parse('# <pre>').should == expected
|
292
|
+
@parser.parse('# foo<pre>bar</pre>').should == expected
|
264
293
|
end
|
265
294
|
|
266
295
|
it 'should ignore PRE_END inside OL blocks' do
|
@@ -272,48 +301,78 @@ describe Wikitext::Parser, 'parsing PRE_START/PRE_END blocks' do
|
|
272
301
|
@parser.parse('# </pre>').should == expected
|
273
302
|
end
|
274
303
|
|
275
|
-
it 'should
|
276
|
-
|
304
|
+
it 'should break out of H1 blocks on seeing PRE_START' do
|
305
|
+
expected = dedent <<-END
|
306
|
+
<h1>foo</h1>
|
307
|
+
<pre>bar</pre>
|
308
|
+
<p> =</p>
|
309
|
+
END
|
310
|
+
@parser.parse('= foo<pre>bar</pre> =').should == expected
|
277
311
|
end
|
278
312
|
|
279
313
|
it 'should ignore PRE_END inside H1 blocks' do
|
280
314
|
@parser.parse('= </pre> =').should == "<h1></pre></h1>\n"
|
281
315
|
end
|
282
316
|
|
283
|
-
it 'should
|
284
|
-
|
317
|
+
it 'should break out of H2 blocks on seeing PRE_START' do
|
318
|
+
expected = dedent <<-END
|
319
|
+
<h2>foo</h2>
|
320
|
+
<pre>bar</pre>
|
321
|
+
<p> ==</p>
|
322
|
+
END
|
323
|
+
@parser.parse('== foo<pre>bar</pre> ==').should == expected
|
285
324
|
end
|
286
325
|
|
287
326
|
it 'should ignore PRE_END inside H2 blocks' do
|
288
327
|
@parser.parse('== </pre> ==').should == "<h2></pre></h2>\n"
|
289
328
|
end
|
290
329
|
|
291
|
-
it 'should
|
292
|
-
|
330
|
+
it 'should break out of H3 blocks on seeing PRE_START' do
|
331
|
+
expected = dedent <<-END
|
332
|
+
<h3>foo</h3>
|
333
|
+
<pre>bar</pre>
|
334
|
+
<p> ===</p>
|
335
|
+
END
|
336
|
+
@parser.parse('=== foo<pre>bar</pre> ===').should == expected
|
293
337
|
end
|
294
338
|
|
295
339
|
it 'should ignore PRE_END inside H3 blocks' do
|
296
340
|
@parser.parse('=== </pre> ===').should == "<h3></pre></h3>\n"
|
297
341
|
end
|
298
342
|
|
299
|
-
it 'should
|
300
|
-
|
343
|
+
it 'should break out of H4 blocks on seeing PRE_START' do
|
344
|
+
expected = dedent <<-END
|
345
|
+
<h4>foo</h4>
|
346
|
+
<pre>bar</pre>
|
347
|
+
<p> ====</p>
|
348
|
+
END
|
349
|
+
@parser.parse('==== foo<pre>bar</pre> ====').should == expected
|
301
350
|
end
|
302
351
|
|
303
352
|
it 'should ignore PRE_END inside H4 blocks' do
|
304
353
|
@parser.parse('==== </pre> ====').should == "<h4></pre></h4>\n"
|
305
354
|
end
|
306
355
|
|
307
|
-
it 'should
|
308
|
-
|
356
|
+
it 'should break out of H5 blocks on seeing PRE_START' do
|
357
|
+
expected = dedent <<-END
|
358
|
+
<h5>foo</h5>
|
359
|
+
<pre>bar</pre>
|
360
|
+
<p> =====</p>
|
361
|
+
END
|
362
|
+
@parser.parse('===== foo<pre>bar</pre> =====').should == expected
|
309
363
|
end
|
310
364
|
|
311
365
|
it 'should ignore PRE_END inside H5 blocks' do
|
312
366
|
@parser.parse('===== </pre> =====').should == "<h5></pre></h5>\n"
|
313
367
|
end
|
314
368
|
|
315
|
-
it 'should
|
316
|
-
|
369
|
+
it 'should break out of H6 blocks on seeing PRE_START' do
|
370
|
+
expected = dedent <<-END
|
371
|
+
<h6>foo</h6>
|
372
|
+
<pre>bar</pre>
|
373
|
+
<p> ======</p>
|
374
|
+
END
|
375
|
+
@parser.parse('====== foo<pre>bar</pre> ======').should == expected
|
317
376
|
end
|
318
377
|
|
319
378
|
it 'should ignore PRE_END inside H6 blocks' do
|
data/spec/regressions_spec.rb
CHANGED
@@ -22,8 +22,8 @@ describe Wikitext::Parser, 'regressions' do
|
|
22
22
|
@parser = Wikitext::Parser.new
|
23
23
|
end
|
24
24
|
|
25
|
+
# turns out that this was never a bug in wikitext -- it was a bug in the host application -- but keeping the test does no harm
|
25
26
|
it 'should correctly transform example #1' do
|
26
|
-
# turns out that this was never a bug in wikitext: it was a bug in the host application
|
27
27
|
input = dedent <<-END
|
28
28
|
= Leopard =
|
29
29
|
|
@@ -42,4 +42,706 @@ describe Wikitext::Parser, 'regressions' do
|
|
42
42
|
END
|
43
43
|
@parser.parse(input).should == expected
|
44
44
|
end
|
45
|
+
|
46
|
+
# discovered at: http://rails.wincent.com/wiki/nginx_log_rotation
|
47
|
+
# fixed by 0a328f1
|
48
|
+
it 'should allow empty lines in PRE blocks marked up with a leading space' do
|
49
|
+
input = dedent <<-END
|
50
|
+
# -d turns on debug mode: output is verbose, no actual changes are made to the log files
|
51
|
+
sudo logrotate -d /etc/logrotate.d/nginx
|
52
|
+
|
53
|
+
# if the debug output looks good, proceed with a real rotation (-v turns on verbose output)
|
54
|
+
sudo logrotate -v /etc/logrotate.d/nginx
|
55
|
+
END
|
56
|
+
expected = dedent <<-END
|
57
|
+
<pre># -d turns on debug mode: output is verbose, no actual changes are made to the log files
|
58
|
+
sudo logrotate -d /etc/logrotate.d/nginx
|
59
|
+
|
60
|
+
# if the debug output looks good, proceed with a real rotation (-v turns on verbose output)
|
61
|
+
sudo logrotate -v /etc/logrotate.d/nginx</pre>
|
62
|
+
END
|
63
|
+
@parser.parse(input).should == expected
|
64
|
+
end
|
65
|
+
|
66
|
+
# discovered at: http://rails.wincent.com/wiki/Installing_Ragel_5.2.0_on_Mac_OS_X_Tiger
|
67
|
+
# fixed by a616841
|
68
|
+
it 'should handle PRE_START blocks which follow unordered lists' do
|
69
|
+
input = dedent <<-END
|
70
|
+
* Get link to latest source code from: http://www.cs.queensu.ca/~thurston/ragel/
|
71
|
+
|
72
|
+
<pre>wget http://www.cs.queensu.ca/~thurston/ragel/ragel-5.20.tar.gz
|
73
|
+
tar xzvf ragel-5.20.tar.gz
|
74
|
+
cd ragel-5.20</pre>
|
75
|
+
END
|
76
|
+
expected = dedent <<-END
|
77
|
+
<ul>
|
78
|
+
<li>Get link to latest source code from: <a href="http://www.cs.queensu.ca/~thurston/ragel/" class="external">http://www.cs.queensu.ca/~thurston/ragel/</a></li>
|
79
|
+
</ul>
|
80
|
+
<pre>wget <a href="http://www.cs.queensu.ca/~thurston/ragel/ragel-5.20.tar.gz" class="external">http://www.cs.queensu.ca/~thurston/ragel/ragel-5.20.tar.gz</a>
|
81
|
+
tar xzvf ragel-5.20.tar.gz
|
82
|
+
cd ragel-5.20</pre>
|
83
|
+
END
|
84
|
+
@parser.parse(input).should == expected
|
85
|
+
end
|
86
|
+
|
87
|
+
# discovered at: http://rails.wincent.com/wiki/Movable_Type_security_notes
|
88
|
+
# fixed by a616841
|
89
|
+
it 'should handle PRE_START blocks which follow ordered lists' do
|
90
|
+
input = dedent <<-END
|
91
|
+
# Turn off the [[Movable Type]] search function; use Google instead (it's better anyway) with a form something like this:
|
92
|
+
|
93
|
+
<pre><form method="get"...></pre>
|
94
|
+
END
|
95
|
+
expected = dedent <<-END
|
96
|
+
<ol>
|
97
|
+
<li>Turn off the <a href="/wiki/Movable%20Type">Movable Type</a> search function; use Google instead (it's better anyway) with a form something like this:</li>
|
98
|
+
</ol>
|
99
|
+
<pre><form method="get"...></pre>
|
100
|
+
END
|
101
|
+
@parser.parse(input).should == expected
|
102
|
+
end
|
103
|
+
|
104
|
+
# discovered at: http://rails.wincent.com/wiki/Movable_Type_security_notes
|
105
|
+
# fixed by 191b75d
|
106
|
+
it 'should respect additional indentation found inside PRE blocks' do
|
107
|
+
# note the two extra spaces on each line
|
108
|
+
input = dedent <<-END
|
109
|
+
<input type="text" name="q" size="20" maxlength="255" value="" />
|
110
|
+
<input type="hidden" name="hl" value="en" />
|
111
|
+
END
|
112
|
+
|
113
|
+
# problem is the spaces were being emitted _before_ the CRLF
|
114
|
+
expected = dedent <<-END
|
115
|
+
<pre> <input type="text" name="q" size="20" maxlength="255" value="" />
|
116
|
+
<input type="hidden" name="hl" value="en" /></pre>
|
117
|
+
END
|
118
|
+
@parser.parse(input).should == expected
|
119
|
+
end
|
120
|
+
|
121
|
+
# this is the general case of the bug covered in the previous spec
|
122
|
+
# any token that appears as the first token after a PRE token can manifest this bug
|
123
|
+
# PRINTABLE didn't only because it called _Wikitext_start_para_if_necessary(), which handled the pending CRLF
|
124
|
+
it 'should emit pending newlines for all token types found inside PRE and PRE_START blocks' do
|
125
|
+
# PRE_START
|
126
|
+
input = dedent <<-END
|
127
|
+
foo
|
128
|
+
<pre>bar
|
129
|
+
END
|
130
|
+
expected = dedent <<-END
|
131
|
+
<pre>foo
|
132
|
+
<pre>bar</pre>
|
133
|
+
END
|
134
|
+
@parser.parse(input).should == expected
|
135
|
+
|
136
|
+
# PRE_END
|
137
|
+
input = dedent <<-END
|
138
|
+
foo
|
139
|
+
</pre>bar
|
140
|
+
END
|
141
|
+
expected = dedent <<-END
|
142
|
+
<pre>foo
|
143
|
+
</pre>bar</pre>
|
144
|
+
END
|
145
|
+
@parser.parse(input).should == expected
|
146
|
+
|
147
|
+
# BLOCKQUOTE_START
|
148
|
+
input = dedent <<-END
|
149
|
+
foo
|
150
|
+
<blockquote>bar
|
151
|
+
END
|
152
|
+
expected = dedent <<-END
|
153
|
+
<pre>foo
|
154
|
+
<blockquote>bar</pre>
|
155
|
+
END
|
156
|
+
@parser.parse(input).should == expected
|
157
|
+
|
158
|
+
# BLOCKQUOTE_END
|
159
|
+
input = dedent <<-END
|
160
|
+
foo
|
161
|
+
</blockquote>bar
|
162
|
+
END
|
163
|
+
expected = dedent <<-END
|
164
|
+
<pre>foo
|
165
|
+
</blockquote>bar</pre>
|
166
|
+
END
|
167
|
+
@parser.parse(input).should == expected
|
168
|
+
|
169
|
+
# NO_WIKI_START
|
170
|
+
input = dedent <<-END
|
171
|
+
foo
|
172
|
+
<nowiki>bar
|
173
|
+
END
|
174
|
+
expected = dedent <<-END
|
175
|
+
<pre>foo
|
176
|
+
<nowiki>bar</pre>
|
177
|
+
END
|
178
|
+
@parser.parse(input).should == expected
|
179
|
+
|
180
|
+
# STRONG_EM
|
181
|
+
input = dedent <<-END
|
182
|
+
foo
|
183
|
+
'''''bar
|
184
|
+
END
|
185
|
+
expected = dedent <<-END
|
186
|
+
<pre>foo
|
187
|
+
'''''bar</pre>
|
188
|
+
END
|
189
|
+
@parser.parse(input).should == expected
|
190
|
+
|
191
|
+
# STRONG
|
192
|
+
input = dedent <<-END
|
193
|
+
foo
|
194
|
+
'''bar
|
195
|
+
END
|
196
|
+
expected = dedent <<-END
|
197
|
+
<pre>foo
|
198
|
+
'''bar</pre>
|
199
|
+
END
|
200
|
+
@parser.parse(input).should == expected
|
201
|
+
|
202
|
+
# STRONG_START
|
203
|
+
input = dedent <<-END
|
204
|
+
foo
|
205
|
+
<strong>bar
|
206
|
+
END
|
207
|
+
expected = dedent <<-END
|
208
|
+
<pre>foo
|
209
|
+
<strong>bar</pre>
|
210
|
+
END
|
211
|
+
@parser.parse(input).should == expected
|
212
|
+
|
213
|
+
# STRONG_END
|
214
|
+
input = dedent <<-END
|
215
|
+
foo
|
216
|
+
</strong>bar
|
217
|
+
END
|
218
|
+
expected = dedent <<-END
|
219
|
+
<pre>foo
|
220
|
+
</strong>bar</pre>
|
221
|
+
END
|
222
|
+
@parser.parse(input).should == expected
|
223
|
+
|
224
|
+
# EM
|
225
|
+
input = dedent <<-END
|
226
|
+
foo
|
227
|
+
''bar
|
228
|
+
END
|
229
|
+
expected = dedent <<-END
|
230
|
+
<pre>foo
|
231
|
+
''bar</pre>
|
232
|
+
END
|
233
|
+
@parser.parse(input).should == expected
|
234
|
+
|
235
|
+
# EM_START
|
236
|
+
input = dedent <<-END
|
237
|
+
foo
|
238
|
+
<em>bar
|
239
|
+
END
|
240
|
+
expected = dedent <<-END
|
241
|
+
<pre>foo
|
242
|
+
<em>bar</pre>
|
243
|
+
END
|
244
|
+
@parser.parse(input).should == expected
|
245
|
+
|
246
|
+
# EM_END
|
247
|
+
input = dedent <<-END
|
248
|
+
foo
|
249
|
+
</em>bar
|
250
|
+
END
|
251
|
+
expected = dedent <<-END
|
252
|
+
<pre>foo
|
253
|
+
</em>bar</pre>
|
254
|
+
END
|
255
|
+
@parser.parse(input).should == expected
|
256
|
+
|
257
|
+
# TT
|
258
|
+
input = dedent <<-END
|
259
|
+
foo
|
260
|
+
`bar
|
261
|
+
END
|
262
|
+
expected = dedent <<-END
|
263
|
+
<pre>foo
|
264
|
+
`bar</pre>
|
265
|
+
END
|
266
|
+
@parser.parse(input).should == expected
|
267
|
+
|
268
|
+
# TT_START
|
269
|
+
input = dedent <<-END
|
270
|
+
foo
|
271
|
+
<tt>bar
|
272
|
+
END
|
273
|
+
expected = dedent <<-END
|
274
|
+
<pre>foo
|
275
|
+
<tt>bar</pre>
|
276
|
+
END
|
277
|
+
@parser.parse(input).should == expected
|
278
|
+
|
279
|
+
# TT_END
|
280
|
+
input = dedent <<-END
|
281
|
+
foo
|
282
|
+
</tt>bar
|
283
|
+
END
|
284
|
+
expected = dedent <<-END
|
285
|
+
<pre>foo
|
286
|
+
</tt>bar</pre>
|
287
|
+
END
|
288
|
+
@parser.parse(input).should == expected
|
289
|
+
|
290
|
+
# H6_END
|
291
|
+
input = dedent <<-END
|
292
|
+
foo
|
293
|
+
======
|
294
|
+
bar
|
295
|
+
END
|
296
|
+
expected = dedent <<-END
|
297
|
+
<pre>foo
|
298
|
+
======
|
299
|
+
bar</pre>
|
300
|
+
END
|
301
|
+
@parser.parse(input).should == expected
|
302
|
+
|
303
|
+
# H5_END
|
304
|
+
input = dedent <<-END
|
305
|
+
foo
|
306
|
+
=====
|
307
|
+
bar
|
308
|
+
END
|
309
|
+
expected = dedent <<-END
|
310
|
+
<pre>foo
|
311
|
+
=====
|
312
|
+
bar</pre>
|
313
|
+
END
|
314
|
+
@parser.parse(input).should == expected
|
315
|
+
|
316
|
+
# H4_END
|
317
|
+
input = dedent <<-END
|
318
|
+
foo
|
319
|
+
====
|
320
|
+
bar
|
321
|
+
END
|
322
|
+
expected = dedent <<-END
|
323
|
+
<pre>foo
|
324
|
+
====
|
325
|
+
bar</pre>
|
326
|
+
END
|
327
|
+
@parser.parse(input).should == expected
|
328
|
+
|
329
|
+
# H3_END
|
330
|
+
input = dedent <<-END
|
331
|
+
foo
|
332
|
+
===
|
333
|
+
bar
|
334
|
+
END
|
335
|
+
expected = dedent <<-END
|
336
|
+
<pre>foo
|
337
|
+
===
|
338
|
+
bar</pre>
|
339
|
+
END
|
340
|
+
@parser.parse(input).should == expected
|
341
|
+
|
342
|
+
# H2_END
|
343
|
+
input = dedent <<-END
|
344
|
+
foo
|
345
|
+
==
|
346
|
+
bar
|
347
|
+
END
|
348
|
+
expected = dedent <<-END
|
349
|
+
<pre>foo
|
350
|
+
==
|
351
|
+
bar</pre>
|
352
|
+
END
|
353
|
+
@parser.parse(input).should == expected
|
354
|
+
|
355
|
+
# H1_END
|
356
|
+
input = dedent <<-END
|
357
|
+
foo
|
358
|
+
=
|
359
|
+
bar
|
360
|
+
END
|
361
|
+
expected = dedent <<-END
|
362
|
+
<pre>foo
|
363
|
+
=
|
364
|
+
bar</pre>
|
365
|
+
END
|
366
|
+
@parser.parse(input).should == expected
|
367
|
+
|
368
|
+
# MAIL
|
369
|
+
input = dedent <<-END
|
370
|
+
foo
|
371
|
+
bar@baz.com
|
372
|
+
END
|
373
|
+
expected = dedent <<-END
|
374
|
+
<pre>foo
|
375
|
+
bar@baz.com</pre>
|
376
|
+
END
|
377
|
+
@parser.parse(input).should == expected
|
378
|
+
|
379
|
+
# LINK_START
|
380
|
+
input = dedent <<-END
|
381
|
+
foo
|
382
|
+
[[bar
|
383
|
+
END
|
384
|
+
expected = dedent <<-END
|
385
|
+
<pre>foo
|
386
|
+
[[bar</pre>
|
387
|
+
END
|
388
|
+
@parser.parse(input).should == expected
|
389
|
+
|
390
|
+
# LINK_END
|
391
|
+
input = dedent <<-END
|
392
|
+
foo
|
393
|
+
]]bar
|
394
|
+
END
|
395
|
+
expected = dedent <<-END
|
396
|
+
<pre>foo
|
397
|
+
]]bar</pre>
|
398
|
+
END
|
399
|
+
@parser.parse(input).should == expected
|
400
|
+
|
401
|
+
# EXT_LINK_START
|
402
|
+
input = dedent <<-END
|
403
|
+
foo
|
404
|
+
[bar
|
405
|
+
END
|
406
|
+
expected = dedent <<-END
|
407
|
+
<pre>foo
|
408
|
+
[bar</pre>
|
409
|
+
END
|
410
|
+
@parser.parse(input).should == expected
|
411
|
+
|
412
|
+
# EXT_LINK_END
|
413
|
+
input = dedent <<-END
|
414
|
+
foo
|
415
|
+
]bar
|
416
|
+
END
|
417
|
+
expected = dedent <<-END
|
418
|
+
<pre>foo
|
419
|
+
]bar</pre>
|
420
|
+
END
|
421
|
+
@parser.parse(input).should == expected
|
422
|
+
|
423
|
+
# IMG_START
|
424
|
+
input = dedent <<-END
|
425
|
+
foo
|
426
|
+
{{bar
|
427
|
+
END
|
428
|
+
expected = dedent <<-END
|
429
|
+
<pre>foo
|
430
|
+
{{bar</pre>
|
431
|
+
END
|
432
|
+
@parser.parse(input).should == expected
|
433
|
+
|
434
|
+
# these tokens weren't affected by the bug, seeing as they either call _Wikitext_start_para_if_necessary()
|
435
|
+
# or they can only appear in PRE_START (not PRE) thanks to the tokenizer
|
436
|
+
# but we add specs for them to make sure that the issue never crops up for them in the future
|
437
|
+
|
438
|
+
# PRE (in PRE_START)
|
439
|
+
input = dedent <<-END
|
440
|
+
<pre>foo
|
441
|
+
bar</pre>
|
442
|
+
END
|
443
|
+
expected = dedent <<-END
|
444
|
+
<pre>foo
|
445
|
+
bar</pre>
|
446
|
+
END
|
447
|
+
@parser.parse(input).should == expected
|
448
|
+
|
449
|
+
# BLOCKQUOTE (in PRE_START)
|
450
|
+
input = dedent <<-END
|
451
|
+
<pre>foo
|
452
|
+
> bar</pre>
|
453
|
+
END
|
454
|
+
expected = dedent <<-END
|
455
|
+
<pre>foo
|
456
|
+
> bar</pre>
|
457
|
+
END
|
458
|
+
@parser.parse(input).should == expected
|
459
|
+
|
460
|
+
# OL (in PRE_START)
|
461
|
+
input = dedent <<-END
|
462
|
+
<pre># foo
|
463
|
+
# bar</pre>
|
464
|
+
END
|
465
|
+
expected = dedent <<-END
|
466
|
+
<pre># foo
|
467
|
+
# bar</pre>
|
468
|
+
END
|
469
|
+
@parser.parse(input).should == expected
|
470
|
+
|
471
|
+
# UL (in PRE_START)
|
472
|
+
input = dedent <<-END
|
473
|
+
<pre>* foo
|
474
|
+
* bar</pre>
|
475
|
+
END
|
476
|
+
expected = dedent <<-END
|
477
|
+
<pre>* foo
|
478
|
+
* bar</pre>
|
479
|
+
END
|
480
|
+
@parser.parse(input).should == expected
|
481
|
+
|
482
|
+
# H6_START (in PRE_START)
|
483
|
+
input = dedent <<-END
|
484
|
+
<pre>foo
|
485
|
+
====== bar
|
486
|
+
baz</pre>
|
487
|
+
END
|
488
|
+
expected = dedent <<-END
|
489
|
+
<pre>foo
|
490
|
+
====== bar
|
491
|
+
baz</pre>
|
492
|
+
END
|
493
|
+
@parser.parse(input).should == expected
|
494
|
+
|
495
|
+
# H5_START (in PRE_START)
|
496
|
+
input = dedent <<-END
|
497
|
+
<pre>foo
|
498
|
+
===== bar
|
499
|
+
baz</pre>
|
500
|
+
END
|
501
|
+
expected = dedent <<-END
|
502
|
+
<pre>foo
|
503
|
+
===== bar
|
504
|
+
baz</pre>
|
505
|
+
END
|
506
|
+
@parser.parse(input).should == expected
|
507
|
+
|
508
|
+
# H4_START (in PRE_START)
|
509
|
+
input = dedent <<-END
|
510
|
+
<pre>foo
|
511
|
+
==== bar
|
512
|
+
baz</pre>
|
513
|
+
END
|
514
|
+
expected = dedent <<-END
|
515
|
+
<pre>foo
|
516
|
+
==== bar
|
517
|
+
baz</pre>
|
518
|
+
END
|
519
|
+
@parser.parse(input).should == expected
|
520
|
+
|
521
|
+
# H3_START (in PRE_START)
|
522
|
+
input = dedent <<-END
|
523
|
+
<pre>foo
|
524
|
+
=== bar
|
525
|
+
baz</pre>
|
526
|
+
END
|
527
|
+
expected = dedent <<-END
|
528
|
+
<pre>foo
|
529
|
+
=== bar
|
530
|
+
baz</pre>
|
531
|
+
END
|
532
|
+
@parser.parse(input).should == expected
|
533
|
+
|
534
|
+
# H2_START (in PRE_START)
|
535
|
+
input = dedent <<-END
|
536
|
+
<pre>foo
|
537
|
+
== bar
|
538
|
+
baz</pre>
|
539
|
+
END
|
540
|
+
expected = dedent <<-END
|
541
|
+
<pre>foo
|
542
|
+
== bar
|
543
|
+
baz</pre>
|
544
|
+
END
|
545
|
+
@parser.parse(input).should == expected
|
546
|
+
|
547
|
+
# H1_START (in PRE_START)
|
548
|
+
input = dedent <<-END
|
549
|
+
<pre>foo
|
550
|
+
= bar
|
551
|
+
baz</pre>
|
552
|
+
END
|
553
|
+
expected = dedent <<-END
|
554
|
+
<pre>foo
|
555
|
+
= bar
|
556
|
+
baz</pre>
|
557
|
+
END
|
558
|
+
@parser.parse(input).should == expected
|
559
|
+
|
560
|
+
# NO_WIKI_END
|
561
|
+
input = dedent <<-END
|
562
|
+
foo
|
563
|
+
</nowiki>bar
|
564
|
+
END
|
565
|
+
expected = dedent <<-END
|
566
|
+
<pre>foo
|
567
|
+
</nowiki>bar</pre>
|
568
|
+
END
|
569
|
+
@parser.parse(input).should == expected
|
570
|
+
|
571
|
+
# SEPARATOR
|
572
|
+
input = dedent <<-END
|
573
|
+
foo
|
574
|
+
|bar
|
575
|
+
END
|
576
|
+
expected = dedent <<-END
|
577
|
+
<pre>foo
|
578
|
+
|bar</pre>
|
579
|
+
END
|
580
|
+
@parser.parse(input).should == expected
|
581
|
+
|
582
|
+
# QUOT_ENTITY
|
583
|
+
input = dedent <<-END
|
584
|
+
foo
|
585
|
+
"bar
|
586
|
+
END
|
587
|
+
expected = dedent <<-END
|
588
|
+
<pre>foo
|
589
|
+
"bar</pre>
|
590
|
+
END
|
591
|
+
@parser.parse(input).should == expected
|
592
|
+
|
593
|
+
# AMP_ENTITY
|
594
|
+
input = dedent <<-END
|
595
|
+
foo
|
596
|
+
&bar
|
597
|
+
END
|
598
|
+
expected = dedent <<-END
|
599
|
+
<pre>foo
|
600
|
+
&bar</pre>
|
601
|
+
END
|
602
|
+
@parser.parse(input).should == expected
|
603
|
+
|
604
|
+
# NAMED_ENTITY
|
605
|
+
input = dedent <<-END
|
606
|
+
foo
|
607
|
+
»bar
|
608
|
+
END
|
609
|
+
expected = dedent <<-END
|
610
|
+
<pre>foo
|
611
|
+
»bar</pre>
|
612
|
+
END
|
613
|
+
@parser.parse(input).should == expected
|
614
|
+
|
615
|
+
# DECIMAL_ENTITY
|
616
|
+
input = dedent <<-END
|
617
|
+
foo
|
618
|
+
Ӓbar
|
619
|
+
END
|
620
|
+
expected = dedent <<-END
|
621
|
+
<pre>foo
|
622
|
+
Ӓbar</pre>
|
623
|
+
END
|
624
|
+
@parser.parse(input).should == expected
|
625
|
+
|
626
|
+
# HEX_ENTITY
|
627
|
+
input = dedent <<-END
|
628
|
+
foo
|
629
|
+
•bar
|
630
|
+
END
|
631
|
+
expected = dedent <<-END
|
632
|
+
<pre>foo
|
633
|
+
•bar</pre>
|
634
|
+
END
|
635
|
+
@parser.parse(input).should == expected
|
636
|
+
|
637
|
+
# QUOT
|
638
|
+
input = dedent <<-END
|
639
|
+
foo
|
640
|
+
"bar
|
641
|
+
END
|
642
|
+
expected = dedent <<-END
|
643
|
+
<pre>foo
|
644
|
+
"bar</pre>
|
645
|
+
END
|
646
|
+
@parser.parse(input).should == expected
|
647
|
+
|
648
|
+
# AMP
|
649
|
+
input = dedent <<-END
|
650
|
+
foo
|
651
|
+
&bar
|
652
|
+
END
|
653
|
+
expected = dedent <<-END
|
654
|
+
<pre>foo
|
655
|
+
&bar</pre>
|
656
|
+
END
|
657
|
+
@parser.parse(input).should == expected
|
658
|
+
|
659
|
+
# LESS
|
660
|
+
input = dedent <<-END
|
661
|
+
foo
|
662
|
+
<bar
|
663
|
+
END
|
664
|
+
expected = dedent <<-END
|
665
|
+
<pre>foo
|
666
|
+
<bar</pre>
|
667
|
+
END
|
668
|
+
@parser.parse(input).should == expected
|
669
|
+
|
670
|
+
# GREATER
|
671
|
+
input = dedent <<-END
|
672
|
+
foo
|
673
|
+
>bar
|
674
|
+
END
|
675
|
+
expected = dedent <<-END
|
676
|
+
<pre>foo
|
677
|
+
>bar</pre>
|
678
|
+
END
|
679
|
+
@parser.parse(input).should == expected
|
680
|
+
|
681
|
+
# URI
|
682
|
+
input = dedent <<-END
|
683
|
+
foo
|
684
|
+
http://example.com/
|
685
|
+
END
|
686
|
+
expected = dedent <<-END
|
687
|
+
<pre>foo
|
688
|
+
<a href="http://example.com/" class="external">http://example.com/</a></pre>
|
689
|
+
END
|
690
|
+
@parser.parse(input).should == expected
|
691
|
+
|
692
|
+
# PRINTABLE
|
693
|
+
input = dedent <<-END
|
694
|
+
foo
|
695
|
+
bar
|
696
|
+
END
|
697
|
+
expected = dedent <<-END
|
698
|
+
<pre>foo
|
699
|
+
bar</pre>
|
700
|
+
END
|
701
|
+
@parser.parse(input).should == expected
|
702
|
+
|
703
|
+
# IMG_END
|
704
|
+
input = dedent <<-END
|
705
|
+
foo
|
706
|
+
}}bar
|
707
|
+
END
|
708
|
+
expected = dedent <<-END
|
709
|
+
<pre>foo
|
710
|
+
}}bar</pre>
|
711
|
+
END
|
712
|
+
@parser.parse(input).should == expected
|
713
|
+
|
714
|
+
# LEFT_CURLY
|
715
|
+
input = dedent <<-END
|
716
|
+
foo
|
717
|
+
{bar
|
718
|
+
END
|
719
|
+
expected = dedent <<-END
|
720
|
+
<pre>foo
|
721
|
+
{bar</pre>
|
722
|
+
END
|
723
|
+
@parser.parse(input).should == expected
|
724
|
+
|
725
|
+
# RIGHT_CURLY
|
726
|
+
input = dedent <<-END
|
727
|
+
foo
|
728
|
+
}bar
|
729
|
+
END
|
730
|
+
expected = dedent <<-END
|
731
|
+
<pre>foo
|
732
|
+
}bar</pre>
|
733
|
+
END
|
734
|
+
@parser.parse(input).should == expected
|
735
|
+
|
736
|
+
# DEFAULT
|
737
|
+
input = dedent <<-END
|
738
|
+
foo
|
739
|
+
€bar
|
740
|
+
END
|
741
|
+
expected = dedent <<-END
|
742
|
+
<pre>foo
|
743
|
+
€bar</pre>
|
744
|
+
END
|
745
|
+
@parser.parse(input).should == expected
|
746
|
+
end
|
45
747
|
end
|