metanorma-utils 1.8.5 → 1.9.0

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: c6a75f252cf191accfebe5292830c5aa14653dcf5b4c02fda98bb1f7ec8dba85
4
- data.tar.gz: 49a53a02959cb26c6998458151488a6ccab8c39a4b9f627d6d16dcd2d64f634f
3
+ metadata.gz: 717014b944b65d1e4f5b7c7ed0c71b3ac3314a3fb9ac740ff0027e9b5088cea8
4
+ data.tar.gz: c5bc40281e230a272deaf0469d4b9b6dd85e4f6b124de1e64d4c5c16347b2e8c
5
5
  SHA512:
6
- metadata.gz: 29fdfcc884ba45d8a6112d7fefacf8988e1fc49d24bdae7285ebc9fbfc869de88fdb75e10e6e9db4b8e5e1287c3fa3f722eb414f18879ad15df44853d2dc9882
7
- data.tar.gz: d5a7e5abe280a6b5dc09cd4661ce38e722433226964aaeb4e973ce6e77aee7c439b20b0714057185ee9c7e74cd3d6dd956a79e80f3fd5031d0cbe08f721b48c2
6
+ metadata.gz: ef77c94f8be1071eead01e24fdbdbf1367ea2fc19ede7f1b3bf0149127863e38d56fea39a42a4685b3c65112431c251fab1507602a54b0307dae108a7ab563c9
7
+ data.tar.gz: 6a86994cc199526918abbb80cb79f0c099a3aa2eb3480b4d763e381a351cea0184ccce285eef28b49cb9d441037469ea4f21df91258a3b09c64bc889c76bf80f
data/lib/utils/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module Utils
3
- VERSION = "1.8.5".freeze
3
+ VERSION = "1.9.0".freeze
4
4
  end
5
5
  end
data/lib/utils/xml.rb CHANGED
@@ -62,6 +62,38 @@ module Metanorma
62
62
  end
63
63
  end
64
64
 
65
+ def noko(_script = "Latn", &block)
66
+ fragment = ::Nokogiri::XML.parse(NOKOHEAD).fragment("")
67
+ ::Nokogiri::XML::Builder.with fragment, &block
68
+ ret = fragment
69
+ .to_xml(encoding: "UTF-8", indent: 0,
70
+ save_with: Nokogiri::XML::Node::SaveOptions::AS_XML)
71
+ .lines.map do |l|
72
+ l.rstrip.gsub("–", "\u0096").gsub("—", "\u0097")
73
+ .gsub("–", "\u0096").gsub("—", "\u0097")
74
+ end
75
+ line_sanitise(ret)
76
+ end
77
+
78
+ # By default, carriage return in source translates to whitespace;
79
+ # but in CJK, it does not. We don't want carriage returns in the final
80
+ # output because of CJK complications
81
+ def line_sanitise(ret)
82
+ ret.size == 1 and return ret
83
+ (0...ret.size).each do |i|
84
+ last = firstchar_xml(ret[i].reverse)
85
+ nextfirst = firstchar_xml(ret[i + 1])
86
+ /#{CJK}/o.match?(last) && /#{CJK}/o.match?(nextfirst) or
87
+ ret[i] += " "
88
+ end
89
+ ret
90
+ end
91
+
92
+ def firstchar_xml(line)
93
+ m = /^(<[^>]+>)*(.)/.match(line) or return ""
94
+ m[2]
95
+ end
96
+
65
97
  def noko_html(&block)
66
98
  doc = ::Nokogiri::XML.parse(NOKOHEAD)
67
99
  fragment = doc.fragment("")
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma-utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.5
4
+ version: 1.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-07-19 00:00:00.000000000 Z
11
+ date: 2024-07-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: asciidoctor