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.
Files changed (66) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/rake.yml +1 -1
  3. data/.github/workflows/release.yml +4 -3
  4. data/.rubocop.yml +1 -1
  5. data/Gemfile +3 -3
  6. data/Rakefile +1 -1
  7. data/exe/stepmod-annotate-all +17 -11
  8. data/exe/stepmod-build-resource-docs-cache +8 -7
  9. data/exe/stepmod-convert-express-description +6 -4
  10. data/exe/stepmod-convert-express-resource +6 -4
  11. data/exe/stepmod-extract-terms +99 -28
  12. data/exe/stepmod-find-express-files +8 -7
  13. data/lib/stepmod/utils/bibdata.rb +31 -35
  14. data/lib/stepmod/utils/cleaner.rb +3 -3
  15. data/lib/stepmod/utils/concept.rb +54 -36
  16. data/lib/stepmod/utils/converters/a.rb +6 -13
  17. data/lib/stepmod/utils/converters/blockquote.rb +4 -4
  18. data/lib/stepmod/utils/converters/br.rb +1 -1
  19. data/lib/stepmod/utils/converters/bypass.rb +33 -33
  20. data/lib/stepmod/utils/converters/clause_ref.rb +3 -3
  21. data/lib/stepmod/utils/converters/code.rb +1 -1
  22. data/lib/stepmod/utils/converters/comment.rb +5 -3
  23. data/lib/stepmod/utils/converters/dd.rb +2 -2
  24. data/lib/stepmod/utils/converters/def.rb +19 -19
  25. data/lib/stepmod/utils/converters/drop.rb +2 -2
  26. data/lib/stepmod/utils/converters/dt.rb +2 -2
  27. data/lib/stepmod/utils/converters/em.rb +1 -1
  28. data/lib/stepmod/utils/converters/em_express_description.rb +1 -1
  29. data/lib/stepmod/utils/converters/eqn.rb +28 -26
  30. data/lib/stepmod/utils/converters/example.rb +5 -6
  31. data/lib/stepmod/utils/converters/express_g.rb +10 -9
  32. data/lib/stepmod/utils/converters/express_ref.rb +2 -2
  33. data/lib/stepmod/utils/converters/express_ref_express_description.rb +3 -2
  34. data/lib/stepmod/utils/converters/ext_description.rb +1 -1
  35. data/lib/stepmod/utils/converters/figure.rb +3 -3
  36. data/lib/stepmod/utils/converters/fund_cons.rb +1 -1
  37. data/lib/stepmod/utils/converters/head.rb +3 -2
  38. data/lib/stepmod/utils/converters/hr.rb +2 -2
  39. data/lib/stepmod/utils/converters/ignore.rb +3 -3
  40. data/lib/stepmod/utils/converters/introduction.rb +1 -1
  41. data/lib/stepmod/utils/converters/module_ref.rb +7 -7
  42. data/lib/stepmod/utils/converters/note.rb +5 -6
  43. data/lib/stepmod/utils/converters/ol.rb +7 -5
  44. data/lib/stepmod/utils/converters/p.rb +2 -2
  45. data/lib/stepmod/utils/converters/pass_through.rb +2 -2
  46. data/lib/stepmod/utils/converters/q.rb +1 -1
  47. data/lib/stepmod/utils/converters/schema.rb +1 -1
  48. data/lib/stepmod/utils/converters/stem.rb +1 -1
  49. data/lib/stepmod/utils/converters/stepmod_ext_description.rb +20 -6
  50. data/lib/stepmod/utils/converters/strong.rb +7 -4
  51. data/lib/stepmod/utils/converters/sub.rb +2 -2
  52. data/lib/stepmod/utils/converters/sup.rb +2 -2
  53. data/lib/stepmod/utils/converters/synonym.rb +2 -2
  54. data/lib/stepmod/utils/converters/table.rb +7 -9
  55. data/lib/stepmod/utils/converters/term.rb +27 -9
  56. data/lib/stepmod/utils/converters/text.rb +11 -13
  57. data/lib/stepmod/utils/converters/uof.rb +3 -4
  58. data/lib/stepmod/utils/html_to_asciimath.rb +91 -90
  59. data/lib/stepmod/utils/smrl_description_converter.rb +34 -33
  60. data/lib/stepmod/utils/smrl_resource_converter.rb +50 -49
  61. data/lib/stepmod/utils/stepmod_definition_converter.rb +39 -38
  62. data/lib/stepmod/utils/stepmod_file_annotator.rb +26 -19
  63. data/lib/stepmod/utils/terms_extractor.rb +138 -86
  64. data/lib/stepmod/utils/version.rb +1 -1
  65. data/stepmod-utils.gemspec +11 -6
  66. metadata +62 -20
