isodoc-i18n 1.5.2 → 1.5.4.pre.alpha.1
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/.rubocop.yml +23 -2
- data/isodoc-i18n.gemspec +1 -1
- data/lib/isodoc/i18n/version.rb +1 -1
- data/lib/isodoc/i18n-yaml.rb +9 -1
- data/lib/isodoc/l10n.rb +26 -0
- metadata +4 -5
- data/.hound.yml +0 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e0231a7dccbd2eb0fcedca0789b43dcc13f028bdbe02538e70612695a505f28c
|
|
4
|
+
data.tar.gz: b240aabb37175a0b42ae8d281b1e87d03307a5194748d367f5e26e1444fbe439
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7c444f8eba3c43faa12b6cd480c2e8db72e2648ab9e88cbc0018e20604b9cbd89e98befe43ffdfc993cca9ed3abbe588568a8700ee4f74e1de792b596d344536
|
|
7
|
+
data.tar.gz: 5744185a3bac5e6898c7f0b6738eddb44994b74abfc35c5e36b143e52e03e956091e477fa8cc15ef272f666d7a15d72c7b5c8421b721f6407ffc6b4e96eb9da7
|
data/.rubocop.yml
CHANGED
|
@@ -1,10 +1,31 @@
|
|
|
1
1
|
# Auto-generated by Cimas: Do not edit it manually!
|
|
2
2
|
# See https://github.com/metanorma/cimas
|
|
3
3
|
inherit_from:
|
|
4
|
-
- https://raw.githubusercontent.com/riboseinc/oss-guides/
|
|
4
|
+
- https://raw.githubusercontent.com/riboseinc/oss-guides/main/ci/rubocop.yml
|
|
5
|
+
# .rubocop_todo.yml MUST be the last entry. inherit_from is last-wins:
|
|
6
|
+
# if listed before oss-guides, the shared config's stricter Metrics/
|
|
7
|
+
# (MethodLength, BlockLength, etc.) rules override the todo's per-file
|
|
8
|
+
# grandfathering, and the todo becomes inert on those cops. Empirically
|
|
9
|
+
# verified on suma 2026-07-06: with todo listed first, 34 Metrics/* offenses
|
|
10
|
+
# remained; moved last, cleared. Every gem in the metanorma-org fleet
|
|
11
|
+
# already ships a `.rubocop_todo.yml` on its live tree (audited 2026-07-06,
|
|
12
|
+
# 54/54 have it), so this reference is safe to emit unconditionally.
|
|
13
|
+
- .rubocop_todo.yml
|
|
14
|
+
|
|
15
|
+
# Rubocop plugins enabled centrally so every metanorma-org gem picks them up
|
|
16
|
+
# on cimas sync — best practice belongs at the shared-template layer, not
|
|
17
|
+
# per-repo. Per ronaldtse feedback on metanorma/ci#332.
|
|
18
|
+
plugins:
|
|
19
|
+
- rubocop-rspec
|
|
20
|
+
- rubocop-performance
|
|
21
|
+
- rubocop-rake
|
|
5
22
|
|
|
6
23
|
# local repo-specific modifications
|
|
7
24
|
# ...
|
|
8
25
|
|
|
9
26
|
AllCops:
|
|
10
|
-
|
|
27
|
+
# 3.3 matches the org-wide minimum being pushed via #274 (Raise minimum
|
|
28
|
+
# Ruby version to 3.3 due to EOL of 3.2 on 2026-03-31). Was 3.4 before
|
|
29
|
+
# this commit — 3.4 was above the org's stated minimum and would have
|
|
30
|
+
# applied Rubocop rules that fail-close on gems still targeting 3.3.
|
|
31
|
+
TargetRubyVersion: 3.3
|
data/isodoc-i18n.gemspec
CHANGED
|
@@ -22,7 +22,7 @@ Gem::Specification.new do |spec|
|
|
|
22
22
|
end
|
|
23
23
|
spec.required_ruby_version = Gem::Requirement.new(">= 3.2.0")
|
|
24
24
|
|
|
25
|
-
spec.add_dependency "base64"
|
|
25
|
+
spec.add_dependency "base64", ">= 0.1.0"
|
|
26
26
|
spec.add_dependency "htmlentities", "~> 4.3.4"
|
|
27
27
|
spec.add_dependency "japanese_calendar"
|
|
28
28
|
spec.add_dependency "liquid", "~> 5"
|
data/lib/isodoc/i18n/version.rb
CHANGED
data/lib/isodoc/i18n-yaml.rb
CHANGED
|
@@ -120,7 +120,15 @@ module IsoDoc
|
|
|
120
120
|
end
|
|
121
121
|
ret
|
|
122
122
|
when Array then ret.map { |n| normalise_hash(n) }
|
|
123
|
-
when String
|
|
123
|
+
when String
|
|
124
|
+
# Private copy: psych interns equal strings across loads, and an
|
|
125
|
+
# in-place relabel can poison every later consumer (isodoc#850 —
|
|
126
|
+
# intermittent "invalid byte sequence in UTF-8" under
|
|
127
|
+
# unicode_normalize when a shared string arrives mislabelled).
|
|
128
|
+
cleaned = +"#{ret}"
|
|
129
|
+
cleaned.force_encoding(Encoding::UTF_8)
|
|
130
|
+
cleaned.scrub! unless cleaned.valid_encoding?
|
|
131
|
+
cleanup_entities(cleaned.unicode_normalize(:nfc))
|
|
124
132
|
else ret
|
|
125
133
|
end
|
|
126
134
|
end
|
data/lib/isodoc/l10n.rb
CHANGED
|
@@ -41,6 +41,7 @@ module IsoDoc
|
|
|
41
41
|
|
|
42
42
|
def l10n_prep(text, options)
|
|
43
43
|
xml = Nokogiri::XML::DocumentFragment.parse(text)
|
|
44
|
+
wrap_tt_children_in_esc(xml)
|
|
44
45
|
t = xml.xpath(".//text()").reject { |node| node.text.empty? }
|
|
45
46
|
text_cache = build_text_cache(t, options[:prev], options[:foll])
|
|
46
47
|
|
|
@@ -51,6 +52,19 @@ module IsoDoc
|
|
|
51
52
|
[t, text_cache, xml, options[:prev], options[:foll], esc_indices]
|
|
52
53
|
end
|
|
53
54
|
|
|
55
|
+
# <tt> is an inline code element whose content is by definition Latin /
|
|
56
|
+
# literal — it must not undergo punctuation localisation. Wrap its
|
|
57
|
+
# children in <esc> so build_esc_indices skips them; the trailing
|
|
58
|
+
# <esc>-strip in l10n removes the wrapper afterwards.
|
|
59
|
+
def wrap_tt_children_in_esc(xml)
|
|
60
|
+
xml.xpath(".//tt | .//*[local-name()='tt']").each do |tt|
|
|
61
|
+
next if tt.children.empty?
|
|
62
|
+
next if tt.children.all? { |c| c.element? && c.name == "esc" }
|
|
63
|
+
|
|
64
|
+
tt.inner_html = "<esc>#{tt.inner_html}</esc>"
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
|
|
54
68
|
# Build set of indices for text nodes within <esc> tags
|
|
55
69
|
# Handles both namespaced and non-namespaced <esc> elements
|
|
56
70
|
def build_esc_indices(xml, text_nodes)
|
|
@@ -131,6 +145,13 @@ module IsoDoc
|
|
|
131
145
|
|
|
132
146
|
def l10_context_valid?(context, idx, delim, regex)
|
|
133
147
|
l10n_context_found_delimiter?(context[idx], delim) or return false
|
|
148
|
+
# A period with digits on both sides is a decimal point, not
|
|
149
|
+
# punctuation: full-width conversion of "CV2.0" -> "CV2。0" is
|
|
150
|
+
# never wanted, in any mode. Number ranges ("3-9", "3〜9") are
|
|
151
|
+
# dash delimiters and stay convertible.
|
|
152
|
+
delim[0].is_a?(String) && %w(. , ; :).include?(delim[0]) and
|
|
153
|
+
return false if l10n_delimiter_decimal?(context, idx)
|
|
154
|
+
|
|
134
155
|
regex.nil? and return true
|
|
135
156
|
regex.detect do |r|
|
|
136
157
|
r[0].match?(context[0...idx].join) && # preceding context
|
|
@@ -138,6 +159,11 @@ module IsoDoc
|
|
|
138
159
|
end
|
|
139
160
|
end
|
|
140
161
|
|
|
162
|
+
def l10n_delimiter_decimal?(context, idx)
|
|
163
|
+
context[0...idx].join.match?(/[0-9]$/) &&
|
|
164
|
+
context[(idx + 1)..-1].join.match?(/\A[0-9]/)
|
|
165
|
+
end
|
|
166
|
+
|
|
141
167
|
def l10n_context_found_delimiter?(token, delim)
|
|
142
168
|
if delim[0].is_a?(Regexp) # punct to convert
|
|
143
169
|
delim[0].match?(token)
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: isodoc-i18n
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.5.
|
|
4
|
+
version: 1.5.4.pre.alpha.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ribose Inc.
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-10-22 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: base64
|
|
@@ -16,14 +16,14 @@ dependencies:
|
|
|
16
16
|
requirements:
|
|
17
17
|
- - ">="
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
|
-
version:
|
|
19
|
+
version: 0.1.0
|
|
20
20
|
type: :runtime
|
|
21
21
|
prerelease: false
|
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
23
|
requirements:
|
|
24
24
|
- - ">="
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
|
-
version:
|
|
26
|
+
version: 0.1.0
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
28
28
|
name: htmlentities
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -285,7 +285,6 @@ executables: []
|
|
|
285
285
|
extensions: []
|
|
286
286
|
extra_rdoc_files: []
|
|
287
287
|
files:
|
|
288
|
-
- ".hound.yml"
|
|
289
288
|
- ".rubocop.yml"
|
|
290
289
|
- CODE_OF_CONDUCT.md
|
|
291
290
|
- Gemfile
|