reverse_markdown 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/reverse_markdown/converters/a.rb +9 -1
- data/lib/reverse_markdown/version.rb +1 -1
- data/spec/assets/anchors.html +3 -1
- data/spec/components/anchors_spec.rb +6 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cfe67b1140e4f13da9e0503b72acc88379eb2be8
|
4
|
+
data.tar.gz: 0a7b5bcd1dba92dfef90949ea3e1655aca425f04
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
"
|
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
|
data/spec/assets/anchors.html
CHANGED
@@ -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
|
-
|
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 '
|
10
|
-
it { is_expected.to include '
|
11
|
-
it { is_expected.to include '
|
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 '  ' }
|
14
14
|
it { is_expected.to include '  ' }
|
15
15
|
it { is_expected.to include '  ' }
|
16
|
-
it { is_expected.to include 'extra space after the [
|
17
|
-
it { is_expected.to include '
|
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.
|
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-
|
11
|
+
date: 2016-04-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|