summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Allen <dan.j.allen@gmail.com>2019-08-26 23:59:50 -0600
committerDan Allen <dan.j.allen@gmail.com>2019-08-27 00:46:41 -0600
commitbbe83b4ddb788d9bf70faa9a96251bea3ba5e8b5 (patch)
treee8f99ea3330356c2351928f26fc9437a2fa6d1aa
parent2c4554415a40d84d31025e230b1b85ef8362d489 (diff)
add tests for breakable chars in bare URL
-rw-r--r--spec/link_spec.rb33
1 files changed, 33 insertions, 0 deletions
diff --git a/spec/link_spec.rb b/spec/link_spec.rb
index bd4bdc5a..729fdc1e 100644
--- a/spec/link_spec.rb
+++ b/spec/link_spec.rb
@@ -26,6 +26,39 @@ describe 'Asciidoctor::PDF::Converter - Link' do
(expect link[:A][:URI]).to eql input
end
+ it 'should split bare URL on breakable characters' do
+ [
+ 'the URL on this line will get split on the ? char https://github.com/asciidoctor/asciidoctor/issues?|q=milestone%3Av2.0.x',
+ 'the URL on this line will get split on the / char instead https://github.com/asciidoctor/asciidoctor/|issues?q=milestone%3Av2.0.x',
+ 'the URL on this line will get split on the # char https://github.com/asciidoctor/asciidoctor/issues#|milestone%3Av2.0.x',
+ ].each do |text|
+ before, after = text.split '|', 2
+ pdf = to_pdf %(#{before}#{after}), analyze: true
+ lines = pdf.lines
+ (expect lines).to have_size 2
+ (expect lines[0]).to end_with before
+ (expect lines[1]).to start_with after
+ end
+ end
+
+ it 'should not split bare URL when using an AFM font' do
+ pdf = to_pdf <<~'EOS', pdf_theme: { base_font_family: 'Helvetica' }, analyze: true
+ this line contains a URL that falls at the end of the line and yet cannot be split https://goo.gl/search/asciidoctor
+ EOS
+ lines = pdf.lines
+ (expect lines).to have_size 2
+ (expect lines[1]).to eql 'https://goo.gl/search/asciidoctor'
+ end
+
+ it 'should not split bare URL after scheme' do
+ pdf = to_pdf <<~'EOS', analyze: true
+ this line contains a URL that falls at the end of the line that is not split after the scheme https://goo.gl/search/asciidoctor
+ EOS
+ lines = pdf.lines
+ (expect lines).to have_size 2
+ (expect lines[1]).to eql 'https://goo.gl/search/asciidoctor'
+ end
+
it 'should reveal URL of link when media=print or media=prepress' do
%w(print prepress).each do |media|
pdf = to_pdf <<~'EOS', attribute_overrides: { 'media' => 'print' }, analyze: true