metanorma-utils 1.7.7 → 1.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/metanorma-utils.rb +1 -0
- data/lib/utils/linestatus.rb +52 -0
- data/lib/utils/version.rb +1 -1
- data/metanorma-utils.gemspec +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5d732ef5b43563be4481894015cde861af9d10a6c9ba3f27f9a7491fc5e035c8
|
4
|
+
data.tar.gz: aaeea69fc4ebc1b02ff5714f31ccbad138ec7a9dc3d05afba575aef5b070da54
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 358711ec61605ad726879b5b4c26dca54788d8e11772ada1251fce68b5ed47b768eeaa3683a0786475c7c6ae9e7d3266d00d6f139148ac4caba31f0c568cd34d
|
7
|
+
data.tar.gz: 977160c2e5eadd24482b5433b095a865ab301f544ad2659426704910f2e963a29a1202af6f230010f4dac2b4d6a7da7b1fc1ac57e5b8adf7afc16bea9fcb5e2a
|
data/lib/metanorma-utils.rb
CHANGED
@@ -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
data/metanorma-utils.gemspec
CHANGED
@@ -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(">=
|
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.
|
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-
|
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:
|
316
|
+
version: 3.1.0
|
316
317
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
317
318
|
requirements:
|
318
319
|
- - ">="
|