reverse_markdown 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c57772b3497c7c256052c61ccd42a3c003671429
4
- data.tar.gz: 2e90d7b68ce83784464dab7b3500b4a3fb5e22a8
3
+ metadata.gz: cfe67b1140e4f13da9e0503b72acc88379eb2be8
4
+ data.tar.gz: 0a7b5bcd1dba92dfef90949ea3e1655aca425f04
5
5
  SHA512:
6
- metadata.gz: 6ece1678de088490e0e1442f9deeee55cc5346c2e8573643fdc628f298efe689ce145f0b87a04d1ed927784bcf452e3ecfc3751c861e747d1d96d76fcfec4d4d
7
- data.tar.gz: 963b8984561fdea0eb8f7757ce1a727fdc6c0e7a7964a012e15844ca210988714232af08568c25d838d382de6a348f9b119187bfdcbb3a230110fbbb41bb1472
6
+ metadata.gz: 527a69664f9295f83f9ebaad8a3eda7f0a3b747012f0a67215d5b681d2de348ef135cbb0afcaa6f34c5e7c19c68e686b3b6006c497cfad9a66c5e5d1a01cbe60
7
+ data.tar.gz: 64784b22edb4a81bed4f34bdb5d1553422f9b1d2633f5df157e62a6c875e8735048fa94c6e8dcdc08aa6c3927a85a2ff3010d061d084b335712ec29fb1a6481b
data/CHANGELOG.md CHANGED
@@ -1,6 +1,10 @@
1
1
  # Change Log
2
2
  All notable changes to this project will be documented in this file.
3
3
 
4
+ ## 1.0.2 - Apr 2016
5
+ ### Changes
6
+ - Handle edge case: exclamation mark before links, thanks @Easy-D (#57)
7
+
4
8
  ## 1.0.1 - Jan 2016
5
9
  ### Changes
6
10
  - Prevent double escaping of * and _, thanks @craig-day (#61)
@@ -9,9 +9,17 @@ module ReverseMarkdown
9
9
  if href.to_s.start_with?('#') || href.to_s.empty? || name.empty?
10
10
  name
11
11
  else
12
- " [#{name}](#{href}#{title})"
12
+ link = "[#{name}](#{href}#{title})"
13
+ link.prepend(' ') if prepend_space?(node)
14
+ link
13
15
  end
14
16
  end
17
+
18
+ private
19
+
20
+ def prepend_space?(node)
21
+ node.at_xpath("preceding::text()[1]").to_s.end_with?('!')
22
+ end
15
23
  end
16
24
 
17
25
  register :a, A.new
@@ -1,3 +1,3 @@
1
1
  module ReverseMarkdown
2
- VERSION = '1.0.1'
2
+ VERSION = '1.0.2'
3
3
  end
@@ -4,7 +4,9 @@
4
4
  <a href="http://foobar.com">Foobar</a>
5
5
  <a href="http://foobar.com" title="f***** up beyond all recognition">Fubar</a>
6
6
  <a href="http://strong.foobar.com"><strong>Strong foobar</strong></a>
7
- Period after the anchor: there shouldn't be an extra space after the <a href="http://foobar.com">anchor</a>. But inline, <a href="http://foobar.com">there</a> should be a space.
7
+ There should be no extra space before and after the anchor (<a href="http://foobar.com">stripped</a>).
8
+ Exception: after an !<a href="http://not.an.image.foobar.com">there</a> should be an extra space.
9
+ Even with stripped elements inbetween: !<span><a href="http://still.not.an.image.foobar.com">there</a></span> should be an extra space.
8
10
 
9
11
  ignore <a href="foo.html"> </a> anchor tags with no link text
10
12
  not ignore <a href="foo.html"><img src="image.png" alt="An Image" /></a> anchor tags with images
@@ -6,15 +6,16 @@ describe ReverseMarkdown do
6
6
  let(:document) { Nokogiri::HTML(input) }
7
7
  subject { ReverseMarkdown.convert(input) }
8
8
 
9
- it { is_expected.to include ' [Foobar](http://foobar.com) ' }
10
- it { is_expected.to include ' [Fubar](http://foobar.com "f\*\*\*\*\* up beyond all recognition") ' }
11
- it { is_expected.to include ' [**Strong foobar**](http://strong.foobar.com) ' }
9
+ it { is_expected.to include '[Foobar](http://foobar.com)' }
10
+ it { is_expected.to include '[Fubar](http://foobar.com "f\*\*\*\*\* up beyond all recognition")' }
11
+ it { is_expected.to include '[**Strong foobar**](http://strong.foobar.com)' }
12
12
 
13
13
  it { is_expected.to include ' ![](http://foobar.com/logo.png) ' }
14
14
  it { is_expected.to include ' ![foobar image](http://foobar.com/foobar.png) ' }
15
15
  it { is_expected.to include ' ![foobar image 2](http://foobar.com/foobar2.png "this is the foobar image 2") ' }
16
- it { is_expected.to include 'extra space after the [anchor](http://foobar.com).'}
17
- it { is_expected.to include 'But inline, [there](http://foobar.com) should be a space.'}
16
+ it { is_expected.to include 'no extra space before and after the anchor ([stripped](http://foobar.com)).'}
17
+ it { is_expected.to include 'after an ! [there](http://not.an.image.foobar.com) should be an extra space.'}
18
+ it { is_expected.to include 'with stripped elements inbetween: ! [there](http://still.not.an.image.foobar.com) should be an extra space.'}
18
19
 
19
20
  context "links to ignore" do
20
21
  it { is_expected.to include ' ignore anchor tags with no link text ' }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: reverse_markdown
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Johannes Opper
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-01-29 00:00:00.000000000 Z
11
+ date: 2016-04-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri