#!/usr/bin/env ruby # encoding: utf-8 BEGIN { require 'pathname' basedir = Pathname.new( __FILE__ ).dirname.parent.parent libdir = basedir + 'lib' extdir = basedir + 'ext' $LOAD_PATH.unshift( libdir ) unless $LOAD_PATH.include?( libdir ) $LOAD_PATH.unshift( extdir ) unless $LOAD_PATH.include?( extdir ) } require 'spec' require 'bluecloth' require 'spec/lib/helpers' require 'spec/lib/constants' require 'spec/lib/matchers' ##################################################################### ### C O N T E X T S ##################################################################### describe BlueCloth, "links" do include BlueCloth::TestConstants, BlueCloth::Matchers it "supports inline links" do the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation An [example](http://url.com/). ---

An example.

--- end it "supports inline link with a title" do the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation An [example](http://url.com/ "Check out url.com!"). ---

An example.

--- end it "supports reference-style links with no title" do the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation An [example][ex] reference-style link. [ex]: http://www.bluefi.com/ ---

An example reference-style link.

--- end it "supports indented (less than tabwidth) reference-style links" do the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation An [example][ex] reference-style link. [ex]: http://www.bluefi.com/ ---

An example reference-style link.

--- end it "supports reference-style links with quoted titles" do the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation An [example][ex] reference-style link. [ex]: http://www.bluefi.com/ "Check out our air." ---

An example reference-style link.

--- end it "supports reference-style links with paren titles" do the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation An [example][ex] reference-style link. [ex]: http://www.bluefi.com/ (Check out our air.) ---

An example reference-style link.

--- end it "supports reference-style links with intervening spaces" do the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation You can split the [linked part] [ex] from the reference part with a single space. [ex]: http://www.treefrog.com/ "for some reason" ---

You can split the linked part from the reference part with a single space.

--- end it "supports reference-style links with intervening spaces" do the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation You can split the [linked part] [ex] from the reference part with a newline in case your editor wraps it there, I guess. [ex]: http://www.treefrog.com/ ---

You can split the linked part from the reference part with a newline in case your editor wraps it there, I guess.

--- end it "supports reference-style anchors" do the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation I get 10 times more traffic from [Google] [1] than from [Yahoo] [2] or [MSN] [3]. [1]: http://google.com/ "Google" [2]: http://search.yahoo.com/ "Yahoo Search" [3]: http://search.msn.com/ "MSN Search" ---

I get 10 times more traffic from Google than from Yahoo or MSN.

--- end it "supports implicit name-link shortcut anchors" do the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation I get 10 times more traffic from [Google][] than from [Yahoo][] or [MSN][]. [google]: http://google.com/ "Google" [yahoo]: http://search.yahoo.com/ "Yahoo Search" [msn]: http://search.msn.com/ "MSN Search" ---

I get 10 times more traffic from Google than from Yahoo or MSN.

--- end it "supports inline anchors" do the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation I get 10 times more traffic from [Google](http://google.com/ "Google") than from [Yahoo](http://search.yahoo.com/ "Yahoo Search") or [MSN](http://search.msn.com/ "MSN Search"). ---

I get 10 times more traffic from Google than from Yahoo or MSN.

--- end it "fails gracefully for unclosed brackets (and bug #524)" do the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation This is just a [bracket opener; it should fail gracefully. ---

This is just a [bracket opener; it should fail gracefully.

--- end it "fails gracefully for unresolved reference-style links (Bug #620)" do the_indented_markdown( <<-"---" ).should be_transformed_into(<<-"---").without_indentation This is an unresolved [url][1]. ---

This is an unresolved [url][1].

--- end end