jekyll-relative-links 0.2.1 → 0.3.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b6ea6cba87dad0f4eaec305aaa85d69f4b7c267f
4
- data.tar.gz: 6554e0b5ecc56d149d39e10fe5e99bbd0f001998
3
+ metadata.gz: ba6b38e69cda482b2142b9e88772c64963323a21
4
+ data.tar.gz: 34303fa94a455987bee54fdac2f78a785a968c86
5
5
  SHA512:
6
- metadata.gz: d3a3761180dccea9dd4fc8cd4ff5631b115c58773c29cfa4a1dcfe4244ac731a28d0517515427d1d22159dac61cdaad1d43b66696ecc83fdf03f64a5da2c898e
7
- data.tar.gz: f8afc458f03896602b6865d42ed515501c0f76a1ba8568fc53b3ffb0eeb1c2edf78b2388ad0b88199e8cfdb689fc85633370456d3c410bcd33bcdca177422e5b
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
- INLINE_LINK_REGEX = %r!\[([^\]]+)\]\(([^\)]+)\)!
9
- REFERENCE_LINK_REGEX = %r!^\[([^\]]+)\]: (.*)$!
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 : 4)
32
- relative_path = Regexp.last_match(link_type == :inline ? 3 : 5)
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
@@ -1,3 +1,3 @@
1
1
  module JekyllRelativeLinks
2
- VERSION = "0.2.1".freeze
2
+ VERSION = "0.3.0".freeze
3
3
  end
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.2.1
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: 2016-12-05 00:00:00.000000000 Z
11
+ date: 2017-01-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll