breakout_parser 0.0.3-x86-mingw32 → 0.0.4-x86-mingw32
Sign up to get free protection for your applications and to get access to all the features.
Binary file
|
data/spec/parser_spec.rb
CHANGED
@@ -168,23 +168,23 @@ describe 'BreakoutParser' do
|
|
168
168
|
{'ul' => '*', 'ol' => '#'}.each do |l,c|
|
169
169
|
it "raw text link inside #{l.upcase}> #1" do
|
170
170
|
s = "#{c} aaa http://www.ru"
|
171
|
-
parse(s).should == "<#{l}><li>aaa <a href=\"http://www.ru\">http://www.ru</a></li></#{l}>"
|
171
|
+
parse(s).should == "<#{l}><li>aaa <a rel=\"nofollow\" href=\"http://www.ru\">http://www.ru</a></li></#{l}>"
|
172
172
|
end
|
173
173
|
it "raw text link inside #{l.upcase}> #2" do
|
174
174
|
s = "#{c} aaa http://www.ru\n#{c} bbb"
|
175
|
-
parse(s).should == "<#{l}><li>aaa <a href=\"http://www.ru\">http://www.ru</a></li><li>bbb</li></#{l}>"
|
175
|
+
parse(s).should == "<#{l}><li>aaa <a rel=\"nofollow\" href=\"http://www.ru\">http://www.ru</a></li><li>bbb</li></#{l}>"
|
176
176
|
end
|
177
177
|
it "raw text link inside #{l.upcase}> #3" do
|
178
178
|
s = "#{c} http://www.ru"
|
179
|
-
parse(s).should == "<#{l}><li><a href=\"http://www.ru\">http://www.ru</a></li></#{l}>"
|
179
|
+
parse(s).should == "<#{l}><li><a rel=\"nofollow\" href=\"http://www.ru\">http://www.ru</a></li></#{l}>"
|
180
180
|
end
|
181
181
|
it "raw text link inside #{l.upcase}> #4" do
|
182
182
|
s = "#{c} aaa http://www.ru bbb"
|
183
|
-
parse(s).should == "<#{l}><li>aaa <a href=\"http://www.ru\">http://www.ru</a> bbb</li></#{l}>"
|
183
|
+
parse(s).should == "<#{l}><li>aaa <a rel=\"nofollow\" href=\"http://www.ru\">http://www.ru</a> bbb</li></#{l}>"
|
184
184
|
end
|
185
185
|
it "two links inside #{l.upcase}>" do
|
186
186
|
s = "#{c} aaa http://www.ru http://ya.ru bbb"
|
187
|
-
parse(s).should == "<#{l}><li>aaa <a href=\"http://www.ru\">http://www.ru</a> <a href=\"http://ya.ru\">http://ya.ru</a> bbb</li></#{l}>"
|
187
|
+
parse(s).should == "<#{l}><li>aaa <a rel=\"nofollow\" href=\"http://www.ru\">http://www.ru</a> <a rel=\"nofollow\" href=\"http://ya.ru\">http://ya.ru</a> bbb</li></#{l}>"
|
188
188
|
end
|
189
189
|
end
|
190
190
|
end
|
@@ -303,34 +303,34 @@ describe 'BreakoutParser' do
|
|
303
303
|
|
304
304
|
describe "raw text links" do
|
305
305
|
it "at the beginning" do
|
306
|
-
parse("http://www.ru").should == "<a href=\"http://www.ru\">http://www.ru</a>"
|
306
|
+
parse("http://www.ru").should == "<a rel=\"nofollow\" href=\"http://www.ru\">http://www.ru</a>"
|
307
307
|
end
|
308
308
|
it "in middle of other words" do
|
309
309
|
parse("aaa bbb ccc http://www.ru ddd eee fff").should ==
|
310
|
-
"aaa bbb ccc <a href=\"http://www.ru\">http://www.ru</a> ddd eee fff"
|
310
|
+
"aaa bbb ccc <a rel=\"nofollow\" href=\"http://www.ru\">http://www.ru</a> ddd eee fff"
|
311
311
|
end
|
312
312
|
it "in new line" do
|
313
313
|
parse("aaa bbb ccc\nhttp://www.ru\nddd eee fff").should match(
|
314
|
-
%r"aaa bbb ccc ?<br /> ?<a href=\"http://www.ru\">http://www.ru</a> ?<br /> ?ddd eee fff"
|
314
|
+
%r"aaa bbb ccc ?<br /> ?<a rel=\"nofollow\" href=\"http://www.ru\">http://www.ru</a> ?<br /> ?ddd eee fff"
|
315
315
|
)
|
316
316
|
end
|
317
317
|
it "escapes '&' in link _text_" do
|
318
|
-
parse("http://www.ru/?a=1&b=2").should == "<a href=\"http://www.ru/?a=1&b=2\">http://www.ru/?a=1&b=2</a>"
|
318
|
+
parse("http://www.ru/?a=1&b=2").should == "<a rel=\"nofollow\" href=\"http://www.ru/?a=1&b=2\">http://www.ru/?a=1&b=2</a>"
|
319
319
|
end
|
320
320
|
|
321
321
|
it "parses https://" do
|
322
|
-
parse("https://www.ru").should == "<a href=\"https://www.ru\">https://www.ru</a>"
|
322
|
+
parse("https://www.ru").should == "<a rel=\"nofollow\" href=\"https://www.ru\">https://www.ru</a>"
|
323
323
|
end
|
324
324
|
|
325
325
|
%w', .'.each do |c|
|
326
326
|
it "stops parsing on \"#{c} \"" do
|
327
|
-
parse("http://www.ru#{c}").should == "<a href=\"http://www.ru\">http://www.ru</a>#{c}"
|
328
|
-
parse(" http://www.ru#{c} ").should == "<a href=\"http://www.ru\">http://www.ru</a>#{c}"
|
329
|
-
parse(" http://www.ru#{c} hello!").should == "<a href=\"http://www.ru\">http://www.ru</a>#{c} hello!"
|
330
|
-
parse("xxx http://www.ru#{c} hello!").should == "xxx <a href=\"http://www.ru\">http://www.ru</a>#{c} hello!"
|
331
|
-
parse(" http://www.ru/#{c} hello!").should == "<a href=\"http://www.ru/\">http://www.ru/</a>#{c} hello!"
|
327
|
+
parse("http://www.ru#{c}").should == "<a rel=\"nofollow\" href=\"http://www.ru\">http://www.ru</a>#{c}"
|
328
|
+
parse(" http://www.ru#{c} ").should == "<a rel=\"nofollow\" href=\"http://www.ru\">http://www.ru</a>#{c}"
|
329
|
+
parse(" http://www.ru#{c} hello!").should == "<a rel=\"nofollow\" href=\"http://www.ru\">http://www.ru</a>#{c} hello!"
|
330
|
+
parse("xxx http://www.ru#{c} hello!").should == "xxx <a rel=\"nofollow\" href=\"http://www.ru\">http://www.ru</a>#{c} hello!"
|
331
|
+
parse(" http://www.ru/#{c} hello!").should == "<a rel=\"nofollow\" href=\"http://www.ru/\">http://www.ru/</a>#{c} hello!"
|
332
332
|
parse(" http://aaa.com#{c} http://bbb.com").should ==
|
333
|
-
"<a href=\"http://aaa.com\">http://aaa.com</a>#{c} <a href=\"http://bbb.com\">http://bbb.com</a>"
|
333
|
+
"<a rel=\"nofollow\" href=\"http://aaa.com\">http://aaa.com</a>#{c} <a rel=\"nofollow\" href=\"http://bbb.com\">http://bbb.com</a>"
|
334
334
|
end
|
335
335
|
end
|
336
336
|
end
|
@@ -572,12 +572,17 @@ describe 'BreakoutParser' do
|
|
572
572
|
a["r:2345"] = '<a href="http://code.assembla.com/test_space/svn/changesets/2345">revision:2345</a>'
|
573
573
|
a["r:2345ef"] = '<a href="http://code.assembla.com/test_space/git/changesets/2345ef">revision:2345ef</a>'
|
574
574
|
|
575
|
-
a["url:http://www.ru"] = '<a href="http://www.ru">http://www.ru</a>'
|
576
|
-
a["url:https://www.ru"] = '<a href="https://www.ru">https://www.ru</a>'
|
577
|
-
a["url:www.ru"] = '<a href="http://www.ru">http://www.ru</a>'
|
578
|
-
a["url:www.ru/?a=1&b=2"] = '<a href="http://www.ru/?a=1&b=2">http://www.ru/?a=1&b=2</a>'
|
579
|
-
a["url:ftp://www.ru"] = '<a href="ftp://www.ru">ftp://www.ru</a>'
|
580
|
-
a["url:/spaces/x2"] = '<a href="/spaces/x2">/spaces/x2</a>'
|
575
|
+
a["url:http://www.ru"] = '<a rel="nofollow" href="http://www.ru">http://www.ru</a>'
|
576
|
+
a["url:https://www.ru"] = '<a rel="nofollow" href="https://www.ru">https://www.ru</a>'
|
577
|
+
a["url:www.ru"] = '<a rel="nofollow" href="http://www.ru">http://www.ru</a>'
|
578
|
+
a["url:www.ru/?a=1&b=2"] = '<a rel="nofollow" href="http://www.ru/?a=1&b=2">http://www.ru/?a=1&b=2</a>'
|
579
|
+
a["url:ftp://www.ru"] = '<a rel="nofollow" href="ftp://www.ru">ftp://www.ru</a>'
|
580
|
+
a["url:/spaces/x2"] = '<a rel="nofollow" href="/spaces/x2">/spaces/x2</a>'
|
581
|
+
|
582
|
+
a["file:ExistingFile.txt"] =
|
583
|
+
'<a href="/spaces/test_space/documents/download/ExistingFile.txt">file:ExistingFile.txt</a>'
|
584
|
+
a["file:cVJUz6ejWr35pEab_qKWB8"] =
|
585
|
+
'<a href="/spaces/test_space/documents/download/cVJUz6ejWr35pEab_qKWB8">file:cVJUz6ejWr35pEab_qKWB8</a>'
|
581
586
|
|
582
587
|
a.each do |k,v|
|
583
588
|
it "parses [[#{k}]]" do
|
@@ -591,7 +596,25 @@ describe 'BreakoutParser' do
|
|
591
596
|
end
|
592
597
|
end
|
593
598
|
|
594
|
-
|
599
|
+
a = {}
|
600
|
+
a["image:ExistingImage.png"] =
|
601
|
+
'<img src="/spaces/test_space/documents/download/ExistingImage.png" alt="ALT" />'
|
602
|
+
a["image:cVJUz6ejWr35pEab_qKWB8"] =
|
603
|
+
'<img src="/spaces/test_space/documents/download/cVJUz6ejWr35pEab_qKWB8" alt="ALT" />'
|
604
|
+
|
605
|
+
a.each do |k,v|
|
606
|
+
it "parses [[#{k}]]" do
|
607
|
+
parse("[[#{k}]]").should == v.sub('ALT',k.sub('image:',''))
|
608
|
+
end
|
609
|
+
it "parses [[#{k}|привет тест]]" do
|
610
|
+
parse("[[#{k}|привет тест]]").should == v.sub('ALT','привет тест')
|
611
|
+
end
|
612
|
+
it "parses [[#{k}|test & here]]" do
|
613
|
+
parse("[[#{k}|test & here]]").should == v.sub('ALT','test & here')
|
614
|
+
end
|
615
|
+
end
|
616
|
+
|
617
|
+
it "ignores unknown link types" do
|
595
618
|
s = "[[zzz:xxx]]"
|
596
619
|
parse(s).should == s
|
597
620
|
s = "[[abcd:1234]]"
|
@@ -600,10 +623,21 @@ describe 'BreakoutParser' do
|
|
600
623
|
parse(s).should == s
|
601
624
|
end
|
602
625
|
|
603
|
-
it "links
|
604
|
-
|
605
|
-
|
606
|
-
|
626
|
+
it "ignores file & image links with forbidden symbols" do
|
627
|
+
s = "[[file:aaa/bbb]]"
|
628
|
+
parse(s).should == s
|
629
|
+
s = "[[file:aaa\\bbb]]"
|
630
|
+
parse(s).should == s
|
631
|
+
s = "[[file:aaa bbb]]"
|
632
|
+
parse(s).should == s
|
633
|
+
|
634
|
+
s = "[[image:aaa/bbb]]"
|
635
|
+
parse(s).should == s
|
636
|
+
s = "[[image:aaa\\bbb]]"
|
637
|
+
parse(s).should == s
|
638
|
+
s = "[[image:aaa bbb]]"
|
639
|
+
parse(s).should == s
|
640
|
+
end
|
607
641
|
end
|
608
642
|
|
609
643
|
###############################################################################
|
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.4
|
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-
|
12
|
+
date: 2010-02-03 00:00:00 +05:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|