jekyll-references 1.0.1 → 1.1.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-cite.rb +35 -0
- data/lib/{jekyll/references.rb → jekyll-references.rb} +2 -1
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b340ee3aec1cbf05b3215ca6449d585daed2a5899b0ab149e776aa416e8f77db
|
4
|
+
data.tar.gz: e7784c0a82b3836297efa64f899521a139a0db47f1e6a9f8dcd9913c6ad1ccec
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4e2d3e4fa588121507eb3e201e70280d69bc0185fc96790303775cfab3453f990f682b51f19d6b81af47e2338f5d6081795d7a4ccbc6bfaee139dbffd97907a8
|
7
|
+
data.tar.gz: fa512b653ad7afea9e67304cb9f562e87271faf4fb7cc6e53d930b14b27a0c65b75f33d08f3da38cb44b6d88debbef1551f395942473aa3e0fba5c3df7a3ed82
|
data/lib/jekyll-cite.rb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'jekyll'
|
4
|
+
|
5
|
+
module Jekyll
|
6
|
+
class CiteTag < Liquid::Tag
|
7
|
+
def initialize(tag_name, text, tokens)
|
8
|
+
super
|
9
|
+
@ref = text
|
10
|
+
end
|
11
|
+
|
12
|
+
def render(context)
|
13
|
+
# Retrieve references from page
|
14
|
+
refs = context.registers[:page]["references"]
|
15
|
+
# Parse references to contain only the IDs
|
16
|
+
refs.map! { |ref| ref[0] }
|
17
|
+
|
18
|
+
# Build output
|
19
|
+
output = ''
|
20
|
+
# Check if index exists
|
21
|
+
if refs.index(@ref).nil?
|
22
|
+
# If it does not exist, set to question mark with no link
|
23
|
+
output = '<sup>?</sup>'
|
24
|
+
else
|
25
|
+
# If it does exist
|
26
|
+
output = "<sup><a href=\"#ref-#{@ref}\">#{refs.index(@ref) + 1}</a></sup>"
|
27
|
+
end
|
28
|
+
|
29
|
+
# Return output
|
30
|
+
output
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
Liquid::Template.register_tag('cite', Jekyll::CiteTag)
|
@@ -1,5 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'jekyll'
|
3
4
|
require 'open-uri'
|
4
5
|
|
5
6
|
module Jekyll
|
@@ -300,7 +301,7 @@ module Jekyll
|
|
300
301
|
output = "<h2>#{@title}</h2>\n"
|
301
302
|
output += "<ol>\n"
|
302
303
|
refs.each do |r|
|
303
|
-
output += "<li>#{parse_ref(r[1], ref_style, ref_lang)}</li>\n"
|
304
|
+
output += "<li id=\"ref-#{r[0]}\">#{parse_ref(r[1], ref_style, ref_lang)}</li>\n"
|
304
305
|
end
|
305
306
|
output += "</ol>"
|
306
307
|
# Return output
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-references
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Igor Padoim
|
8
8
|
bindir: bin
|
9
9
|
cert_chain: []
|
10
|
-
date:
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: jekyll
|
@@ -29,7 +29,8 @@ executables: []
|
|
29
29
|
extensions: []
|
30
30
|
extra_rdoc_files: []
|
31
31
|
files:
|
32
|
-
- lib/jekyll
|
32
|
+
- lib/jekyll-cite.rb
|
33
|
+
- lib/jekyll-references.rb
|
33
34
|
homepage: https://github.com/Nereare/jekyll-references/
|
34
35
|
licenses:
|
35
36
|
- WTFPL
|
@@ -51,7 +52,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
51
52
|
- !ruby/object:Gem::Version
|
52
53
|
version: '0'
|
53
54
|
requirements: []
|
54
|
-
rubygems_version: 3.6.
|
55
|
+
rubygems_version: 3.6.8
|
55
56
|
specification_version: 4
|
56
57
|
summary: Create Liquid tags to parse and show reference lists
|
57
58
|
test_files: []
|