stepmod-utils 0.3.5 → 0.3.10
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/.github/workflows/release.yml +4 -3
- data/.rubocop.yml +1 -1
- data/Gemfile +3 -3
- data/Rakefile +1 -1
- data/exe/stepmod-annotate-all +17 -11
- data/exe/stepmod-build-resource-docs-cache +8 -7
- data/exe/stepmod-convert-express-description +6 -4
- data/exe/stepmod-convert-express-resource +6 -4
- data/exe/stepmod-extract-terms +99 -28
- data/exe/stepmod-find-express-files +8 -7
- data/lib/stepmod/utils/bibdata.rb +31 -35
- data/lib/stepmod/utils/cleaner.rb +3 -3
- data/lib/stepmod/utils/concept.rb +54 -36
- data/lib/stepmod/utils/converters/a.rb +6 -13
- data/lib/stepmod/utils/converters/blockquote.rb +4 -4
- data/lib/stepmod/utils/converters/br.rb +1 -1
- data/lib/stepmod/utils/converters/bypass.rb +33 -33
- data/lib/stepmod/utils/converters/clause_ref.rb +3 -3
- data/lib/stepmod/utils/converters/code.rb +1 -1
- data/lib/stepmod/utils/converters/comment.rb +5 -3
- data/lib/stepmod/utils/converters/dd.rb +2 -2
- data/lib/stepmod/utils/converters/def.rb +19 -19
- data/lib/stepmod/utils/converters/drop.rb +2 -2
- data/lib/stepmod/utils/converters/dt.rb +2 -2
- data/lib/stepmod/utils/converters/em.rb +1 -1
- data/lib/stepmod/utils/converters/em_express_description.rb +1 -1
- data/lib/stepmod/utils/converters/eqn.rb +28 -26
- data/lib/stepmod/utils/converters/example.rb +5 -6
- data/lib/stepmod/utils/converters/express_g.rb +10 -9
- data/lib/stepmod/utils/converters/express_ref.rb +2 -2
- data/lib/stepmod/utils/converters/express_ref_express_description.rb +3 -2
- data/lib/stepmod/utils/converters/ext_description.rb +1 -1
- data/lib/stepmod/utils/converters/figure.rb +3 -3
- data/lib/stepmod/utils/converters/fund_cons.rb +1 -1
- data/lib/stepmod/utils/converters/head.rb +3 -2
- data/lib/stepmod/utils/converters/hr.rb +2 -2
- data/lib/stepmod/utils/converters/ignore.rb +3 -3
- data/lib/stepmod/utils/converters/introduction.rb +1 -1
- data/lib/stepmod/utils/converters/module_ref.rb +7 -7
- data/lib/stepmod/utils/converters/note.rb +5 -6
- data/lib/stepmod/utils/converters/ol.rb +7 -5
- data/lib/stepmod/utils/converters/p.rb +2 -2
- data/lib/stepmod/utils/converters/pass_through.rb +2 -2
- data/lib/stepmod/utils/converters/q.rb +1 -1
- data/lib/stepmod/utils/converters/schema.rb +1 -1
- data/lib/stepmod/utils/converters/stem.rb +1 -1
- data/lib/stepmod/utils/converters/stepmod_ext_description.rb +20 -6
- data/lib/stepmod/utils/converters/strong.rb +7 -4
- data/lib/stepmod/utils/converters/sub.rb +2 -2
- data/lib/stepmod/utils/converters/sup.rb +2 -2
- data/lib/stepmod/utils/converters/synonym.rb +2 -2
- data/lib/stepmod/utils/converters/table.rb +7 -9
- data/lib/stepmod/utils/converters/term.rb +27 -9
- data/lib/stepmod/utils/converters/text.rb +11 -13
- data/lib/stepmod/utils/converters/uof.rb +3 -4
- data/lib/stepmod/utils/html_to_asciimath.rb +91 -90
- data/lib/stepmod/utils/smrl_description_converter.rb +34 -33
- data/lib/stepmod/utils/smrl_resource_converter.rb +50 -49
- data/lib/stepmod/utils/stepmod_definition_converter.rb +39 -38
- data/lib/stepmod/utils/stepmod_file_annotator.rb +26 -19
- data/lib/stepmod/utils/terms_extractor.rb +138 -86
- data/lib/stepmod/utils/version.rb +1 -1
- data/stepmod-utils.gemspec +11 -6
- metadata +62 -20
@@ -1,15 +1,14 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "stepmod/utils/converters/synonym"
|
4
4
|
|
5
5
|
module Stepmod
|
6
6
|
module Utils
|
7
7
|
module Converters
|
8
8
|
class Uof < ReverseAdoc::Converters::Base
|
9
|
-
def convert(
|
10
|
-
|
9
|
+
def convert(_node, _state = {})
|
11
10
|
# WARNING: <uof> tag content is deprecated
|
12
|
-
|
11
|
+
""
|
13
12
|
|
14
13
|
#
|
15
14
|
# <<~TEXT
|
@@ -6,7 +6,7 @@ module Stepmod
|
|
6
6
|
|
7
7
|
to_asciimath = Nokogiri::HTML.fragment(input, "UTF-8")
|
8
8
|
|
9
|
-
to_asciimath.css(
|
9
|
+
to_asciimath.css("i").each do |math_element|
|
10
10
|
# puts "HTML MATH!! #{math_element.to_xml}"
|
11
11
|
# puts "HTML MATH!! #{math_element.text}"
|
12
12
|
decoded = text_to_asciimath(math_element.text)
|
@@ -21,7 +21,7 @@ module Stepmod
|
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
|
-
to_asciimath.css(
|
24
|
+
to_asciimath.css("sub").each do |math_element|
|
25
25
|
case math_element.text.length
|
26
26
|
when 0
|
27
27
|
math_element.remove
|
@@ -30,7 +30,7 @@ module Stepmod
|
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
|
-
to_asciimath.css(
|
33
|
+
to_asciimath.css("sup").each do |math_element|
|
34
34
|
case math_element.text.length
|
35
35
|
when 0
|
36
36
|
math_element.remove
|
@@ -39,14 +39,14 @@ module Stepmod
|
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
42
|
-
to_asciimath.css(
|
43
|
-
element.css(
|
42
|
+
to_asciimath.css("ol").each do |element|
|
43
|
+
element.css("li").each do |li|
|
44
44
|
li.replace ". #{li.text}"
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
48
|
-
to_asciimath.css(
|
49
|
-
element.css(
|
48
|
+
to_asciimath.css("ul").each do |element|
|
49
|
+
element.css("li").each do |li|
|
50
50
|
li.replace "* #{li.text}"
|
51
51
|
end
|
52
52
|
end
|
@@ -57,7 +57,8 @@ module Stepmod
|
|
57
57
|
end
|
58
58
|
|
59
59
|
html_entities_to_stem(
|
60
|
-
to_asciimath.children.to_s.gsub(/\]stem:\[/,
|
60
|
+
to_asciimath.children.to_s.gsub(/\]stem:\[/, "").gsub(/<\/?[uo]l>/,
|
61
|
+
""),
|
61
62
|
)
|
62
63
|
end
|
63
64
|
|
@@ -66,91 +67,91 @@ module Stepmod
|
|
66
67
|
end
|
67
68
|
|
68
69
|
def html_entities_to_asciimath(x)
|
69
|
-
x.gsub("α", "alpha")
|
70
|
-
gsub("β", "beta")
|
71
|
-
gsub("γ", "gamma")
|
72
|
-
gsub("Γ", "Gamma")
|
73
|
-
gsub("δ", "delta")
|
74
|
-
gsub("Δ", "Delta")
|
75
|
-
gsub("ε", "epsilon")
|
76
|
-
gsub("ϵ", "varepsilon")
|
77
|
-
gsub("ζ", "zeta")
|
78
|
-
gsub("η", "eta")
|
79
|
-
gsub("θ", "theta")
|
80
|
-
gsub("Θ", "Theta")
|
81
|
-
gsub("ϑ", "vartheta")
|
82
|
-
gsub("ι", "iota")
|
83
|
-
gsub("κ", "kappa")
|
84
|
-
gsub("λ", "lambda")
|
85
|
-
gsub("Λ", "Lambda")
|
86
|
-
gsub("μ", "mu")
|
87
|
-
gsub("ν", "nu")
|
88
|
-
gsub("ξ", "xi")
|
89
|
-
gsub("Ξ", "Xi")
|
90
|
-
gsub("π", "pi")
|
91
|
-
gsub("Π", "Pi")
|
92
|
-
gsub("ρ", "rho")
|
93
|
-
gsub("β", "beta")
|
94
|
-
gsub("σ", "sigma")
|
95
|
-
gsub("Σ", "Sigma")
|
96
|
-
gsub("τ", "tau")
|
97
|
-
gsub("υ", "upsilon")
|
98
|
-
gsub("φ", "phi")
|
99
|
-
gsub("Φ", "Phi")
|
100
|
-
gsub("ϕ", "varphi")
|
101
|
-
gsub("χ", "chi")
|
102
|
-
gsub("ψ", "psi")
|
103
|
-
gsub("Ψ", "Psi")
|
104
|
-
gsub("ω", "omega")
|
105
|
-
gsub("χ", "χ")
|
106
|
-
gsub("×", "×")
|
107
|
-
gsub("Σ", "Σ")
|
108
|
-
gsub("ρ", "ρ")
|
109
|
-
gsub("σ", "σ")
|
110
|
-
gsub("λ", "λ")
|
111
|
-
gsub("τ", "τ")
|
112
|
-
gsub("∂", "∂")
|
113
|
-
gsub("≤", "≤")
|
114
|
-
gsub("≥", "≥")
|
70
|
+
x.gsub("α", "alpha")
|
71
|
+
.gsub("β", "beta")
|
72
|
+
.gsub("γ", "gamma")
|
73
|
+
.gsub("Γ", "Gamma")
|
74
|
+
.gsub("δ", "delta")
|
75
|
+
.gsub("Δ", "Delta")
|
76
|
+
.gsub("ε", "epsilon")
|
77
|
+
.gsub("ϵ", "varepsilon")
|
78
|
+
.gsub("ζ", "zeta")
|
79
|
+
.gsub("η", "eta")
|
80
|
+
.gsub("θ", "theta")
|
81
|
+
.gsub("Θ", "Theta")
|
82
|
+
.gsub("ϑ", "vartheta")
|
83
|
+
.gsub("ι", "iota")
|
84
|
+
.gsub("κ", "kappa")
|
85
|
+
.gsub("λ", "lambda")
|
86
|
+
.gsub("Λ", "Lambda")
|
87
|
+
.gsub("μ", "mu")
|
88
|
+
.gsub("ν", "nu")
|
89
|
+
.gsub("ξ", "xi")
|
90
|
+
.gsub("Ξ", "Xi")
|
91
|
+
.gsub("π", "pi")
|
92
|
+
.gsub("Π", "Pi")
|
93
|
+
.gsub("ρ", "rho")
|
94
|
+
.gsub("β", "beta")
|
95
|
+
.gsub("σ", "sigma")
|
96
|
+
.gsub("Σ", "Sigma")
|
97
|
+
.gsub("τ", "tau")
|
98
|
+
.gsub("υ", "upsilon")
|
99
|
+
.gsub("φ", "phi")
|
100
|
+
.gsub("Φ", "Phi")
|
101
|
+
.gsub("ϕ", "varphi")
|
102
|
+
.gsub("χ", "chi")
|
103
|
+
.gsub("ψ", "psi")
|
104
|
+
.gsub("Ψ", "Psi")
|
105
|
+
.gsub("ω", "omega")
|
106
|
+
.gsub("χ", "χ")
|
107
|
+
.gsub("×", "×")
|
108
|
+
.gsub("Σ", "Σ")
|
109
|
+
.gsub("ρ", "ρ")
|
110
|
+
.gsub("σ", "σ")
|
111
|
+
.gsub("λ", "λ")
|
112
|
+
.gsub("τ", "τ")
|
113
|
+
.gsub("∂", "∂")
|
114
|
+
.gsub("≤", "≤")
|
115
|
+
.gsub("≥", "≥")
|
115
116
|
end
|
116
117
|
|
117
118
|
def html_entities_to_stem(x)
|
118
|
-
x.gsub("α", "stem:[alpha]")
|
119
|
-
gsub("β", "stem:[beta]")
|
120
|
-
gsub("γ", "stem:[gamma]")
|
121
|
-
gsub("Γ", "stem:[Gamma]")
|
122
|
-
gsub("δ", "stem:[delta]")
|
123
|
-
gsub("Δ", "stem:[Delta]")
|
124
|
-
gsub("ε", "stem:[epsilon]")
|
125
|
-
gsub("ϵ", "stem:[varepsilon]")
|
126
|
-
gsub("ζ", "stem:[zeta]")
|
127
|
-
gsub("η", "stem:[eta]")
|
128
|
-
gsub("θ", "stem:[theta]")
|
129
|
-
gsub("Θ", "stem:[Theta]")
|
130
|
-
gsub("ϑ", "stem:[vartheta]")
|
131
|
-
gsub("ι", "stem:[iota]")
|
132
|
-
gsub("κ", "stem:[kappa]")
|
133
|
-
gsub("λ", "stem:[lambda]")
|
134
|
-
gsub("Λ", "stem:[Lambda]")
|
135
|
-
gsub("μ", "stem:[mu]")
|
136
|
-
gsub("ν", "stem:[nu]")
|
137
|
-
gsub("ξ", "stem:[xi]")
|
138
|
-
gsub("Ξ", "stem:[Xi]")
|
139
|
-
gsub("π", "stem:[pi]")
|
140
|
-
gsub("Π", "stem:[Pi]")
|
141
|
-
gsub("ρ", "stem:[rho]")
|
142
|
-
gsub("β", "stem:[beta]")
|
143
|
-
gsub("σ", "stem:[sigma]")
|
144
|
-
gsub("Σ", "stem:[Sigma]")
|
145
|
-
gsub("τ", "stem:[tau]")
|
146
|
-
gsub("υ", "stem:[upsilon]")
|
147
|
-
gsub("φ", "stem:[phi]")
|
148
|
-
gsub("Φ", "stem:[Phi]")
|
149
|
-
gsub("ϕ", "stem:[varphi]")
|
150
|
-
gsub("χ", "stem:[chi]")
|
151
|
-
gsub("ψ", "stem:[psi]")
|
152
|
-
gsub("Ψ", "stem:[Psi]")
|
153
|
-
gsub("ω", "stem:[omega]")
|
119
|
+
x.gsub("α", "stem:[alpha]")
|
120
|
+
.gsub("β", "stem:[beta]")
|
121
|
+
.gsub("γ", "stem:[gamma]")
|
122
|
+
.gsub("Γ", "stem:[Gamma]")
|
123
|
+
.gsub("δ", "stem:[delta]")
|
124
|
+
.gsub("Δ", "stem:[Delta]")
|
125
|
+
.gsub("ε", "stem:[epsilon]")
|
126
|
+
.gsub("ϵ", "stem:[varepsilon]")
|
127
|
+
.gsub("ζ", "stem:[zeta]")
|
128
|
+
.gsub("η", "stem:[eta]")
|
129
|
+
.gsub("θ", "stem:[theta]")
|
130
|
+
.gsub("Θ", "stem:[Theta]")
|
131
|
+
.gsub("ϑ", "stem:[vartheta]")
|
132
|
+
.gsub("ι", "stem:[iota]")
|
133
|
+
.gsub("κ", "stem:[kappa]")
|
134
|
+
.gsub("λ", "stem:[lambda]")
|
135
|
+
.gsub("Λ", "stem:[Lambda]")
|
136
|
+
.gsub("μ", "stem:[mu]")
|
137
|
+
.gsub("ν", "stem:[nu]")
|
138
|
+
.gsub("ξ", "stem:[xi]")
|
139
|
+
.gsub("Ξ", "stem:[Xi]")
|
140
|
+
.gsub("π", "stem:[pi]")
|
141
|
+
.gsub("Π", "stem:[Pi]")
|
142
|
+
.gsub("ρ", "stem:[rho]")
|
143
|
+
.gsub("β", "stem:[beta]")
|
144
|
+
.gsub("σ", "stem:[sigma]")
|
145
|
+
.gsub("Σ", "stem:[Sigma]")
|
146
|
+
.gsub("τ", "stem:[tau]")
|
147
|
+
.gsub("υ", "stem:[upsilon]")
|
148
|
+
.gsub("φ", "stem:[phi]")
|
149
|
+
.gsub("Φ", "stem:[Phi]")
|
150
|
+
.gsub("ϕ", "stem:[varphi]")
|
151
|
+
.gsub("χ", "stem:[chi]")
|
152
|
+
.gsub("ψ", "stem:[psi]")
|
153
|
+
.gsub("Ψ", "stem:[Psi]")
|
154
|
+
.gsub("ω", "stem:[omega]")
|
154
155
|
end
|
155
156
|
end
|
156
157
|
end
|
@@ -1,43 +1,44 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
7
|
-
require
|
8
|
-
require
|
9
|
-
require
|
10
|
-
require
|
11
|
-
require
|
12
|
-
require
|
13
|
-
require
|
14
|
-
require
|
15
|
-
require
|
16
|
-
require
|
17
|
-
require
|
18
|
-
require
|
19
|
-
require
|
20
|
-
require
|
21
|
-
require
|
22
|
-
require
|
23
|
-
require
|
24
|
-
require
|
25
|
-
require
|
26
|
-
require
|
3
|
+
require "reverse_adoc"
|
4
|
+
require "stepmod/utils/converters/a"
|
5
|
+
require "stepmod/utils/converters/blockquote"
|
6
|
+
require "stepmod/utils/converters/br"
|
7
|
+
require "stepmod/utils/converters/bypass"
|
8
|
+
require "stepmod/utils/converters/code"
|
9
|
+
require "stepmod/utils/converters/drop"
|
10
|
+
require "stepmod/utils/converters/em_express_description"
|
11
|
+
require "stepmod/utils/converters/example"
|
12
|
+
require "stepmod/utils/converters/express_ref_express_description"
|
13
|
+
require "stepmod/utils/converters/ext_description"
|
14
|
+
require "stepmod/utils/converters/ext_descriptions"
|
15
|
+
require "stepmod/utils/converters/head"
|
16
|
+
require "stepmod/utils/converters/hr"
|
17
|
+
require "stepmod/utils/converters/ignore"
|
18
|
+
require "stepmod/utils/converters/note"
|
19
|
+
require "stepmod/utils/converters/p"
|
20
|
+
require "stepmod/utils/converters/pass_through"
|
21
|
+
require "stepmod/utils/converters/q"
|
22
|
+
require "stepmod/utils/converters/strong"
|
23
|
+
require "stepmod/utils/converters/sub"
|
24
|
+
require "stepmod/utils/converters/sup"
|
25
|
+
require "stepmod/utils/converters/text"
|
26
|
+
require "stepmod/utils/cleaner"
|
27
27
|
|
28
28
|
module Stepmod
|
29
29
|
module Utils
|
30
30
|
class SmrlDescriptionConverter
|
31
31
|
def self.convert(input, options = {})
|
32
|
-
root =
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
32
|
+
root = case input
|
33
|
+
when String
|
34
|
+
Nokogiri::XML(input).root
|
35
|
+
when Nokogiri::XML::Document
|
36
|
+
input.root
|
37
|
+
when Nokogiri::XML::Node
|
38
|
+
input
|
39
|
+
end
|
39
40
|
|
40
|
-
root || (return
|
41
|
+
root || (return "")
|
41
42
|
|
42
43
|
ReverseAdoc.config.with(options) do
|
43
44
|
result = ReverseAdoc::Converters.lookup(root.name).convert(root)
|
@@ -46,4 +47,4 @@ module Stepmod
|
|
46
47
|
end
|
47
48
|
end
|
48
49
|
end
|
49
|
-
end
|
50
|
+
end
|
@@ -1,61 +1,62 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
7
|
-
require
|
8
|
-
require
|
9
|
-
require
|
10
|
-
require
|
11
|
-
require
|
12
|
-
require
|
13
|
-
require
|
14
|
-
require
|
15
|
-
require
|
16
|
-
require
|
17
|
-
require
|
18
|
-
require
|
19
|
-
require
|
20
|
-
require
|
21
|
-
require
|
22
|
-
require
|
23
|
-
require
|
24
|
-
require
|
25
|
-
require
|
26
|
-
require
|
27
|
-
require
|
28
|
-
require
|
29
|
-
require
|
30
|
-
require
|
31
|
-
require
|
32
|
-
require
|
33
|
-
require
|
34
|
-
require
|
35
|
-
require
|
36
|
-
require
|
37
|
-
require
|
3
|
+
require "reverse_adoc"
|
4
|
+
require "reverse_adoc/converters/bypass"
|
5
|
+
require "reverse_adoc/converters/pass_through"
|
6
|
+
require "stepmod/utils/converters/a"
|
7
|
+
require "stepmod/utils/converters/blockquote"
|
8
|
+
require "stepmod/utils/converters/br"
|
9
|
+
require "stepmod/utils/converters/bypass"
|
10
|
+
require "stepmod/utils/converters/code"
|
11
|
+
require "stepmod/utils/converters/comment"
|
12
|
+
require "stepmod/utils/converters/dd"
|
13
|
+
require "stepmod/utils/converters/dl"
|
14
|
+
require "stepmod/utils/converters/dt"
|
15
|
+
require "stepmod/utils/converters/drop"
|
16
|
+
require "stepmod/utils/converters/example"
|
17
|
+
require "stepmod/utils/converters/express_g"
|
18
|
+
require "stepmod/utils/converters/fund_cons"
|
19
|
+
require "stepmod/utils/converters/eqn"
|
20
|
+
require "stepmod/utils/converters/head"
|
21
|
+
require "stepmod/utils/converters/hr"
|
22
|
+
require "stepmod/utils/converters/ignore"
|
23
|
+
require "stepmod/utils/converters/introduction"
|
24
|
+
require "stepmod/utils/converters/note"
|
25
|
+
require "stepmod/utils/converters/ol"
|
26
|
+
require "stepmod/utils/converters/p"
|
27
|
+
require "stepmod/utils/converters/pass_through"
|
28
|
+
require "stepmod/utils/converters/q"
|
29
|
+
require "stepmod/utils/converters/resource"
|
30
|
+
require "stepmod/utils/converters/schema_diag"
|
31
|
+
require "stepmod/utils/converters/schema"
|
32
|
+
require "stepmod/utils/converters/strong"
|
33
|
+
require "stepmod/utils/converters/sub"
|
34
|
+
require "stepmod/utils/converters/sup"
|
35
|
+
require "stepmod/utils/converters/table"
|
36
|
+
require "stepmod/utils/converters/text"
|
37
|
+
require "stepmod/utils/cleaner"
|
38
38
|
|
39
|
-
require
|
40
|
-
require
|
41
|
-
require
|
42
|
-
require
|
43
|
-
require
|
44
|
-
require
|
39
|
+
require "reverse_adoc/converters/figure"
|
40
|
+
require "reverse_adoc/converters/img"
|
41
|
+
require "reverse_adoc/converters/li"
|
42
|
+
require "reverse_adoc/converters/tr"
|
43
|
+
require "reverse_adoc/converters/td"
|
44
|
+
require "reverse_adoc/converters/th"
|
45
45
|
|
46
46
|
module Stepmod
|
47
47
|
module Utils
|
48
48
|
class SmrlResourceConverter
|
49
49
|
def self.convert(input, options = {})
|
50
|
-
root =
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
50
|
+
root = case input
|
51
|
+
when String
|
52
|
+
Nokogiri::XML(input).root
|
53
|
+
when Nokogiri::XML::Document
|
54
|
+
input.root
|
55
|
+
when Nokogiri::XML::Node
|
56
|
+
input
|
57
|
+
end
|
57
58
|
|
58
|
-
root || (return
|
59
|
+
root || (return "")
|
59
60
|
|
60
61
|
ReverseAdoc.config.with(options) do
|
61
62
|
result = ReverseAdoc::Converters.lookup(root.name).convert(root)
|
@@ -1,41 +1,40 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
7
|
-
require
|
8
|
-
require
|
9
|
-
require
|
10
|
-
require
|
11
|
-
require
|
12
|
-
require
|
13
|
-
require
|
14
|
-
require
|
15
|
-
require
|
16
|
-
require
|
17
|
-
require
|
18
|
-
require
|
19
|
-
require
|
20
|
-
|
21
|
-
require 'reverse_adoc/converters/a'
|
22
|
-
require 'reverse_adoc/converters/blockquote'
|
23
|
-
require 'reverse_adoc/converters/bypass'
|
24
|
-
require 'reverse_adoc/converters/br'
|
25
|
-
require 'reverse_adoc/converters/code'
|
26
|
-
require 'reverse_adoc/converters/drop'
|
27
|
-
require 'reverse_adoc/converters/head'
|
28
|
-
require 'reverse_adoc/converters/hr'
|
29
|
-
require 'reverse_adoc/converters/ignore'
|
30
|
-
require 'reverse_adoc/converters/li'
|
31
|
-
require 'reverse_adoc/converters/p'
|
32
|
-
require 'reverse_adoc/converters/pass_through'
|
33
|
-
require 'reverse_adoc/converters/q'
|
34
|
-
require 'reverse_adoc/converters/strong'
|
35
|
-
require 'reverse_adoc/converters/sup'
|
36
|
-
require 'reverse_adoc/converters/sub'
|
37
|
-
require 'reverse_adoc/converters/text'
|
3
|
+
require "reverse_adoc"
|
4
|
+
require "stepmod/utils/converters/arm"
|
5
|
+
require "stepmod/utils/converters/clause_ref"
|
6
|
+
require "stepmod/utils/converters/express_ref"
|
7
|
+
require "stepmod/utils/converters/module_ref"
|
8
|
+
require "stepmod/utils/converters/def"
|
9
|
+
require "stepmod/utils/converters/definition"
|
10
|
+
require "stepmod/utils/converters/em"
|
11
|
+
require "stepmod/utils/converters/example"
|
12
|
+
require "stepmod/utils/converters/note"
|
13
|
+
require "stepmod/utils/converters/ol"
|
14
|
+
require "stepmod/utils/converters/stem"
|
15
|
+
require "stepmod/utils/converters/stepmod_ext_description"
|
16
|
+
require "stepmod/utils/converters/term"
|
17
|
+
require "stepmod/utils/converters/synonym"
|
18
|
+
require "stepmod/utils/converters/uof"
|
19
|
+
require "stepmod/utils/converters/figure"
|
38
20
|
|
21
|
+
require "reverse_adoc/converters/a"
|
22
|
+
require "reverse_adoc/converters/blockquote"
|
23
|
+
require "reverse_adoc/converters/bypass"
|
24
|
+
require "reverse_adoc/converters/br"
|
25
|
+
require "reverse_adoc/converters/code"
|
26
|
+
require "reverse_adoc/converters/drop"
|
27
|
+
require "reverse_adoc/converters/head"
|
28
|
+
require "reverse_adoc/converters/hr"
|
29
|
+
require "reverse_adoc/converters/ignore"
|
30
|
+
require "reverse_adoc/converters/li"
|
31
|
+
require "reverse_adoc/converters/p"
|
32
|
+
require "reverse_adoc/converters/pass_through"
|
33
|
+
require "reverse_adoc/converters/q"
|
34
|
+
require "reverse_adoc/converters/strong"
|
35
|
+
require "reverse_adoc/converters/sup"
|
36
|
+
require "reverse_adoc/converters/sub"
|
37
|
+
require "reverse_adoc/converters/text"
|
39
38
|
|
40
39
|
module Stepmod
|
41
40
|
module Utils
|
@@ -50,11 +49,13 @@ module Stepmod
|
|
50
49
|
input
|
51
50
|
end
|
52
51
|
|
53
|
-
return
|
52
|
+
return "" unless root
|
54
53
|
|
55
54
|
ReverseAdoc.config.with(options) do
|
56
|
-
result = ReverseAdoc::Converters.lookup(root.name).convert(root,
|
57
|
-
|
55
|
+
result = ReverseAdoc::Converters.lookup(root.name).convert(root,
|
56
|
+
options)
|
57
|
+
return "" unless result
|
58
|
+
|
58
59
|
ReverseAdoc.cleaner.tidy(result.dup)
|
59
60
|
end
|
60
61
|
end
|
@@ -1,6 +1,6 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
1
|
+
require "json"
|
2
|
+
require "stepmod/utils/smrl_description_converter"
|
3
|
+
require "stepmod/utils/smrl_resource_converter"
|
4
4
|
|
5
5
|
module Stepmod
|
6
6
|
module Utils
|
@@ -17,35 +17,41 @@ module Stepmod
|
|
17
17
|
|
18
18
|
def call
|
19
19
|
match = File.basename(express_file).match('^(arm|mim|bom)\.exp$')
|
20
|
-
descriptions_base = match ? "#{match.captures[0]}_descriptions.xml" :
|
21
|
-
descriptions_file = File.join(File.dirname(express_file),
|
20
|
+
descriptions_base = match ? "#{match.captures[0]}_descriptions.xml" : "descriptions.xml"
|
21
|
+
descriptions_file = File.join(File.dirname(express_file),
|
22
|
+
descriptions_base)
|
22
23
|
output_express = File.read(express_file)
|
23
24
|
resource_docs_cache = JSON.parse(File.read(resource_docs_cache_file))
|
24
25
|
|
25
26
|
if File.exists?(descriptions_file)
|
26
27
|
descriptions = Nokogiri::XML(File.read(descriptions_file)).root
|
27
28
|
added_resource_descriptions = {}
|
28
|
-
descriptions.xpath(
|
29
|
+
descriptions.xpath("ext_description").each do |description|
|
29
30
|
# Add base resource from linked path if exists, eg "language_schema.language.wr:WR1" -> "language_schema"
|
30
|
-
base_linked = description[
|
31
|
+
base_linked = description["linkend"].to_s.split(".").first
|
31
32
|
if added_resource_descriptions[base_linked].nil?
|
32
|
-
base_reource_doc_dir = resource_docs_cache[description[
|
33
|
+
base_reource_doc_dir = resource_docs_cache[description["linkend"].to_s.split(".").first]
|
33
34
|
if base_reource_doc_dir
|
34
|
-
output_express << convert_from_resource_file(
|
35
|
+
output_express << convert_from_resource_file(
|
36
|
+
base_reource_doc_dir, stepmod_dir, base_linked, descriptions_file
|
37
|
+
)
|
35
38
|
end
|
36
39
|
added_resource_descriptions[base_linked] = true
|
37
40
|
end
|
38
|
-
resource_docs_dir = resource_docs_cache[description[
|
41
|
+
resource_docs_dir = resource_docs_cache[description["linkend"]]
|
39
42
|
# Convert content description
|
40
43
|
# when a schema description is available from resource.xml and also descriptions.xml, the description from resource.xml is only used.
|
41
44
|
# https://github.com/metanorma/annotated-express/issues/32#issuecomment-792609078
|
42
45
|
if description.text.strip.length.positive? && resource_docs_dir.nil?
|
43
|
-
output_express << convert_from_description_text(
|
46
|
+
output_express << convert_from_description_text(
|
47
|
+
descriptions_file, description
|
48
|
+
)
|
44
49
|
end
|
45
50
|
# Add converted description from exact linked path
|
46
|
-
if resource_docs_dir && added_resource_descriptions[description[
|
47
|
-
output_express << convert_from_resource_file(resource_docs_dir,
|
48
|
-
|
51
|
+
if resource_docs_dir && added_resource_descriptions[description["linkend"]].nil?
|
52
|
+
output_express << convert_from_resource_file(resource_docs_dir,
|
53
|
+
stepmod_dir, description["linkend"], descriptions_file)
|
54
|
+
added_resource_descriptions[description["linkend"]] = true
|
49
55
|
end
|
50
56
|
end
|
51
57
|
end
|
@@ -57,20 +63,21 @@ module Stepmod
|
|
57
63
|
|
58
64
|
def convert_from_description_text(descriptions_file, description)
|
59
65
|
Dir.chdir(File.dirname(descriptions_file)) do
|
60
|
-
wrapper = "<ext_descriptions>#{description
|
61
|
-
"\n
|
66
|
+
wrapper = "<ext_descriptions>#{description}</ext_descriptions>"
|
67
|
+
"\n#{Stepmod::Utils::SmrlDescriptionConverter.convert(wrapper)}"
|
62
68
|
end
|
63
69
|
end
|
64
70
|
|
65
71
|
def convert_from_resource_file(resource_docs_dir, stepmod_dir, linked, descriptions_file)
|
66
|
-
resource_docs_file = File.join(stepmod_dir,
|
72
|
+
resource_docs_file = File.join(stepmod_dir, "data/resource_docs",
|
73
|
+
resource_docs_dir, "resource.xml")
|
67
74
|
puts(resource_docs_file)
|
68
75
|
resource_docs = Nokogiri::XML(File.read(resource_docs_file)).root
|
69
76
|
schema = resource_docs.xpath("schema[@name='#{linked}']")
|
70
77
|
|
71
78
|
Dir.chdir(File.dirname(descriptions_file)) do
|
72
|
-
wrapper = "<resource>#{schema
|
73
|
-
"\n
|
79
|
+
wrapper = "<resource>#{schema}</resource>"
|
80
|
+
"\n#{Stepmod::Utils::SmrlResourceConverter.convert(wrapper)}"
|
74
81
|
end
|
75
82
|
end
|
76
83
|
end
|