relaton-bib 1.11.3 → 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/.github/workflows/rake.yml +1 -5
- data/.rubocop.yml +1 -1
- data/lib/relaton_bib/bibxml_parser.rb +1 -1
- data/lib/relaton_bib/localized_string.rb +56 -3
- 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 +3 -2
- metadata +19 -5
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
|
data/.github/workflows/rake.yml
CHANGED
@@ -16,7 +16,7 @@ jobs:
|
|
16
16
|
strategy:
|
17
17
|
fail-fast: false
|
18
18
|
matrix:
|
19
|
-
ruby: [ '3.0', '2.7', '2.6'
|
19
|
+
ruby: [ '3.0', '2.7', '2.6' ]
|
20
20
|
os: [ ubuntu-latest, windows-latest, macos-latest ]
|
21
21
|
experimental: [ false ]
|
22
22
|
steps:
|
@@ -24,10 +24,6 @@ jobs:
|
|
24
24
|
with:
|
25
25
|
submodules: true
|
26
26
|
|
27
|
-
# https://github.com/ruby-debug/debase/issues/89#issuecomment-686827382
|
28
|
-
- if: matrix.os == 'macos-latest' && matrix.ruby == '2.5'
|
29
|
-
run: echo BUNDLE_BUILD__DEBASE="--with-cflags=\"-Wno-error=implicit-function-declaration\"" >> $GITHUB_ENV
|
30
|
-
|
31
27
|
- uses: ruby/setup-ruby@v1
|
32
28
|
with:
|
33
29
|
ruby-version: ${{ matrix.ruby }}
|
data/.rubocop.yml
CHANGED
@@ -194,7 +194,7 @@ module RelatonBib
|
|
194
194
|
# @return [Array<RelatonBib::FormattedString>]
|
195
195
|
def abstracts(ref)
|
196
196
|
ref.xpath("./front/abstract").map do |a|
|
197
|
-
c = a.
|
197
|
+
c = a.inner_html.gsub(/\s*(<\/?)t(>)\s*/, '\1p\2')
|
198
198
|
.gsub(/[\t\n]/, " ").squeeze " "
|
199
199
|
FormattedString.new(content: c, language: language(ref), script: "Latn",
|
200
200
|
format: "text/html")
|
@@ -56,12 +56,65 @@ 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.parent
|
59
|
+
builder.parent.inner_html = encode content
|
60
60
|
end
|
61
61
|
end
|
62
62
|
|
63
|
-
|
64
|
-
|
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
|
65
118
|
end
|
66
119
|
|
67
120
|
# @return [Hash]
|
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
@@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.bindir = "exe"
|
22
22
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
23
23
|
spec.require_paths = ["lib"]
|
24
|
-
spec.required_ruby_version = Gem::Requirement.new(">= 2.
|
24
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.6.0")
|
25
25
|
|
26
26
|
spec.add_development_dependency "byebug"
|
27
27
|
spec.add_development_dependency "equivalent-xml", "~> 0.6"
|
@@ -35,6 +35,7 @@ Gem::Specification.new do |spec|
|
|
35
35
|
|
36
36
|
spec.add_dependency "addressable"
|
37
37
|
spec.add_dependency "bibtex-ruby"
|
38
|
+
spec.add_dependency "htmlentities"
|
38
39
|
spec.add_dependency "iso639"
|
39
|
-
spec.add_dependency "nokogiri", "~> 1.
|
40
|
+
spec.add_dependency "nokogiri", "~> 1.13.0"
|
40
41
|
end
|
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
|
@@ -184,14 +198,14 @@ dependencies:
|
|
184
198
|
requirements:
|
185
199
|
- - "~>"
|
186
200
|
- !ruby/object:Gem::Version
|
187
|
-
version: 1.
|
201
|
+
version: 1.13.0
|
188
202
|
type: :runtime
|
189
203
|
prerelease: false
|
190
204
|
version_requirements: !ruby/object:Gem::Requirement
|
191
205
|
requirements:
|
192
206
|
- - "~>"
|
193
207
|
- !ruby/object:Gem::Version
|
194
|
-
version: 1.
|
208
|
+
version: 1.13.0
|
195
209
|
description: 'RelatonBib: Ruby XMLDOC impementation.'
|
196
210
|
email:
|
197
211
|
- open.source@ribose.com
|
@@ -270,7 +284,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
270
284
|
requirements:
|
271
285
|
- - ">="
|
272
286
|
- !ruby/object:Gem::Version
|
273
|
-
version: 2.
|
287
|
+
version: 2.6.0
|
274
288
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
275
289
|
requirements:
|
276
290
|
- - ">="
|