isodoc-i18n 1.1.0 → 1.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 71a7b4e2dcb8b00587cc92988c85a99c411444fb8698f8bd067c92a4f90751e2
4
- data.tar.gz: 6304cf921c57b555ff259b9c1dfad4d7306e726c7f56f08291e4959a188a6181
3
+ metadata.gz: db66af34abba937daa72bbef574be08220618ca75b104c5b1e6275736494e781
4
+ data.tar.gz: b94275b875363991d526ea1a83ec3be97bdc93dcd0db16681cee8ba0197a8577
5
5
  SHA512:
6
- metadata.gz: 9de07fcd21fdfd8ba2ab4d758f76952cbfe84075caad216543cd0a6fa2bcf409fab8e71bc71309aa98ed50342727be9a46c5ffc2625c27f987ede80c65e29b18
7
- data.tar.gz: fff4809002eef23c8d550baed4fb1185f134b99fb7a61733d3413045134b11b1e18eaab54a8787e0e4817601ff9051d67ffc1efc97cfaa589a73320188e70d98
6
+ metadata.gz: 16e56e238e36071225875002eeb86959c23ddcf2ae874fa7db18e6893978e4d7105b88964867f8cd331718c975bdea5175845533e6ad045b621b035bff34a3c7
7
+ data.tar.gz: 87da9b7308403c25d52f8008177cb0ef62da042df0d58d8f26864678de53b84a925465dd36b9b40e1a106ca8a8406411d515567f1316903d54643cbbc89dc339
data/lib/isodoc/i18n.rb CHANGED
@@ -98,23 +98,24 @@ module IsoDoc
98
98
  end
99
99
 
100
100
  def l10n_zh(text)
101
- xml = Nokogiri::HTML::DocumentFragment.parse(text)
101
+ xml = Nokogiri::XML::DocumentFragment.parse(text)
102
102
  xml.traverse do |n|
103
103
  next unless n.text?
104
104
 
105
105
  n.replace(cleanup_entities(l10_zh1(n.text), is_xml: false))
106
106
  end
107
- xml.to_xml.gsub(/<b>/, "").gsub("</b>", "").gsub(/<\?[^>]+>/, "")
107
+ xml.to_xml(encoding: "UTF-8").gsub(/<b>/, "").gsub("</b>", "")
108
+ .gsub(/<\?[^>]+>/, "")
108
109
  end
109
110
 
110
111
  def l10n_fr(text, locale)
111
- xml = Nokogiri::HTML::DocumentFragment.parse(text)
112
+ xml = Nokogiri::XML::DocumentFragment.parse(text)
112
113
  xml.traverse do |n|
113
114
  next unless n.text?
114
115
 
115
116
  n.replace(cleanup_entities(l10n_fr1(n.text, locale), is_xml: false))
116
117
  end
117
- xml.to_xml
118
+ xml.to_xml(encoding: "UTF-8")
118
119
  end
119
120
 
120
121
  ZH_CHAR = "\\p{Han}|\\p{In CJK Symbols And Punctuation}|"\
@@ -144,12 +145,14 @@ module IsoDoc
144
145
  end
145
146
 
146
147
  def l10n_fr1(text, locale)
147
- text = text.gsub(/(?<=\p{Alnum})([»›;?!])/, "\u202f\\1")
148
+ text = text.gsub(/(?<=\p{Alnum})([»›;?!])(?=\s)/, "\u202f\\1")
149
+ text = text.gsub(/(?<=\p{Alnum})([»›;?!])$/, "\u202f\\1")
148
150
  text = text.gsub(/^([»›;?!])/, "\u202f\\1")
149
151
  text = text.gsub(/([«‹])/, "\\1\u202f")
150
152
  colonsp = locale == "CH" ? "\u202f" : "\u00a0"
151
- text = text.gsub(/(?<=\p{Alnum})(:)/, "#{colonsp}\\1")
152
- text.gsub(/^(:)/, "#{colonsp}\\1")
153
+ text = text.gsub(/(?<=\p{Alnum})(:)(?=\s)/, "#{colonsp}\\1")
154
+ text = text.gsub(/(?<=\p{Alnum})(:)$/, "#{colonsp}\\1")
155
+ text.gsub(/^(:\s)/, "#{colonsp}\\1")
153
156
  end
154
157
 
155
158
  def boolean_conj(list, conn)
@@ -169,11 +172,11 @@ module IsoDoc
169
172
  c = HTMLEntities.new
170
173
  if is_xml
171
174
  text.split(/([<>])/).each_slice(4).map do |a|
172
- a[0] = c.encode(c.decode(a[0]), :hexadecimal)
175
+ a[0] = c.decode(a[0])
173
176
  a
174
177
  end.join
175
178
  else
176
- c.encode(c.decode(text), :hexadecimal)
179
+ c.decode(text)
177
180
  end
178
181
  end
179
182
 
@@ -1,5 +1,5 @@
1
1
  module IsoDoc
2
2
  class I18n
3
- VERSION = "1.1.0".freeze
3
+ VERSION = "1.1.2".freeze
4
4
  end
5
5
  end
@@ -103,6 +103,8 @@ RSpec.describe IsoDoc::I18n do
103
103
  expect(e.encode(c.l10n("Code; «code» and: code!"), :hexadecimal))
104
104
  .to be_equivalent_to "Code&#x202f;; &#xab;&#x202f;code&#x202f;&#xbb; "\
105
105
  "and&#x202f;: code&#x202f;!"
106
+ expect(e.encode(c.l10n("http://xyz a;b"), :hexadecimal))
107
+ .to be_equivalent_to "http://xyz a;b"
106
108
  end
107
109
 
108
110
  it "does boolean conjunctions" do
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.1.0
4
+ version: 1.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-09-25 00:00:00.000000000 Z
11
+ date: 2022-09-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: htmlentities