@@ -1,15 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'stepmod/utils/converters/synonym'
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(node, state = {})
10
-
9
+ def convert(_node, _state = {})
11
10
  # WARNING: <uof> tag content is deprecated
12
- return ""
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('i').each do |math_element|
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('sub').each do |math_element|
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('sup').each do |math_element|
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('ol').each do |element|
43
- element.css('li').each do |li|
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('ul').each do |element|
49
- element.css('li').each do |li|
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:\[/, '').gsub(/<\/?[uo]l>/, '')
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;", "alpha").
70
- gsub("&beta;", "beta").
71
- gsub("&gamma;", "gamma").
72
- gsub("&Gamma;", "Gamma").
73
- gsub("&delta;", "delta").
74
- gsub("&Delta;", "Delta").
75
- gsub("&epsilon;", "epsilon").
76
- gsub("&varepsilon;", "varepsilon").
77
- gsub("&zeta;", "zeta").
78
- gsub("&eta;", "eta").
79
- gsub("&theta;", "theta").
80
- gsub("&Theta;", "Theta").
81
- gsub("&vartheta;", "vartheta").
82
- gsub("&iota;", "iota").
83
- gsub("&kappa;", "kappa").
84
- gsub("&lambda;", "lambda").
85
- gsub("&Lambda;", "Lambda").
86
- gsub("&mu;", "mu").
87
- gsub("&nu;", "nu").
88
- gsub("&xi;", "xi").
89
- gsub("&Xi;", "Xi").
90
- gsub("&pi;", "pi").
91
- gsub("&Pi;", "Pi").
92
- gsub("&rho;", "rho").
93
- gsub("&beta;", "beta").
94
- gsub("&sigma;", "sigma").
95
- gsub("&Sigma;", "Sigma").
96
- gsub("&tau;", "tau").
97
- gsub("&upsilon;", "upsilon").
98
- gsub("&phi;", "phi").
99
- gsub("&Phi;", "Phi").
100
- gsub("&varphi;", "varphi").
101
- gsub("&chi;", "chi").
102
- gsub("&psi;", "psi").
103
- gsub("&Psi;", "Psi").
104
- gsub("&omega;", "omega")
105
- gsub("&#967", "χ").
106
- gsub("&#215", "×").
107
- gsub("&#931", "Σ").
108
- gsub("&#961", "ρ").
109
- gsub("&#963", "σ").
110
- gsub("&#955", "λ").
111
- gsub("&#964", "τ").
112
- gsub("&#8706", "∂").
113
- gsub("&#8804", "≤").
114
- gsub("&#8805", "≥")
70
+ x.gsub("&alpha;", "alpha")
71
+ .gsub("&beta;", "beta")
72
+ .gsub("&gamma;", "gamma")
73
+ .gsub("&Gamma;", "Gamma")
74
+ .gsub("&delta;", "delta")
75
+ .gsub("&Delta;", "Delta")
76
+ .gsub("&epsilon;", "epsilon")
77
+ .gsub("&varepsilon;", "varepsilon")
78
+ .gsub("&zeta;", "zeta")
79
+ .gsub("&eta;", "eta")
80
+ .gsub("&theta;", "theta")
81
+ .gsub("&Theta;", "Theta")
82
+ .gsub("&vartheta;", "vartheta")
83
+ .gsub("&iota;", "iota")
84
+ .gsub("&kappa;", "kappa")
85
+ .gsub("&lambda;", "lambda")
86
+ .gsub("&Lambda;", "Lambda")
87
+ .gsub("&mu;", "mu")
88
+ .gsub("&nu;", "nu")
89
+ .gsub("&xi;", "xi")
90
+ .gsub("&Xi;", "Xi")
91
+ .gsub("&pi;", "pi")
92
+ .gsub("&Pi;", "Pi")
93
+ .gsub("&rho;", "rho")
94
+ .gsub("&beta;", "beta")
95
+ .gsub("&sigma;", "sigma")
96
+ .gsub("&Sigma;", "Sigma")
97
+ .gsub("&tau;", "tau")
98
+ .gsub("&upsilon;", "upsilon")
99
+ .gsub("&phi;", "phi")
100
+ .gsub("&Phi;", "Phi")
101
+ .gsub("&varphi;", "varphi")
102
+ .gsub("&chi;", "chi")
103
+ .gsub("&psi;", "psi")
104
+ .gsub("&Psi;", "Psi")
105
+ .gsub("&omega;", "omega")
106
+ .gsub("&#967", "χ")
107
+ .gsub("&#215", "×")
108
+ .gsub("&#931", "Σ")
109
+ .gsub("&#961", "ρ")
110
+ .gsub("&#963", "σ")
111
+ .gsub("&#955", "λ")
112
+ .gsub("&#964", "τ")
113
+ .gsub("&#8706", "∂")
114
+ .gsub("&#8804", "≤")
115
+ .gsub("&#8805", "≥")
115
116
  end
