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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1d32567e880304ea57ec26bd33014d3b727e30caa9fd057ef7f4d3fe8121b630
4
- data.tar.gz: 5fd706a2faf7f9db1419fa537e596b96cd82800bab4382b5c2d0b5e8a8605057
3
+ metadata.gz: b8214b4ddc7290c78f5c5dd70fb9cb894e4fd33d6a69a40de41e86e34f9ae0ef
4
+ data.tar.gz: d40b771439ac6bfeca275970a6fb2c779bc492d60f2542b7b194abf6a95cae83
5
5
  SHA512:
6
- metadata.gz: 75bfacc4803e89a34ca0ceb8907691bfd25462d1d947bc037fc63fd08217857d21567e81d112a10afe7adcf315363a77c1461eaef29710b9eb862b947b5d0724
7
- data.tar.gz: '053841eeac54b72fccc6386f157b65b778c48b79d8be0d28ed49d8ba77e5d4e3036bddaf29aa736776d77a2b53f7114db670ba0e90f53554e9e93a23c24f26a8'
6
+ metadata.gz: 8ac9628f99e84e0600e479136aa54afdbfe2aab3a2f7ebf0ea4ab1419125002f74937c1a2a731ca2510f568b5fd4b2e2aa8cefc65b572476f18ea77c0922fc9e
7
+ data.tar.gz: 3722452d1fbce0836ad04f87999f63f9d191612441e3226d3788e16efa06ff59d203f6b45943d332c530d18bf198498696d19e592c7130c9084f93409866b1b9
@@ -16,7 +16,7 @@ jobs:
16
16
  strategy:
17
17
  fail-fast: false
18
18
  matrix:
19
- ruby: [ '3.0', '2.7', '2.6', '2.5', '2.4' ]
19
+ ruby: [ '3.0', '2.7', '2.6', '2.5' ]
20
20
  os: [ ubuntu-latest, windows-latest, macos-latest ]
21
21
  experimental: [ false ]
22
22
  steps:
data/.rubocop.yml CHANGED
@@ -7,4 +7,4 @@ inherit_from:
7
7
  # ...
8
8
 
9
9
  AllCops:
10
- TargetRubyVersion: 2.4
10
+ TargetRubyVersion: 2.5
data/lib/utils/image.rb CHANGED
@@ -54,8 +54,7 @@ module Metanorma
54
54
  /^data:/.match(src) and i["src"] = datauri(path)
55
55
  elsif i = svgmap.at(".//m:svg", "m" => SVG_NS)
56
56
  i.replace(svgmap_rewrite1(svgmap, i, namespace, idx))
57
- else
58
- return false
57
+ else return false
59
58
  end
60
59
  true
61
60
  end
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-\u0022\u0024\u002c\u002f\u003a-\u0040\\u005b-\u005e"\
9
- "\u0060\u007b-\u00b6\u00b8-\u00bf\u00d7\u00f7\u037e\u2000-\u200b"\
10
- "\u200e-\u203e\u2041-\u206f\u2190-\u2bff\u2ff0-\u3000".freeze
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
- "\u203f-\u2040".freeze
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
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module Utils
3
- VERSION = "1.2.3".freeze
3
+ VERSION = "1.2.4".freeze
4
4
  end
5
5
  end
@@ -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.4.0")
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.8"
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.3
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-07 00:00:00.000000000 Z
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.8'
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.8'
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.4.0
335
+ version: 2.5.0
322
336
  required_rubygems_version: !ruby/object:Gem::Requirement
323
337
  requirements:
324
338
  - - ">="