jekyll-references 1.0.2 → 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 +1 -1
- metadata +2 -1
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)
|
data/lib/jekyll-references.rb
CHANGED
@@ -301,7 +301,7 @@ module Jekyll
|
|
301
301
|
output = "<h2>#{@title}</h2>\n"
|
302
302
|
output += "<ol>\n"
|
303
303
|
refs.each do |r|
|
304
|
-
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"
|
305
305
|
end
|
306
306
|
output += "</ol>"
|
307
307
|
# Return output
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
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
|
@@ -29,6 +29,7 @@ executables: []
|
|
29
29
|
extensions: []
|
30
30
|
extra_rdoc_files: []
|
31
31
|
files:
|
32
|
+
- lib/jekyll-cite.rb
|
32
33
|
- lib/jekyll-references.rb
|
33
34
|
homepage: https://github.com/Nereare/jekyll-references/
|
34
35
|
licenses:
|