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 +4 -4
- data/lib/jekyll/footnotes.rb +20 -2
- data/lib/jekyll/footnotes/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 580328fc34fc9a2adf42b30edd151ce1012b0f56
|
4
|
+
data.tar.gz: a5fe5d1540f2aa96fcfc9796855f3bbad469df8f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 82366a728069f473c22c360a779712e4b0a94aa6902bd61a438ee1458506900a4eb206d4299ea82866d0fde62328ef14404c32471a11ae678785a7597576774a
|
7
|
+
data.tar.gz: a970574d61db81312f6ab8ab93b2203600d2b413dbe9ec56268009a155f7080cf010d872243b57f60ae8b2fae3cb8907840fd78ee25e04deb01eae060ccd04cd
|
data/lib/jekyll/footnotes.rb
CHANGED
@@ -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=\"#
|
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=\"
|
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
|