jekyll-footnotes 0.5.2 → 0.6.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: b506c54b4e377c619dc25355f156eb28dc163b6c
4
- data.tar.gz: a4a33937ede54328432563158113dedab719070e
3
+ metadata.gz: 580328fc34fc9a2adf42b30edd151ce1012b0f56
4
+ data.tar.gz: a5fe5d1540f2aa96fcfc9796855f3bbad469df8f
5
5
  SHA512:
6
- metadata.gz: 5ad16e96982c317d88e123ee9833f1c320815e087b49df92d0b12459bbc3e57fdd818c680b003f72eb770ffe10df69ea34ef408db1239beed8d5ddab45e7e429
7
- data.tar.gz: 495e0b54ba9daa4e78cb4eaa51758faced03ff9df5143dda4956dc142dba8e139bf1e2bacab815aae30a659bb0388cea45d3b1ca23bc3eb32229d0684b855e25
6
+ metadata.gz: 82366a728069f473c22c360a779712e4b0a94aa6902bd61a438ee1458506900a4eb206d4299ea82866d0fde62328ef14404c32471a11ae678785a7597576774a
7
+ data.tar.gz: a970574d61db81312f6ab8ab93b2203600d2b413dbe9ec56268009a155f7080cf010d872243b57f60ae8b2fae3cb8907840fd78ee25e04deb01eae060ccd04cd
@@ -1,7 +1,23 @@
1
1
  require "jekyll/footnotes/version"
2
2
 
3
+ module FootnoteUtils
4
+ def page_hash(page)
5
+ page['url'].hash.to_s(16)[-4,4]
6
+ end
7
+
8
+ def footnote_id(context, id)
9
+ "#{page_hash(context.registers[:page])}:fn:#{id}"
10
+ end
11
+
12
+ def backlink_id(context, id)
13
+ "#{page_hash(context.registers[:page])}:fn-back:#{id}"
14
+ end
15
+ end
16
+
3
17
  module Jekyll
4
18
  class FootnoteTag < Liquid::Tag
19
+ include FootnoteUtils
20
+
5
21
  def initialize(tag_name, id, tokens)
6
22
  raise(SyntaxError.new("invalid footnote ID")) if ['"', '<', '>'].any? { |c| id.include?(c) }
7
23
  @id = id.strip unless id.strip.empty?
@@ -14,11 +30,13 @@ module Jekyll
14
30
  context.registers[:fn] = context.registers[:fn].next
15
31
  @id = context.registers[:fn]
16
32
  end
17
- "<sup><a href=\"#fn:#{@id}\" class=\"footnote\" id=\"fn-back:#{@id}\">#{@id}</a></sup>"
33
+ "<sup><a href=\"#{footnote_id(context, @id)}\" class=\"footnote\" id=\"#{backlink_id(context, @id)}\">#{@id}</a></sup>"
18
34
  end
19
35
  end
20
36
 
21
37
  class FootnoteBody < Liquid::Block
38
+ include FootnoteUtils
39
+
22
40
  def initialize(tag_name, id, tokens)
23
41
  raise(SyntaxError.new("invalid footnote ID")) if ['"', '<', '>'].any? { |c| id.include?(c) }
24
42
  @id = id.strip unless id.strip.empty?
@@ -33,7 +51,7 @@ module Jekyll
33
51
  end
34
52
  context.stack do
35
53
  body = super
36
- "<li id=\"fn:#{@id}\" class=\"footnotebody\" value=\"#{@id}\">#{body}<a href=\"#fn-back:#{@id}\" class=\"backlink\">⏎</a></li>"
54
+ "<li id=\"#{footnote_id(context, @id)}\" class=\"footnotebody\" value=\"#{@id}\">#{body}<a href=\"##{backlink_id(context, @id)}\" class=\"backlink\">⏎</a></li>"
37
55
  end
38
56
  end
39
57
  end
@@ -1,5 +1,5 @@
1
1
  module Jekyll
2
2
  module Footnotes
3
- VERSION = "0.5.2"
3
+ VERSION = "0.6.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-footnotes
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julian Simioni