jekyll-relative-links 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/jekyll-relative-links/generator.rb +9 -4
- data/lib/jekyll-relative-links/version.rb +1 -1
- 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: ba6b38e69cda482b2142b9e88772c64963323a21
|
4
|
+
data.tar.gz: 34303fa94a455987bee54fdac2f78a785a968c86
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2e8ed38db685fc82e2aafe3a8e32f6c296c38681548873efaa07487b2d480afcbbf46e33b95580c4bb50854050fb28faf9313452ffafe077a1a53f2cdc345861
|
7
|
+
data.tar.gz: 50630b46713f52d82ef9ee4c4cd17f4a7e1b87d85b2bcab7747e93c94164427709935cb2ff3d29d1fcc4ccd3da0b4e50bca4a634694d13e1fd23bd41ed4b002a
|
@@ -5,8 +5,10 @@ module JekyllRelativeLinks
|
|
5
5
|
# Use Jekyll's native relative_url filter
|
6
6
|
include Jekyll::Filters::URLFilters
|
7
7
|
|
8
|
-
|
9
|
-
|
8
|
+
LINK_TEXT_REGEX = %r!([^\]]+)!
|
9
|
+
FRAGMENT_REGEX = %r!(#.+)?!
|
10
|
+
INLINE_LINK_REGEX = %r!\[#{LINK_TEXT_REGEX}\]\(([^\)]+?)#{FRAGMENT_REGEX}\)!
|
11
|
+
REFERENCE_LINK_REGEX = %r!^\[#{LINK_TEXT_REGEX}\]: (.+?)#{FRAGMENT_REGEX}$!
|
10
12
|
LINK_REGEX = %r!(#{INLINE_LINK_REGEX}|#{REFERENCE_LINK_REGEX})!
|
11
13
|
CONVERTER_CLASS = Jekyll::Converters::Markdown
|
12
14
|
|
@@ -28,12 +30,15 @@ module JekyllRelativeLinks
|
|
28
30
|
|
29
31
|
page.content.gsub!(LINK_REGEX) do |original|
|
30
32
|
link_type = Regexp.last_match(2) ? :inline : :reference
|
31
|
-
link_text = Regexp.last_match(link_type == :inline ? 2 :
|
32
|
-
relative_path = Regexp.last_match(link_type == :inline ? 3 :
|
33
|
+
link_text = Regexp.last_match(link_type == :inline ? 2 : 5)
|
34
|
+
relative_path = Regexp.last_match(link_type == :inline ? 3 : 6)
|
35
|
+
fragment = Regexp.last_match(link_type == :inline ? 4 : 7)
|
36
|
+
|
33
37
|
relative_path.sub!(%r!\A/!, "")
|
34
38
|
url = url_for_path(path_from_root(relative_path, url_base))
|
35
39
|
|
36
40
|
if url
|
41
|
+
url << fragment if fragment
|
37
42
|
replacement_text(link_type, link_text, url)
|
38
43
|
else
|
39
44
|
original
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-relative-links
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Balter
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-01-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|