relaton-bib 1.12.6 → 1.12.7
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/relaton_bib/localized_string.rb +16 -11
- data/lib/relaton_bib/typed_title_string.rb +1 -1
- data/lib/relaton_bib/version.rb +1 -1
- data/lib/relaton_bib/xml_parser.rb +1 -1
- data/lib/relaton_bib.rb +2 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: be4b986a04f391a2e552c13d8ee897e73c398f3acb27deda3bb203da627f585b
|
4
|
+
data.tar.gz: 05540e11934396b938df0c902d926c37b1c49c8aa215b7888827bb42d19d4042
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f82094e85351832f3738216ce8ba72c68f7f26e9bcd7379cbe49b2e9a2bc0318ce1d4507462d3dbfed61ba57fc9bc692daf4998cbc84fb3bc2f54a14bed7e72a
|
7
|
+
data.tar.gz: 66de7c5f7b612c203694d6adacb0fdbf09dd34380f24bfe6e3d298f50d61d52af844f2803f8e75644839ce0b256726db55fc9058a649f9f42c8c3198f6e279ab
|
@@ -68,14 +68,17 @@ module RelatonBib
|
|
68
68
|
# @return [String] encoded content
|
69
69
|
#
|
70
70
|
def encode(cnt) # rubocop:disable Metrics/MethodLength
|
71
|
-
|
71
|
+
return unless cnt
|
72
|
+
|
73
|
+
# regex = /(?<prf>.*?)(?<xml><(?<tag>\w+)>.*<\/\k<tag>>)(?<sfx>.*)/m
|
74
|
+
regex = /(?<prf>.*?)(?<xml><(?<tag>\w+)[^>]*(?:>.*<\/\k<tag>)?>)(?<rest>.*)/m
|
72
75
|
if cnt.match(regex)
|
73
76
|
prf = Regexp.last_match(:prf).lstrip
|
74
77
|
xml = Regexp.last_match[:xml]
|
75
|
-
|
76
|
-
parts = xml.scan(/\s*<(?<tago>\w+)>(?<cnt1>.*?)(
|
78
|
+
rest = Regexp.last_match(:rest).rstrip
|
79
|
+
parts = xml.scan(/\s*<(?<tago>\w+)(?<attrs>[^>]*)>(?:(?<cnt1>.*?)(?=<\/\w+>|<\w+[^>]*>))?|(?<cnt2>.*?)<\/(?<tagc>\w+)>/)
|
77
80
|
out = scan_xml parts
|
78
|
-
"#{escp(prf)}#{out}#{
|
81
|
+
"#{escp(prf)}#{out}#{encode(rest)}"
|
79
82
|
else
|
80
83
|
escp cnt
|
81
84
|
end
|
@@ -84,22 +87,24 @@ module RelatonBib
|
|
84
87
|
#
|
85
88
|
# Scan XML and escape HTML entities.
|
86
89
|
#
|
87
|
-
# @param [Array<Array<String,
|
90
|
+
# @param [Array<Array<String,nil>>] parts XML parts
|
88
91
|
#
|
89
92
|
# @return [String] output string
|
90
93
|
#
|
91
94
|
def scan_xml(parts) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity,Metrics/MethodLength
|
92
95
|
return "" unless parts.any? && parts.first[0]
|
93
96
|
|
94
|
-
tago, cnt1, = parts.shift
|
95
|
-
if tago && tago == parts.first
|
96
|
-
_, _, cnt2, tagc = parts.shift
|
97
|
-
"<#{tago}>#{escp(cnt1)}#{escp(cnt2)}</#{tagc}>"
|
97
|
+
tago, attrs, cnt1, = parts.shift
|
98
|
+
if tago && tago == parts.first&.last
|
99
|
+
_, _, _, cnt2, tagc = parts.shift
|
100
|
+
"<#{tago}#{attrs}>#{escp(cnt1)}#{escp(cnt2)}</#{tagc}>"
|
101
|
+
elsif tago && attrs && attrs[-1] == "/"
|
102
|
+
"<#{tago}#{attrs}>"
|
98
103
|
elsif tago
|
99
104
|
inr = scan_xml parts
|
100
|
-
_, _, cnt2, tagc = parts.shift
|
105
|
+
_, _, _, cnt2, tagc = parts.shift
|
101
106
|
if tago == tagc
|
102
|
-
"<#{tago}>#{escp(cnt1)}#{inr}#{escp(cnt2)}</#{tagc}>"
|
107
|
+
"<#{tago}#{attrs}>#{escp(cnt1)}#{inr}#{escp(cnt2)}</#{tagc}>"
|
103
108
|
else
|
104
109
|
"#{escp("<#{tago}>#{cnt1}")}#{inr}#{escp("#{cnt2}</#{tagc}>")}"
|
105
110
|
end
|
data/lib/relaton_bib/version.rb
CHANGED
data/lib/relaton_bib.rb
CHANGED
@@ -40,7 +40,8 @@ module RelatonBib
|
|
40
40
|
#
|
41
41
|
# @param [String] date date string
|
42
42
|
# @param [String] format format string
|
43
|
-
# @param [Boolean] str return string
|
43
|
+
# @param [Boolean] str return string if true in other case return Date
|
44
|
+
# @param [String, nil] outformat output format
|
44
45
|
#
|
45
46
|
# @return [Date, String] date object or formatted date string
|
46
47
|
#
|
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.12.
|
4
|
+
version: 1.12.7
|
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-08-
|
11
|
+
date: 2022-08-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: byebug
|