relaton-bib 1.11.5 → 1.11.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/relaton_bib/localized_string.rb +58 -1
- data/lib/relaton_bib/version.rb +1 -1
- data/lib/relaton_bib/xml_parser.rb +1 -1
- data/lib/relaton_bib.rb +1 -0
- data/relaton-bib.gemspec +1 -0
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b67e36718ab80cde1c79a95f8233240641a49ef1faacadf94816d19f4d410b48
|
4
|
+
data.tar.gz: 63caef369d95e108ab09ecfb266db82528e76f29c3107f5ebb5b5a6ce3f6eab5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 680f63959cde0cb1f151ae84afcf41696e52ba7c4777b84415b22f50a10c32d188e471a4c5d5bce2922326c76889a7402f3105c192004a4d94ed3aa1de8b07aa
|
7
|
+
data.tar.gz: c5d7df8e301a1518b1acdd2ca5dc5ae7bd88b24d0464b5e0428a41a446e660fac58f6658a992cbfc17369ca9986a7460cee0ffbfd606b690c53eb1df55f743e8
|
@@ -56,10 +56,67 @@ module RelatonBib
|
|
56
56
|
else
|
57
57
|
builder.parent["language"] = language.join(",") if language&.any?
|
58
58
|
builder.parent["script"] = script.join(",") if script&.any?
|
59
|
-
builder.
|
59
|
+
builder.parent.inner_html = encode content
|
60
60
|
end
|
61
61
|
end
|
62
62
|
|
63
|
+
#
|
64
|
+
# Encode content.
|
65
|
+
#
|
66
|
+
# @param [String] cnt content
|
67
|
+
#
|
68
|
+
# @return [String] encoded content
|
69
|
+
#
|
70
|
+
def encode(cnt) # rubocop:disable Metrics/MethodLength
|
71
|
+
regex = /(?<prf>.*?)(?<xml><(?<tag>\w+)>.*<\/\k<tag>>)(?<sfx>.*)/m
|
72
|
+
if cnt.match(regex)
|
73
|
+
prf = Regexp.last_match(:prf).lstrip
|
74
|
+
xml = Regexp.last_match[:xml]
|
75
|
+
sfx = Regexp.last_match(:sfx).rstrip
|
76
|
+
parts = xml.scan(/\s*<(?<tago>\w+)>(?<cnt1>.*?)(?=<\/?\w+>)|(?<cnt2>.*?)<\/(?<tagc>\w+)>/)
|
77
|
+
out = scan_xml parts
|
78
|
+
"#{escp(prf)}#{out}#{escp(sfx)}"
|
79
|
+
else
|
80
|
+
escp cnt
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
#
|
85
|
+
# Scan XML and escape HTML entities.
|
86
|
+
#
|
87
|
+
# @param [Array<Array<String,nik>>] parts XML parts
|
88
|
+
#
|
89
|
+
# @return [String] output string
|
90
|
+
#
|
91
|
+
def scan_xml(parts) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity,Metrics/MethodLength
|
92
|
+
return "" unless parts.any? && parts.first[0]
|
93
|
+
|
94
|
+
tago, cnt1, = parts.shift
|
95
|
+
if tago && tago == parts.first[3]
|
96
|
+
_, _, cnt2, tagc = parts.shift
|
97
|
+
"<#{tago}>#{escp(cnt1)}#{escp(cnt2)}</#{tagc}>"
|
98
|
+
elsif tago
|
99
|
+
inr = scan_xml parts
|
100
|
+
_, _, cnt2, tagc = parts.shift
|
101
|
+
if tago == tagc
|
102
|
+
"<#{tago}>#{escp(cnt1)}#{inr}#{escp(cnt2)}</#{tagc}>"
|
103
|
+
else
|
104
|
+
"#{escp("<#{tago}>#{cnt1}")}#{inr}#{escp("#{cnt2}</#{tagc}>")}"
|
105
|
+
end
|
106
|
+
end + scan_xml(parts)
|
107
|
+
end
|
108
|
+
|
109
|
+
#
|
110
|
+
# Escope HTML entities.
|
111
|
+
#
|
112
|
+
# @param [String] str input string
|
113
|
+
#
|
114
|
+
# @return [String] output string
|
115
|
+
#
|
116
|
+
def escp(str)
|
117
|
+
HTMLEntities.new.encode str
|
118
|
+
end
|
119
|
+
|
63
120
|
# @return [Hash]
|
64
121
|
def to_hash # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
|
65
122
|
if content.is_a? String
|
data/lib/relaton_bib/version.rb
CHANGED
@@ -354,7 +354,7 @@ module RelatonBib
|
|
354
354
|
# @return [Array<RelatonBib::FormattedString>]
|
355
355
|
def fetch_abstract(item)
|
356
356
|
item.xpath("./abstract").map do |a|
|
357
|
-
c = a.
|
357
|
+
c = a.inner_html(encoding: "utf-8").strip
|
358
358
|
FormattedString.new(content: c, language: a[:language],
|
359
359
|
script: a[:script], format: a[:format])
|
360
360
|
end
|
data/lib/relaton_bib.rb
CHANGED
data/relaton-bib.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: relaton-bib
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.11.
|
4
|
+
version: 1.11.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-05-
|
11
|
+
date: 2022-05-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: byebug
|
@@ -164,6 +164,20 @@ dependencies:
|
|
164
164
|
- - ">="
|
165
165
|
- !ruby/object:Gem::Version
|
166
166
|
version: '0'
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: htmlentities
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - ">="
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '0'
|
174
|
+
type: :runtime
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - ">="
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '0'
|
167
181
|
- !ruby/object:Gem::Dependency
|
168
182
|
name: iso639
|
169
183
|
requirement: !ruby/object:Gem::Requirement
|