metanorma-utils 1.7.7 → 1.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7464b0f736513d8c049db1859958c5730496c189c17ec06f3690ceeafdc51548
4
- data.tar.gz: 7acf790ae1a53ab6693a6185c3f6b5be82ffcb1a8f75581b6fef8d27800d5688
3
+ metadata.gz: 5d732ef5b43563be4481894015cde861af9d10a6c9ba3f27f9a7491fc5e035c8
4
+ data.tar.gz: aaeea69fc4ebc1b02ff5714f31ccbad138ec7a9dc3d05afba575aef5b070da54
5
5
  SHA512:
6
- metadata.gz: dc31707be4f372e3edc040ab8c989b246e803ad48694cf9fbacfded0aa0cde52fcc00616d616697e344c65664dddbb9c259e1cd1d79032be6170884ac53c7385
7
- data.tar.gz: ee8b200993fc61fcb8606ba7fe2a7406cf8f03b7da12be5c18f0f44c6fa1d6887eeb829cf404f09794a30b71fb7c85831644275c7de610f621bb762e94e5c18c
6
+ metadata.gz: 358711ec61605ad726879b5b4c26dca54788d8e11772ada1251fce68b5ed47b768eeaa3683a0786475c7c6ae9e7d3266d00d6f139148ac4caba31f0c568cd34d
7
+ data.tar.gz: 977160c2e5eadd24482b5433b095a865ab301f544ad2659426704910f2e963a29a1202af6f230010f4dac2b4d6a7da7b1fc1ac57e5b8adf7afc16bea9fcb5e2a
@@ -2,5 +2,6 @@ require_relative "utils/version"
2
2
  require_relative "utils/hash_transform_keys"
3
3
  require_relative "utils/main"
4
4
  require_relative "utils/image"
5
+ require_relative "utils/linestatus"
5
6
  require_relative "utils/log"
6
7
  require_relative "utils/xml"
@@ -0,0 +1,52 @@
1
+ module Metanorma
2
+ module Utils
3
+ class LineStatus
4
+ # document attribute in the middle of a document, not in a header
5
+ attr_reader :middoc_docattr
6
+ # block attribute associated with preformatted text, e.g. [source]
7
+ attr_reader :is_delim
8
+ # block delimiter for preformatted text, e.g. ====
9
+ attr_reader :delimln
10
+ # passthrough block delimiter
11
+ attr_reader :pass_delim
12
+ # passthrough block
13
+ attr_reader :pass
14
+ # record previous line read
15
+ attr_reader :prev_line
16
+
17
+ def initialize
18
+ # process as passthrough: init = true until hit end of document header
19
+ @pass = true
20
+ @delim = false
21
+ @pass_delim = false
22
+ @delimln = ""
23
+ end
24
+
25
+ def process(line)
26
+ text = line.rstrip
27
+ text == "++++" && !@delimln and @pass = !@pass
28
+ if @middoc_docattr && !/^:[^ :]+:($| )/.match?(text)
29
+ @middoc_docattr = false
30
+ @pass = false
31
+ elsif (@is_delim && /^(-+|\*+|=+|_+)$/.match?(text)) ||
32
+ (!@is_delim && !@delimln && /^-----*$|^\.\.\.\.\.*$/.match?(text))
33
+ @delimln = text
34
+ @pass = true
35
+ elsif @pass_delim
36
+ @pass = true
37
+ @delimln = "" # end of paragraph for paragraph with [pass]
38
+ elsif @delimln && text == @delimln
39
+ @pass = false
40
+ @delimln = nil
41
+ elsif /^:[^ :]+:($| )/.match?(text) &&
42
+ (@prev_line.empty? || @middoc_docattr)
43
+ @pass = true
44
+ @middoc_docattr = true
45
+ end
46
+ @is_delim = /^\[(source|listing|literal|pass)\b/.match?(text)
47
+ @pass_delim = /^\[(pass)\b/.match?(text)
48
+ @prev_line = text.strip
49
+ end
50
+ end
51
+ end
52
+ end
data/lib/utils/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Metanorma
2
2
  module Utils
3
- VERSION = "1.7.7".freeze
3
+ VERSION = "1.8.0".freeze
4
4
  end
5
5
  end
@@ -24,7 +24,7 @@ Gem::Specification.new do |spec|
24
24
  f.match(%r{^(test|spec|features|bin|.github)/}) \
25
25
  || f.match(%r{Rakefile|bin/rspec})
26
26
  end
27
- spec.required_ruby_version = Gem::Requirement.new(">= 2.7.0")
27
+ spec.required_ruby_version = Gem::Requirement.new(">= 3.1.0")
28
28
 
29
29
  spec.add_dependency "asciidoctor", ">= 2"
30
30
  spec.add_dependency "concurrent-ruby"
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.7.7
4
+ version: 1.8.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-05-02 00:00:00.000000000 Z
11
+ date: 2024-07-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: asciidoctor
@@ -294,6 +294,7 @@ files:
294
294
  - lib/metanorma-utils.rb
295
295
  - lib/utils/hash_transform_keys.rb
296
296
  - lib/utils/image.rb
297
+ - lib/utils/linestatus.rb
297
298
  - lib/utils/log.rb
298
299
  - lib/utils/main.rb
299
300
  - lib/utils/namespace.rb
@@ -312,7 +313,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
312
313
  requirements:
313
314
  - - ">="
314
315
  - !ruby/object:Gem::Version
315
- version: 2.7.0
316
+ version: 3.1.0
316
317
  required_rubygems_version: !ruby/object:Gem::Requirement
317
318
  requirements:
318
319
  - - ">="