breakout_parser 0.0.12-x86-mingw32 → 0.0.13-x86-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +7 -0
- data/lib/breakout_parser/win32-ruby1.8/breakout_parser.so +0 -0
- data/spec/parser_spec.rb +86 -21
- metadata +2 -2
data/ChangeLog
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
[ 0.0.13 ]
|
2
|
+
|
3
|
+
* add "h-" to header ids
|
4
|
+
(https://www.assembla.com/spaces/breakout/tickets/5793)
|
5
|
+
* handle [un]numbered lists of level 2 and 3 (**,***,##,###)
|
6
|
+
(https://www.assembla.com/spaces/breakout/tickets/5687)
|
7
|
+
|
1
8
|
[ 0.0.12 ]
|
2
9
|
|
3
10
|
* new internal calling convention
|
Binary file
|
data/spec/parser_spec.rb
CHANGED
@@ -11,6 +11,19 @@ describe 'BreakoutParser' do
|
|
11
11
|
end
|
12
12
|
def hex_string s; self.class.hex_string(s); end
|
13
13
|
|
14
|
+
def unformat s
|
15
|
+
s.strip.split("\n").map(&:strip).join
|
16
|
+
end
|
17
|
+
|
18
|
+
def get_data fname
|
19
|
+
r = File.read(File.dirname(__FILE__) + '/data/' + fname)
|
20
|
+
if self.class.description[' numbered list multilevel']
|
21
|
+
r.gsub!('*','#')
|
22
|
+
r.gsub!('ul>','ol>')
|
23
|
+
end
|
24
|
+
r
|
25
|
+
end
|
26
|
+
|
14
27
|
it 'accepts from 2 to 4 arguments' do
|
15
28
|
[0,1,5,6,7,8,9,10].each do |argc|
|
16
29
|
lambda{
|
@@ -319,6 +332,31 @@ describe 'BreakoutParser' do
|
|
319
332
|
parse("hello\n\n * a\n * b\n * c\nworld").should ==
|
320
333
|
"hello<br /><br /><ul><li>a</li><li>b</li><li>c</li></ul>world"
|
321
334
|
end
|
335
|
+
|
336
|
+
describe "multilevel" do
|
337
|
+
it "at start" do
|
338
|
+
# NOTE: not sure that list1.html is correct enough, but it should render fine
|
339
|
+
parse(get_data('list1')).should == unformat(get_data('list1.html'))
|
340
|
+
end
|
341
|
+
|
342
|
+
it "in middle" do
|
343
|
+
parse(get_data('list2')).should == unformat(get_data('list2.html'))
|
344
|
+
end
|
345
|
+
|
346
|
+
it "three levels" do
|
347
|
+
parse(get_data('list3')).should == unformat(get_data('list3.html'))
|
348
|
+
end
|
349
|
+
|
350
|
+
it "mess - should have matching count of opening and closing tags" do
|
351
|
+
r = parse(get_data('list4'))
|
352
|
+
r.scan('<ul>').count.should > 0
|
353
|
+
r.scan('<ul>').count.should <= r.scan('</ul>').count
|
354
|
+
end
|
355
|
+
|
356
|
+
it "at end" do
|
357
|
+
parse(get_data('list5')).should == unformat(get_data('list5.html'))
|
358
|
+
end
|
359
|
+
end
|
322
360
|
end
|
323
361
|
|
324
362
|
###############################################################################
|
@@ -347,58 +385,84 @@ describe 'BreakoutParser' do
|
|
347
385
|
parse("hello\n\n # a\n # b\n # c\nworld").should ==
|
348
386
|
"hello<br /><br /><ol><li>a</li><li>b</li><li>c</li></ol>world"
|
349
387
|
end
|
388
|
+
|
389
|
+
describe "multilevel" do
|
390
|
+
it "at start" do
|
391
|
+
# NOTE: not sure that list1.html is correct enough, but it should render fine
|
392
|
+
parse(get_data('list1')).should == unformat(get_data('list1.html'))
|
393
|
+
end
|
394
|
+
|
395
|
+
it "in middle" do
|
396
|
+
parse(get_data('list2')).should == unformat(get_data('list2.html'))
|
397
|
+
end
|
398
|
+
|
399
|
+
it "three levels" do
|
400
|
+
parse(get_data('list3')).should == unformat(get_data('list3.html'))
|
401
|
+
end
|
402
|
+
|
403
|
+
it "mess - should have matching count of opening and closing tags" do
|
404
|
+
r = parse(unformat(get_data('list4')))
|
405
|
+
r.scan('<ol>').count.should > 0
|
406
|
+
r.scan('<ol>').count.should <= r.scan('</ol>').count
|
407
|
+
end
|
408
|
+
|
409
|
+
it "at end" do
|
410
|
+
parse(get_data('list5')).should == unformat(get_data('list5.html'))
|
411
|
+
end
|
412
|
+
end
|
350
413
|
end
|
351
414
|
|
352
415
|
###############################################################################
|
416
|
+
# headers
|
353
417
|
|
354
418
|
1.upto(5) do |lvl|
|
355
419
|
describe "H#{lvl}" do
|
356
420
|
it "at the beginning" do
|
357
|
-
parse("h#{lvl}. xxx").should == "<h#{lvl} id=\"xxx\">xxx</h#{lvl}>"
|
421
|
+
parse("h#{lvl}. xxx").should == "<h#{lvl} id=\"h-xxx\">xxx</h#{lvl}>"
|
358
422
|
end
|
359
423
|
it "after 1 line of text" do
|
360
|
-
parse("abcd\nh#{lvl}. xxx").should == "abcd<br /><h#{lvl} id=\"xxx\">xxx</h#{lvl}>"
|
424
|
+
parse("abcd\nh#{lvl}. xxx").should == "abcd<br /><h#{lvl} id=\"h-xxx\">xxx</h#{lvl}>"
|
361
425
|
end
|
362
426
|
it "after 2 lines of text" do
|
363
|
-
parse("abcd\ndefgh\nh#{lvl}. xxx").should == "abcd<br />defgh<br /><h#{lvl} id=\"xxx\">xxx</h#{lvl}>"
|
427
|
+
parse("abcd\ndefgh\nh#{lvl}. xxx").should == "abcd<br />defgh<br /><h#{lvl} id=\"h-xxx\">xxx</h#{lvl}>"
|
364
428
|
end
|
365
429
|
it "in middle of other words" do
|
366
430
|
parse("abcd defgh h#{lvl}. xxx yyy").should == "abcd defgh h#{lvl}. xxx yyy"
|
367
431
|
end
|
368
432
|
it "in middle of other lines" do
|
369
|
-
parse("abcd defgh\nh#{lvl}. xxx\nyyy").should == "abcd defgh<br /><h#{lvl} id=\"xxx\">xxx</h#{lvl}><br />yyy"
|
433
|
+
parse("abcd defgh\nh#{lvl}. xxx\nyyy").should == "abcd defgh<br /><h#{lvl} id=\"h-xxx\">xxx</h#{lvl}><br />yyy"
|
370
434
|
end
|
371
435
|
|
372
436
|
it "converts spaces to underscores in id" do
|
373
|
-
parse("h#{lvl}. xxx yyy z").should == "<h#{lvl} id=\"xxx___yyy_z\">xxx yyy z</h#{lvl}>"
|
437
|
+
parse("h#{lvl}. xxx yyy z").should == "<h#{lvl} id=\"h-xxx___yyy_z\">xxx yyy z</h#{lvl}>"
|
374
438
|
end
|
375
439
|
it "keeps underscores in id" do
|
376
|
-
parse("h#{lvl}. xxx___yyy_z").should == "<h#{lvl} id=\"xxx___yyy_z\">xxx___yyy_z</h#{lvl}>"
|
440
|
+
parse("h#{lvl}. xxx___yyy_z").should == "<h#{lvl} id=\"h-xxx___yyy_z\">xxx___yyy_z</h#{lvl}>"
|
377
441
|
end
|
378
442
|
it "keeps dashes in id" do
|
379
|
-
parse("h#{lvl}. xxx---yyy-z").should == "<h#{lvl} id=\"xxx---yyy-z\">xxx---yyy-z</h#{lvl}>"
|
443
|
+
parse("h#{lvl}. xxx---yyy-z").should == "<h#{lvl} id=\"h-xxx---yyy-z\">xxx---yyy-z</h#{lvl}>"
|
380
444
|
end
|
381
445
|
it "keeps dots in id" do
|
382
|
-
parse("h#{lvl}. xxx...yyy.z").should == "<h#{lvl} id=\"xxx...yyy.z\">xxx...yyy.z</h#{lvl}>"
|
446
|
+
parse("h#{lvl}. xxx...yyy.z").should == "<h#{lvl} id=\"h-xxx...yyy.z\">xxx...yyy.z</h#{lvl}>"
|
383
447
|
end
|
384
448
|
|
385
449
|
%w'Ъ ъ : ; , привет" \' ! < >'.each do |c|
|
386
450
|
it "converts id to hex if it contains \"#{c}\"" do
|
387
451
|
idhex = hex_string("xxx#{c}yyy")
|
388
|
-
parse("h#{lvl}. xxx#{c}yyy").should == "<h#{lvl} id=\"
|
452
|
+
parse("h#{lvl}. xxx#{c}yyy").should == "<h#{lvl} id=\"h-#{idhex}\">xxx#{h(c)}yyy</h#{lvl}>"
|
389
453
|
end
|
390
454
|
end
|
391
455
|
|
392
456
|
it "skips excess spaces" do
|
393
|
-
parse("h#{lvl}. \t xxx \t ").should == "<h#{lvl} id=\"xxx\">xxx</h#{lvl}>"
|
457
|
+
parse("h#{lvl}. \t xxx \t ").should == "<h#{lvl} id=\"h-xxx\">xxx</h#{lvl}>"
|
394
458
|
end
|
395
459
|
|
396
460
|
it "thinks that \\r is EOL" do
|
397
|
-
parse("h#{lvl}. xxx\ryyy").should == "<h#{lvl} id=\"xxx\">xxx</h#{lvl}><br />yyy"
|
398
|
-
parse("h#{lvl}. xxx\r").should == "<h#{lvl} id=\"xxx\">xxx</h#{lvl}>"
|
461
|
+
parse("h#{lvl}. xxx\ryyy").should == "<h#{lvl} id=\"h-xxx\">xxx</h#{lvl}><br />yyy"
|
462
|
+
parse("h#{lvl}. xxx\r").should == "<h#{lvl} id=\"h-xxx\">xxx</h#{lvl}>"
|
399
463
|
|
400
464
|
parse("h#{lvl}. xxx\r yyy").sub(' yyy','yyy').should ==
|
401
|
-
"<h#{lvl} id=\"xxx\">xxx</h#{lvl}><br />yyy"
|
465
|
+
"<h#{lvl} id=\"h-xxx\">xxx</h#{lvl}><br />yyy"
|
402
466
|
end
|
403
467
|
end
|
404
468
|
end
|
@@ -740,14 +804,15 @@ describe 'BreakoutParser' do
|
|
740
804
|
a = {}
|
741
805
|
a["wiki:Name"] = '<a class="wiki_link" title="Name" href="/wiki/show/test_space/Name">Name</a>'
|
742
806
|
a["Name"] = '<a class="wiki_link" title="Name" href="/wiki/show/test_space/Name">Name</a>'
|
743
|
-
a["Name#Ref"] = '<a class="wiki_link" title="Name#Ref" href="/wiki/show/test_space/Name#Ref">Name#Ref</a>'
|
744
|
-
a["#Ref"]
|
745
|
-
a["
|
746
|
-
a["
|
747
|
-
a["#
|
748
|
-
a["#
|
749
|
-
a["#with
|
750
|
-
a["#with
|
807
|
+
a["Name#Ref"] = '<a class="wiki_link" title="Name#Ref" href="/wiki/show/test_space/Name#h-Ref">Name#Ref</a>'
|
808
|
+
a["Name#h-Ref"] = '<a class="wiki_link" title="Name#h-Ref" href="/wiki/show/test_space/Name#h-h-Ref">Name#h-Ref</a>'
|
809
|
+
a["#Ref"] = '<a href="#h-Ref" title="#Ref" class="wiki_link">#Ref</a>'
|
810
|
+
a["#привет"] = %Q|<a href="#h-#{hex_string("привет")}" title="#привет" class="wiki_link">#привет</a>|
|
811
|
+
a["#with spc"] = %Q|<a href="#h-with__spc" title="#with spc" class="wiki_link">#with spc</a>|
|
812
|
+
a["#with__usc"] = %Q|<a href="#h-with__usc" title="#with__usc" class="wiki_link">#with__usc</a>|
|
813
|
+
a["#with--dsh"] = %Q|<a href="#h-with--dsh" title="#with--dsh" class="wiki_link">#with--dsh</a>|
|
814
|
+
a["#with!xclm"] = %Q|<a href="#h-#{hex_string("with!xclm")}" title="#with!xclm" class="wiki_link">#with!xclm</a>|
|
815
|
+
a["#with&"] = %Q|<a href="#h-#{hex_string("with&")}" title="#with&" class="wiki_link">#with&amp</a>|
|
751
816
|
|
752
817
|
a["ticket:234"] = '<a href="/spaces/test_space/tickets/234">#234</a>'
|
753
818
|
a["revision:1f4bdab77be696efd"] =
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: breakout_parser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.13
|
5
5
|
platform: x86-mingw32
|
6
6
|
authors:
|
7
7
|
- Andrey "Zed" Zaikin
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-04-
|
12
|
+
date: 2010-04-27 00:00:00 +06:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|