relaton-render 1.0.3 → 1.0.4
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
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1473c5dc29146f1092fab77dda408f5bc0e15891991f6ecb54775625028d62d2
|
|
4
|
+
data.tar.gz: c2008fe936003b2304fd437f3f19983ea6c64041d4442cdfd855e439a1f73965
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: '093e82b2f66e172221a6846a59f49d75f1a0e638c0cb7900f9d0e2395f49b196824c24dddb29aeab08280f48935db93fc8fffb3d927392e5903623562291713f'
|
|
7
|
+
data.tar.gz: 1761156e4dba5d2d5ae43081a6e83b117aeb4a5e5c9c06e0099bfe98e7889e2e28a4d29a618a0f7d62593662da49bc6d18de4c13d1f852d5fd54da580a94a83e
|
|
@@ -94,8 +94,8 @@ module Relaton
|
|
|
94
94
|
i = @i18n.select(b[:data])
|
|
95
95
|
b[:citation][:default] =
|
|
96
96
|
i.l10n(b[:data][:authoritative_identifier]&.first || "")
|
|
97
|
-
b[:
|
|
98
|
-
|
|
97
|
+
d = b[:data].merge(citestyle: "short")
|
|
98
|
+
b[:citation][:short] = i.l10n(renderer(b).citeshorttemplate.render(d, d))
|
|
99
99
|
citations_iterate_cite_styles(b, i)
|
|
100
100
|
end
|
|
101
101
|
ret
|
|
@@ -48,7 +48,6 @@ module Relaton
|
|
|
48
48
|
# ...[0], ...[1], ...[2]
|
|
49
49
|
def expand_nametemplate(template, size)
|
|
50
50
|
t = nametemplate_split(template)
|
|
51
|
-
|
|
52
51
|
mid = (1..size - 2).each_with_object([]) do |i, m|
|
|
53
52
|
m << t[1].gsub("[1]", "[#{i}]")
|
|
54
53
|
end
|
|
@@ -68,6 +67,7 @@ module Relaton
|
|
|
68
67
|
def nametemplate_split(template)
|
|
69
68
|
curr = 0
|
|
70
69
|
prec = ""
|
|
70
|
+
@in_name = 0
|
|
71
71
|
t = template.split(/(\{[{%][^{]+?[}%]\})/)
|
|
72
72
|
.each_with_object([""]) do |n, m|
|
|
73
73
|
m, curr, prec = nametemplate_split1(n, m, curr, prec)
|
|
@@ -79,6 +79,9 @@ module Relaton
|
|
|
79
79
|
|
|
80
80
|
def nametemplate_split1(elem, acc, curr, prec)
|
|
81
81
|
if match = /\{[{%].+?\[(\d)\]/.match(elem)
|
|
82
|
+
# we are in a name component
|
|
83
|
+
# if an if is started, track the if nesting...
|
|
84
|
+
@in_name += 1 if /\{%\s*if/.match?(elem)
|
|
82
85
|
if match[1].to_i > curr
|
|
83
86
|
curr += 1
|
|
84
87
|
acc[curr] ||= ""
|
|
@@ -86,7 +89,10 @@ module Relaton
|
|
|
86
89
|
acc[curr] += prec
|
|
87
90
|
prec = ""
|
|
88
91
|
acc[curr] += elem
|
|
89
|
-
elsif /\{%\s*endif/.match?(elem)
|
|
92
|
+
elsif /\{%\s*endif/.match?(elem) && @in_name.positive?
|
|
93
|
+
# stick the endif to the currently if-nested name component,
|
|
94
|
+
# if we are in one (@in_name.positive?)
|
|
95
|
+
@in_name -= 1
|
|
90
96
|
acc[curr] += prec
|
|
91
97
|
prec = ""
|
|
92
98
|
acc[curr] += elem
|
|
@@ -115,10 +115,12 @@ module Relaton
|
|
|
115
115
|
# potentially enhanced
|
|
116
116
|
def render(hash, context)
|
|
117
117
|
t = template_select(hash) or return nil # TODO select on context?
|
|
118
|
-
i = @i18n.select(context)
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
118
|
+
i = @i18n.select(context)
|
|
119
|
+
i18nsettings = { "labels" => i.get, "lang" => i.lang,
|
|
120
|
+
"script" => i.script, "locale" => i.locale }
|
|
121
|
+
ret = template_clean(t.render(liquid_hash(hash.merge(i18nsettings))))
|
|
122
|
+
bib_delim = i.get.dig("punct", "biblio-field-delimiter") || ". "
|
|
123
|
+
template_components(ret, bib_delim, context)
|
|
122
124
|
end
|
|
123
125
|
|
|
124
126
|
def template_select(_hash)
|
|
@@ -172,17 +174,23 @@ module Relaton
|
|
|
172
174
|
# Do not strip any delimiters from final field in string
|
|
173
175
|
#
|
|
174
176
|
# if delim = ". " , then: ({{ series }}$$$|) => (series1.)
|
|
175
|
-
def template_components(str, delim)
|
|
177
|
+
def template_components(str, delim, context)
|
|
176
178
|
str or return str
|
|
177
179
|
delimrstrip, delimre, delimrstripre = template_components_prep(delim)
|
|
180
|
+
ret = template_components_split(str, delimre)
|
|
181
|
+
delim != delimrstrip and # "." in field followed by ". " in delim
|
|
182
|
+
ret = remove_double_period(ret, delimrstripre)
|
|
183
|
+
context[:citestyle] == "short" and
|
|
184
|
+
ret[0] += "<span class='fmt-first-biblio-delim'/>"
|
|
185
|
+
ret.join(delim).gsub(/#{delim}\|/, delimrstrip)
|
|
186
|
+
end
|
|
187
|
+
|
|
188
|
+
def template_components_split(str, delimre)
|
|
178
189
|
ret = str.gsub(NON_SPACING_DELIM, "|").split(/#{COMPONENT_DELIM}/o)
|
|
179
190
|
.map(&:strip).reject(&:empty?)
|
|
180
|
-
ret
|
|
191
|
+
ret[0...-1].map do |s|
|
|
181
192
|
s.sub(/#{delimre}$/, "").sub(%r[#{delimre}(</[^>]+>)$], "\\1")
|
|
182
193
|
end + [ret.last]
|
|
183
|
-
delim != delimrstrip and # "." in field followed by ". " in delim
|
|
184
|
-
ret = remove_double_period(ret, delimrstripre)
|
|
185
|
-
ret.join(delim).gsub(/#{delim}\|/, delimrstrip)
|
|
186
194
|
end
|
|
187
195
|
|
|
188
196
|
def remove_double_period(ret, delimrstripre)
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: relaton-render
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.0.
|
|
4
|
+
version: 1.0.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ribose Inc.
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2026-02-16 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|