metanorma-utils 1.9.0 → 1.10.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/utils/linestatus.rb +1 -1
- data/lib/utils/log.rb +1 -1
- data/lib/utils/version.rb +1 -1
- data/lib/utils/xml.rb +19 -31
- data/metanorma-utils.gemspec +1 -0
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fe2af0c9b9521b3ae1953545fb434d08e45d028dd93c02fa509a8251e14e1c8e
|
4
|
+
data.tar.gz: c551aa4d4c08dba83273ce0be945a171cfbbdc4a9a2c02fd09044b3c97a8b317
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f6a23dde225425211a6ac35bb0e9b718189f0bc071eeef526a36ecebd3f8572f78addf7b93c4390374511642c360b6543e88e98e459ea1bb76849d077e008730
|
7
|
+
data.tar.gz: b537b6828491a4cc6f495c462e0c0810a8b1fcd61effb326232980f07325fe70e2ddc6b9f3c09d60b1f8c6af250c38e21064617acd294f8fa3542e141d647f40
|
data/lib/utils/linestatus.rb
CHANGED
@@ -29,7 +29,7 @@ module Metanorma
|
|
29
29
|
@middoc_docattr = false
|
30
30
|
@pass = false
|
31
31
|
elsif (@is_delim && /^(--+|\*\*+|==+|__+)$/.match?(text)) ||
|
32
|
-
(!@is_delim && !@delimln &&
|
32
|
+
(!@is_delim && !@delimln && /^-----*$|^\.\.\.\.\.*$|^\/\/\/\/\/*$/
|
33
33
|
.match?(text))
|
34
34
|
@delimln = text
|
35
35
|
@pass = true
|
data/lib/utils/log.rb
CHANGED
data/lib/utils/version.rb
CHANGED
data/lib/utils/xml.rb
CHANGED
@@ -48,49 +48,37 @@ module Metanorma
|
|
48
48
|
# block for processing XML document fragments as XHTML,
|
49
49
|
# to allow for HTMLentities
|
50
50
|
# Unescape special chars used in Asciidoctor substitution processing
|
51
|
-
def noko(script = "Latn", &block)
|
52
|
-
doc = ::Nokogiri::XML.parse(NOKOHEAD)
|
53
|
-
fragment = doc.fragment("")
|
54
|
-
::Nokogiri::XML::Builder.with fragment, &block
|
55
|
-
eoln = %w(Hans Hant Jpan).include?(script) ? "" : " "
|
56
|
-
fragment.to_xml(encoding: "US-ASCII", indent: 0,
|
57
|
-
save_with: Nokogiri::XML::Node::SaveOptions::AS_XML)
|
58
|
-
.lines.map do |l|
|
59
|
-
l.gsub(/>\n$/, ">").gsub(/\n$/m, eoln).gsub("–", "\u0096")
|
60
|
-
.gsub("—", "\u0097").gsub("–", "\u0096")
|
61
|
-
.gsub("—", "\u0097")
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
51
|
def noko(_script = "Latn", &block)
|
66
52
|
fragment = ::Nokogiri::XML.parse(NOKOHEAD).fragment("")
|
67
53
|
::Nokogiri::XML::Builder.with fragment, &block
|
68
|
-
|
54
|
+
fragment
|
69
55
|
.to_xml(encoding: "UTF-8", indent: 0,
|
70
56
|
save_with: Nokogiri::XML::Node::SaveOptions::AS_XML)
|
71
|
-
.
|
72
|
-
|
73
|
-
.gsub("–", "\u0096").gsub("—", "\u0097")
|
74
|
-
end
|
75
|
-
line_sanitise(ret)
|
57
|
+
.gsub("–", "\u0096").gsub("—", "\u0097")
|
58
|
+
.gsub("–", "\u0096").gsub("—", "\u0097")
|
76
59
|
end
|
77
60
|
|
78
61
|
# By default, carriage return in source translates to whitespace;
|
79
|
-
# but in CJK, it does not.
|
80
|
-
# output because of CJK complications
|
62
|
+
# but in CJK, it does not. (Non-CJK text \n CJK)
|
81
63
|
def line_sanitise(ret)
|
82
64
|
ret.size == 1 and return ret
|
83
|
-
(0...ret.size).each do |i|
|
65
|
+
(0...(ret.size - 1)).each do |i|
|
84
66
|
last = firstchar_xml(ret[i].reverse)
|
85
67
|
nextfirst = firstchar_xml(ret[i + 1])
|
86
|
-
|
87
|
-
|
68
|
+
cjk1 = /#{CJK}/o.match?(last)
|
69
|
+
cjk2 = /#{CJK}/o.match?(nextfirst)
|
70
|
+
text1 = /[^\p{Z}\p{C}]/.match?(last)
|
71
|
+
text2 = /[^\p{Z}\p{C}]/.match?(nextfirst)
|
72
|
+
(cjk1 && (cjk2 || !text2)) and next
|
73
|
+
!text1 && cjk2 and next
|
74
|
+
ret[i] += " "
|
88
75
|
end
|
89
76
|
ret
|
90
77
|
end
|
91
78
|
|
79
|
+
# need to deal with both <em> and its reverse string, >me<
|
92
80
|
def firstchar_xml(line)
|
93
|
-
m = /^(
|
81
|
+
m = /^([<>][^<>]+[<>])*(.)/.match(line) or return ""
|
94
82
|
m[2]
|
95
83
|
end
|
96
84
|
|
@@ -111,15 +99,15 @@ module Metanorma
|
|
111
99
|
end
|
112
100
|
|
113
101
|
def ns(xpath)
|
114
|
-
xpath.gsub(%r{/([a-zA-
|
115
|
-
.gsub(%r{::([a-zA-
|
116
|
-
.gsub(%r{\[([a-zA-
|
117
|
-
.gsub(%r{\[([a-zA-
|
102
|
+
xpath.gsub(%r{/([a-zA-Z])}, "/xmlns:\\1")
|
103
|
+
.gsub(%r{::([a-zA-Z])}, "::xmlns:\\1")
|
104
|
+
.gsub(%r{\[([a-zA-Z][a-z0-9A-Z@/-]* ?=)}, "[xmlns:\\1")
|
105
|
+
.gsub(%r{\[([a-zA-Z][a-z0-9A-Z@/-]*[/\[\]])}, "[xmlns:\\1")
|
118
106
|
end
|
119
107
|
|
120
108
|
def numeric_escapes(xml)
|
121
109
|
c = HTMLEntities.new
|
122
|
-
xml.split(/(&[^ \r\n\t
|
110
|
+
xml.split(/(&[^ \r\n\t#&;]+;)/).map do |t|
|
123
111
|
if /^(&[^ \t\r\n#;]+;)/.match?(t)
|
124
112
|
c.encode(c.decode(t), :hexadecimal)
|
125
113
|
else t
|
data/metanorma-utils.gemspec
CHANGED
@@ -46,5 +46,6 @@ Gem::Specification.new do |spec|
|
|
46
46
|
spec.add_development_dependency "timecop", "~> 0.9"
|
47
47
|
spec.add_development_dependency "vcr", "~> 6.1.0"
|
48
48
|
spec.add_development_dependency "webmock"
|
49
|
+
spec.add_development_dependency "xml-c14n"
|
49
50
|
#spec.metadata["rubygems_mfa_required"] = "true"
|
50
51
|
end
|
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.
|
4
|
+
version: 1.10.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: 2024-
|
11
|
+
date: 2024-08-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: asciidoctor
|
@@ -276,6 +276,20 @@ dependencies:
|
|
276
276
|
- - ">="
|
277
277
|
- !ruby/object:Gem::Version
|
278
278
|
version: '0'
|
279
|
+
- !ruby/object:Gem::Dependency
|
280
|
+
name: xml-c14n
|
281
|
+
requirement: !ruby/object:Gem::Requirement
|
282
|
+
requirements:
|
283
|
+
- - ">="
|
284
|
+
- !ruby/object:Gem::Version
|
285
|
+
version: '0'
|
286
|
+
type: :development
|
287
|
+
prerelease: false
|
288
|
+
version_requirements: !ruby/object:Gem::Requirement
|
289
|
+
requirements:
|
290
|
+
- - ">="
|
291
|
+
- !ruby/object:Gem::Version
|
292
|
+
version: '0'
|
279
293
|
description: 'metanorma-utils provides utilities for the Metanorma stack
|
280
294
|
|
281
295
|
'
|