metanorma-utils 1.2.3 → 1.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/rake.yml +1 -1
- data/.rubocop.yml +1 -1
- data/lib/utils/image.rb +1 -2
- data/lib/utils/main.rb +12 -9
- data/lib/utils/version.rb +1 -1
- data/metanorma-utils.gemspec +3 -2
- data/spec/utils_spec.rb +3 -0
- metadata +19 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b8214b4ddc7290c78f5c5dd70fb9cb894e4fd33d6a69a40de41e86e34f9ae0ef
|
4
|
+
data.tar.gz: d40b771439ac6bfeca275970a6fb2c779bc492d60f2542b7b194abf6a95cae83
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8ac9628f99e84e0600e479136aa54afdbfe2aab3a2f7ebf0ea4ab1419125002f74937c1a2a731ca2510f568b5fd4b2e2aa8cefc65b572476f18ea77c0922fc9e
|
7
|
+
data.tar.gz: 3722452d1fbce0836ad04f87999f63f9d191612441e3226d3788e16efa06ff59d203f6b45943d332c530d18bf198498696d19e592c7130c9084f93409866b1b9
|
data/.github/workflows/rake.yml
CHANGED
data/.rubocop.yml
CHANGED
data/lib/utils/image.rb
CHANGED
data/lib/utils/main.rb
CHANGED
@@ -2,25 +2,28 @@ require "asciidoctor"
|
|
2
2
|
require "tempfile"
|
3
3
|
require "sterile"
|
4
4
|
require "uuidtools"
|
5
|
+
require "htmlentities"
|
5
6
|
|
6
7
|
module Metanorma
|
7
8
|
module Utils
|
8
|
-
NAMECHAR = "\u0000-\
|
9
|
-
|
10
|
-
|
9
|
+
NAMECHAR = "\u0000-\u002c\u002f\u003a-\u0040\\u005b-\u005e"\
|
10
|
+
"\u0060\u007b-\u00b6\u00b8-\u00bf\u00d7\u00f7\u037e"\
|
11
|
+
"\u2000-\u200b"\
|
12
|
+
"\u200e-\u203e\u2041-\u206f\u2190-\u2bff\u2ff0-\u3000".freeze
|
11
13
|
NAMESTARTCHAR = "\\u002d\u002e\u0030-\u0039\u00b7\u0300-\u036f"\
|
12
|
-
|
14
|
+
"\u203f-\u2040".freeze
|
13
15
|
|
14
16
|
class << self
|
15
|
-
def to_ncname(tag)
|
17
|
+
def to_ncname(tag, asciionly: true)
|
18
|
+
asciionly and tag = HTMLEntities.new.encode(tag, :basic, :hexadecimal)
|
16
19
|
start = tag[0]
|
17
|
-
ret1 = if %r([#{NAMECHAR}#]).match?(start)
|
20
|
+
ret1 = if %r([#{NAMECHAR}#])o.match?(start)
|
18
21
|
"_"
|
19
22
|
else
|
20
|
-
(%r([#{NAMESTARTCHAR}#]).match?(start) ? "_#{start}" : start)
|
23
|
+
(%r([#{NAMESTARTCHAR}#])o.match?(start) ? "_#{start}" : start)
|
21
24
|
end
|
22
25
|
ret2 = tag[1..-1] || ""
|
23
|
-
(ret1 || "") + ret2.gsub(%r([#{NAMECHAR}#]), "_")
|
26
|
+
(ret1 || "") + ret2.gsub(%r([#{NAMECHAR}#])o, "_")
|
24
27
|
end
|
25
28
|
|
26
29
|
def anchor_or_uuid(node = nil)
|
@@ -34,7 +37,7 @@ module Metanorma
|
|
34
37
|
|
35
38
|
d = Asciidoctor::Document.new(
|
36
39
|
text.lines.entries,
|
37
|
-
{ header_footer: false, backend: flavour }
|
40
|
+
{ header_footer: false, backend: flavour },
|
38
41
|
)
|
39
42
|
b = d.parse.blocks.first
|
40
43
|
b.apply_subs(b.source)
|
data/lib/utils/version.rb
CHANGED
data/metanorma-utils.gemspec
CHANGED
@@ -22,7 +22,7 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.require_paths = ["lib"]
|
23
23
|
spec.files = `git ls-files`.split("\n")
|
24
24
|
spec.test_files = `git ls-files -- {spec}/*`.split("\n")
|
25
|
-
spec.required_ruby_version = Gem::Requirement.new(">= 2.
|
25
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.5.0")
|
26
26
|
|
27
27
|
spec.add_dependency "asciidoctor", "~> 2.0.0"
|
28
28
|
spec.add_dependency "concurrent-ruby"
|
@@ -31,12 +31,13 @@ Gem::Specification.new do |spec|
|
|
31
31
|
spec.add_dependency "nokogiri", "~> 1.11"
|
32
32
|
spec.add_dependency "sterile", "~> 1.0.14"
|
33
33
|
spec.add_dependency "uuidtools"
|
34
|
+
spec.add_dependency "htmlentities", "~> 4.3.4"
|
34
35
|
|
35
36
|
spec.add_development_dependency "byebug"
|
36
37
|
spec.add_development_dependency "equivalent-xml", "~> 0.6"
|
37
38
|
spec.add_development_dependency "guard", "~> 2.14"
|
38
39
|
spec.add_development_dependency "guard-rspec", "~> 4.7"
|
39
|
-
spec.add_development_dependency "metanorma-standoc", "~> 1.
|
40
|
+
spec.add_development_dependency "metanorma-standoc", "~> 1.10"
|
40
41
|
spec.add_development_dependency "rake", "~> 13.0"
|
41
42
|
spec.add_development_dependency "rspec", "~> 3.6"
|
42
43
|
spec.add_development_dependency "rubocop", "~> 1.5.2"
|
data/spec/utils_spec.rb
CHANGED
@@ -8,6 +8,9 @@ RSpec.describe Metanorma::Utils do
|
|
8
8
|
|
9
9
|
it "normalises anchors" do
|
10
10
|
expect(Metanorma::Utils.to_ncname("/:ab")).to eq "__ab"
|
11
|
+
expect(Metanorma::Utils.to_ncname("Löwe")).to eq "L__xf6_we"
|
12
|
+
expect(Metanorma::Utils.to_ncname("Löwe", asciionly: false)).to eq "Löwe"
|
13
|
+
expect(Metanorma::Utils.to_ncname("Löwe", asciionly: true)).to eq "L__xf6_we"
|
11
14
|
end
|
12
15
|
|
13
16
|
it "sets metanorma IDs if not provided" do
|
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.2.
|
4
|
+
version: 1.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-06
|
11
|
+
date: 2021-09-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: asciidoctor
|
@@ -108,6 +108,20 @@ dependencies:
|
|
108
108
|
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: htmlentities
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: 4.3.4
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: 4.3.4
|
111
125
|
- !ruby/object:Gem::Dependency
|
112
126
|
name: byebug
|
113
127
|
requirement: !ruby/object:Gem::Requirement
|
@@ -170,14 +184,14 @@ dependencies:
|
|
170
184
|
requirements:
|
171
185
|
- - "~>"
|
172
186
|
- !ruby/object:Gem::Version
|
173
|
-
version: '1.
|
187
|
+
version: '1.10'
|
174
188
|
type: :development
|
175
189
|
prerelease: false
|
176
190
|
version_requirements: !ruby/object:Gem::Requirement
|
177
191
|
requirements:
|
178
192
|
- - "~>"
|
179
193
|
- !ruby/object:Gem::Version
|
180
|
-
version: '1.
|
194
|
+
version: '1.10'
|
181
195
|
- !ruby/object:Gem::Dependency
|
182
196
|
name: rake
|
183
197
|
requirement: !ruby/object:Gem::Requirement
|
@@ -318,7 +332,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
318
332
|
requirements:
|
319
333
|
- - ">="
|
320
334
|
- !ruby/object:Gem::Version
|
321
|
-
version: 2.
|
335
|
+
version: 2.5.0
|
322
336
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
323
337
|
requirements:
|
324
338
|
- - ">="
|