116
117
 
117
118
  def html_entities_to_stem(x)
118
- x.gsub("&alpha;", "stem:[alpha]").
119
- gsub("&beta;", "stem:[beta]").
120
- gsub("&gamma;", "stem:[gamma]").
121
- gsub("&Gamma;", "stem:[Gamma]").
122
- gsub("&delta;", "stem:[delta]").
123
- gsub("&Delta;", "stem:[Delta]").
124
- gsub("&epsilon;", "stem:[epsilon]").
125
- gsub("&varepsilon;", "stem:[varepsilon]").
126
- gsub("&zeta;", "stem:[zeta]").
127
- gsub("&eta;", "stem:[eta]").
128
- gsub("&theta;", "stem:[theta]").
129
- gsub("&Theta;", "stem:[Theta]").
130
- gsub("&vartheta;", "stem:[vartheta]").
131
- gsub("&iota;", "stem:[iota]").
132
- gsub("&kappa;", "stem:[kappa]").
133
- gsub("&lambda;", "stem:[lambda]").
134
- gsub("&Lambda;", "stem:[Lambda]").
135
- gsub("&mu;", "stem:[mu]").
136
- gsub("&nu;", "stem:[nu]").
137
- gsub("&xi;", "stem:[xi]").
138
- gsub("&Xi;", "stem:[Xi]").
139
- gsub("&pi;", "stem:[pi]").
140
- gsub("&Pi;", "stem:[Pi]").
141
- gsub("&rho;", "stem:[rho]").
142
- gsub("&beta;", "stem:[beta]").
143
- gsub("&sigma;", "stem:[sigma]").
144
- gsub("&Sigma;", "stem:[Sigma]").
145
- gsub("&tau;", "stem:[tau]").
146
- gsub("&upsilon;", "stem:[upsilon]").
147
- gsub("&phi;", "stem:[phi]").
148
- gsub("&Phi;", "stem:[Phi]").
149
- gsub("&varphi;", "stem:[varphi]").
150
- gsub("&chi;", "stem:[chi]").
151
- gsub("&psi;", "stem:[psi]").
152
- gsub("&Psi;", "stem:[Psi]").
153
- gsub("&omega;", "stem:[omega]")
119
+ x.gsub("&alpha;", "stem:[alpha]")
120
+ .gsub("&beta;", "stem:[beta]")
121
+ .gsub("&gamma;", "stem:[gamma]")
122
+ .gsub("&Gamma;", "stem:[Gamma]")
123
+ .gsub("&delta;", "stem:[delta]")
124
+ .gsub("&Delta;", "stem:[Delta]")
125
+ .gsub("&epsilon;", "stem:[epsilon]")
126
+ .gsub("&varepsilon;", "stem:[varepsilon]")
127
+ .gsub("&zeta;", "stem:[zeta]")
128
+ .gsub("&eta;", "stem:[eta]")
129
+ .gsub("&theta;", "stem:[theta]")
130
+ .gsub("&Theta;", "stem:[Theta]")
131
+ .gsub("&vartheta;", "stem:[vartheta]")
132
+ .gsub("&iota;", "stem:[iota]")
133
+ .gsub("&kappa;", "stem:[kappa]")
134
+ .gsub("&lambda;", "stem:[lambda]")
135
+ .gsub("&Lambda;", "stem:[Lambda]")
136
+ .gsub("&mu;", "stem:[mu]")
137
+ .gsub("&nu;", "stem:[nu]")
138
+ .gsub("&xi;", "stem:[xi]")
139
+ .gsub("&Xi;", "stem:[Xi]")
140
+ .gsub("&pi;", "stem:[pi]")
141
+ .gsub("&Pi;", "stem:[Pi]")
142
+ .gsub("&rho;", "stem:[rho]")
143
+ .gsub("&beta;", "stem:[beta]")
144
+ .gsub("&sigma;", "stem:[sigma]")
145
+ .gsub("&Sigma;", "stem:[Sigma]")
146
+ .gsub("&tau;", "stem:[tau]")
147
+ .gsub("&upsilon;", "stem:[upsilon]")
148
+ .gsub("&phi;", "stem:[phi]")
149
+ .gsub("&Phi;", "stem:[Phi]")
150
+ .gsub("&varphi;", "stem:[varphi]")
151
+ .gsub("&chi;", "stem:[chi]")
152
+ .gsub("&psi;", "stem:[psi]")
153
+ .gsub("&Psi;", "stem:[Psi]")
154
+ .gsub("&omega;", "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 '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'
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 = if input.is_a?(String)
33
- then Nokogiri::XML(input).root
34
- elsif input.is_a?(Nokogiri::XML::Document)
35
- then input.root
36
- elsif input.is_a?(Nokogiri::XML::Node)
37
- then input
38
- end
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 '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'
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 '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'
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 = if input.is_a?(String)
51
- then Nokogiri::XML(input).root
52
- elsif input.is_a?(Nokogiri::XML::Document)
53
- then input.root
54
- elsif input.is_a?(Nokogiri::XML::Node)
55
- then input
56
- end
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 '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'
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 '' unless root
52
+ return "" unless root
54
53
 
55
54
  ReverseAdoc.config.with(options) do
56
- result = ReverseAdoc::Converters.lookup(root.name).convert(root, options)
57
- return '' unless result
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 'json'
2
- require 'stepmod/utils/smrl_description_converter'
3
- require 'stepmod/utils/smrl_resource_converter'
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" : 'descriptions.xml'
21
- descriptions_file = File.join(File.dirname(express_file), descriptions_base)
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('ext_description').each do |description|
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['linkend'].to_s.split('.').first
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['linkend'].to_s.split('.').first]
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(base_reource_doc_dir, stepmod_dir, base_linked, descriptions_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['linkend']]
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(descriptions_file, description)
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['linkend']].nil?
47
- output_express << convert_from_resource_file(resource_docs_dir, stepmod_dir, description['linkend'], descriptions_file)
48
- added_resource_descriptions[description['linkend']] = true
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.to_s}</ext_descriptions>"
61
- "\n" + Stepmod::Utils::SmrlDescriptionConverter.convert(wrapper)
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, 'data/resource_docs', resource_docs_dir, 'resource.xml')
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.to_s}</resource>"
73
- "\n" + Stepmod::Utils::SmrlResourceConverter.convert(wrapper)
79
+ wrapper = "<resource>#{schema}</resource>"
80
+ "\n#{Stepmod::Utils::SmrlResourceConverter.convert(wrapper)}"
74
81
  end
75
82
  end
76
83
  end