stepmod-utils 0.1.6 → 0.2.4
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 +4 -4
- data/.github/workflows/rake.yml +51 -0
- data/.github/workflows/release.yml +20 -22
- data/Gemfile +2 -0
- data/Makefile +2 -0
- data/README.adoc +136 -2
- data/exe/stepmod-annotate +44 -0
- data/exe/stepmod-annotate-all +39 -0
- data/exe/stepmod-build-resource-docs-cache +19 -0
- data/exe/stepmod-convert-express-description +33 -0
- data/exe/stepmod-convert-express-resource +33 -0
- data/exe/stepmod-extract-terms +61 -12
- data/exe/stepmod-find-express-files +23 -0
- data/lib/stepmod/utils/cleaner.rb +11 -0
- data/lib/stepmod/utils/concept.rb +16 -3
- data/lib/stepmod/utils/converters/a.rb +47 -0
- data/lib/stepmod/utils/converters/blockquote.rb +22 -0
- data/lib/stepmod/utils/converters/br.rb +15 -0
- data/lib/stepmod/utils/converters/bypass.rb +81 -0
- data/lib/stepmod/utils/converters/code.rb +19 -0
- data/lib/stepmod/utils/converters/comment.rb +16 -0
- data/lib/stepmod/utils/converters/dd.rb +15 -0
- data/lib/stepmod/utils/converters/def.rb +11 -4
- data/lib/stepmod/utils/converters/dl.rb +31 -0
- data/lib/stepmod/utils/converters/drop.rb +22 -0
- data/lib/stepmod/utils/converters/dt.rb +17 -0
- data/lib/stepmod/utils/converters/em_express_description.rb +22 -0
- data/lib/stepmod/utils/converters/eqn.rb +96 -0
- data/lib/stepmod/utils/converters/example.rb +1 -6
- data/lib/stepmod/utils/converters/express_g.rb +46 -0
- data/lib/stepmod/utils/converters/express_ref_express_description.rb +13 -0
- data/lib/stepmod/utils/converters/ext_description.rb +16 -0
- data/lib/stepmod/utils/converters/ext_descriptions.rb +14 -0
- data/lib/stepmod/utils/converters/fund_cons.rb +15 -0
- data/lib/stepmod/utils/converters/head.rb +22 -0
- data/lib/stepmod/utils/converters/hr.rb +15 -0
- data/lib/stepmod/utils/converters/ignore.rb +16 -0
- data/lib/stepmod/utils/converters/introduction.rb +15 -0
- data/lib/stepmod/utils/converters/note.rb +1 -6
- data/lib/stepmod/utils/converters/ol.rb +3 -2
- data/lib/stepmod/utils/converters/p.rb +21 -0
- data/lib/stepmod/utils/converters/pass_through.rb +13 -0
- data/lib/stepmod/utils/converters/q.rb +16 -0
- data/lib/stepmod/utils/converters/resource.rb +14 -0
- data/lib/stepmod/utils/converters/schema.rb +18 -0
- data/lib/stepmod/utils/converters/schema_diag.rb +14 -0
- data/lib/stepmod/utils/converters/strong.rb +21 -0
- data/lib/stepmod/utils/converters/sub.rb +16 -0
- data/lib/stepmod/utils/converters/sup.rb +16 -0
- data/lib/stepmod/utils/converters/text.rb +68 -0
- data/lib/stepmod/utils/html_to_asciimath.rb +157 -0
- data/lib/stepmod/utils/smrl_description_converter.rb +49 -0
- data/lib/stepmod/utils/smrl_resource_converter.rb +67 -0
- data/lib/stepmod/utils/stepmod_file_annotator.rb +54 -0
- data/lib/stepmod/utils/version.rb +1 -1
- data/migrating_from_cvs.adoc +190 -0
- data/stepmod-utils.gemspec +2 -0
- metadata +82 -6
- data/.github/workflows/macos.yml +0 -39
- data/.github/workflows/ubuntu.yml +0 -53
- data/.github/workflows/windows.yml +0 -41
|
@@ -9,8 +9,9 @@ module Stepmod
|
|
|
9
9
|
anchor = id ? "[[#{id}]]\n" : ""
|
|
10
10
|
ol_count = state.fetch(:ol_count, 0) + 1
|
|
11
11
|
attrs = ol_attrs(node)
|
|
12
|
-
res = "\n#{anchor}#{attrs}#{treat_children(node, state.merge(ol_count: ol_count))}"
|
|
13
|
-
|
|
12
|
+
res = "\n\n#{anchor}#{attrs}#{treat_children(node, state.merge(ol_count: ol_count))}\n"
|
|
13
|
+
# Why do we add this?
|
|
14
|
+
# res = "\n" + res if node.parent && node.parent.name == 'note'
|
|
14
15
|
res
|
|
15
16
|
end
|
|
16
17
|
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Stepmod
|
|
4
|
+
module Utils
|
|
5
|
+
module Converters
|
|
6
|
+
class P < ReverseAdoc::Converters::Base
|
|
7
|
+
def convert(node, state = {})
|
|
8
|
+
id = node['id']
|
|
9
|
+
anchor = id ? "[[#{id}]]\n" : ""
|
|
10
|
+
if state[:tdsinglepara]
|
|
11
|
+
"#{anchor}#{treat_children(node, state).strip}"
|
|
12
|
+
else
|
|
13
|
+
"\n\n#{anchor}#{treat_children(node, state).strip}\n\n"
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
ReverseAdoc::Converters.register :p, P.new
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Stepmod
|
|
4
|
+
module Utils
|
|
5
|
+
module Converters
|
|
6
|
+
class Q < ReverseAdoc::Converters::Base
|
|
7
|
+
def convert(node, state = {})
|
|
8
|
+
content = treat_children(node, state)
|
|
9
|
+
"#{content[/^\s*/]}\"#{content.strip}\"#{content[/\s*$/]}"
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
ReverseAdoc::Converters.register :q, Q.new
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Stepmod
|
|
4
|
+
module Utils
|
|
5
|
+
module Converters
|
|
6
|
+
class Resource < ReverseAdoc::Converters::Base
|
|
7
|
+
def convert(node, state = {})
|
|
8
|
+
treat_children(node, state)
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
ReverseAdoc::Converters.register :resource, Resource.new
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Stepmod
|
|
4
|
+
module Utils
|
|
5
|
+
module Converters
|
|
6
|
+
class Schema < ReverseAdoc::Converters::Base
|
|
7
|
+
def convert(node, state = {})
|
|
8
|
+
<<~TEMPLATE
|
|
9
|
+
(*"#{node['name']}"
|
|
10
|
+
#{treat_children(node, state).strip}
|
|
11
|
+
*)
|
|
12
|
+
TEMPLATE
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
ReverseAdoc::Converters.register :schema, Schema.new
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Stepmod
|
|
4
|
+
module Utils
|
|
5
|
+
module Converters
|
|
6
|
+
class SchemaDiag < ReverseAdoc::Converters::Base
|
|
7
|
+
def convert(node, state = {})
|
|
8
|
+
treat_children(node, state).strip
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
ReverseAdoc::Converters.register :schema_diag, SchemaDiag.new
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Stepmod
|
|
4
|
+
module Utils
|
|
5
|
+
module Converters
|
|
6
|
+
class Strong < ReverseAdoc::Converters::Base
|
|
7
|
+
def convert(node, state = {})
|
|
8
|
+
content = treat_children(node, state.merge(already_strong: true))
|
|
9
|
+
if content.strip.empty? || state[:already_strong]
|
|
10
|
+
content
|
|
11
|
+
else
|
|
12
|
+
"#{content[/^\s*/]}*#{content.strip}*#{content[/\s*$/]}"
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
ReverseAdoc::Converters.register :strong, Strong.new
|
|
18
|
+
ReverseAdoc::Converters.register :b, Strong.new
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Stepmod
|
|
4
|
+
module Utils
|
|
5
|
+
module Converters
|
|
6
|
+
class Sub < ReverseAdoc::Converters::Base
|
|
7
|
+
def convert(node, state = {})
|
|
8
|
+
content = treat_children(node, state)
|
|
9
|
+
"#{content[/^\s*/]}~#{content.strip}~#{content[/\s*$/]}"
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
ReverseAdoc::Converters.register :sub, Sub.new
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Stepmod
|
|
4
|
+
module Utils
|
|
5
|
+
module Converters
|
|
6
|
+
class Sup < ReverseAdoc::Converters::Base
|
|
7
|
+
def convert(node, state = {})
|
|
8
|
+
content = treat_children(node, state)
|
|
9
|
+
"#{content[/^\s*/]}^#{content.strip}^#{content[/\s*$/]}"
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
ReverseAdoc::Converters.register :sup, Sup.new
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Stepmod
|
|
4
|
+
module Utils
|
|
5
|
+
module Converters
|
|
6
|
+
class Text < ReverseAdoc::Converters::Base
|
|
7
|
+
def convert(node, state = {})
|
|
8
|
+
if node.text.strip.empty?
|
|
9
|
+
treat_empty(node, state)
|
|
10
|
+
else
|
|
11
|
+
treat_text(node)
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
private
|
|
16
|
+
|
|
17
|
+
def treat_empty(node, state)
|
|
18
|
+
parent = node.parent.name.to_sym
|
|
19
|
+
if [:ol, :ul].include?(parent) # Otherwise the identation is broken
|
|
20
|
+
''
|
|
21
|
+
elsif state[:tdsinglepara]
|
|
22
|
+
''
|
|
23
|
+
elsif node.text == ' ' # Regular whitespace text node
|
|
24
|
+
' '
|
|
25
|
+
else
|
|
26
|
+
''
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def treat_text(node)
|
|
31
|
+
text = node.text
|
|
32
|
+
text = preserve_nbsp(text)
|
|
33
|
+
# text = remove_border_newlines(text)
|
|
34
|
+
text = remove_inner_newlines(text)
|
|
35
|
+
|
|
36
|
+
text = preserve_keychars_within_backticks(text)
|
|
37
|
+
text = preserve_tags(text)
|
|
38
|
+
|
|
39
|
+
text
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def preserve_nbsp(text)
|
|
43
|
+
text.gsub(/\u00A0/, " ")
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def preserve_tags(text)
|
|
47
|
+
text.gsub(/[<>]/, '>' => '\>', '<' => '\<')
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def remove_border_newlines(text)
|
|
51
|
+
text.gsub(/\A\n+/, '').gsub(/\n+\z/, '')
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def remove_inner_newlines(text)
|
|
55
|
+
text.tr("\n\t", ' ').squeeze(' ')
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def preserve_keychars_within_backticks(text)
|
|
59
|
+
text.gsub(/`.*?`/) do |match|
|
|
60
|
+
match.gsub('\_', '_').gsub('\*', '*')
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
ReverseAdoc::Converters.register :text, Text.new
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
module Stepmod
|
|
2
|
+
module Utils
|
|
3
|
+
class HtmlToAsciimath
|
|
4
|
+
def call(input)
|
|
5
|
+
return input if input.nil? || input.empty?
|
|
6
|
+
|
|
7
|
+
to_asciimath = Nokogiri::HTML.fragment(input, "UTF-8")
|
|
8
|
+
|
|
9
|
+
to_asciimath.css('i').each do |math_element|
|
|
10
|
+
# puts "HTML MATH!! #{math_element.to_xml}"
|
|
11
|
+
# puts "HTML MATH!! #{math_element.text}"
|
|
12
|
+
decoded = text_to_asciimath(math_element.text)
|
|
13
|
+
case decoded.length
|
|
14
|
+
when 1..12
|
|
15
|
+
# puts "(#{math_element.text} to => #{decoded})"
|
|
16
|
+
math_element.replace "stem:[#{decoded}]"
|
|
17
|
+
when 0
|
|
18
|
+
math_element.remove
|
|
19
|
+
else
|
|
20
|
+
math_element.replace "_#{decoded}_"
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
to_asciimath.css('sub').each do |math_element|
|
|
25
|
+
case math_element.text.length
|
|
26
|
+
when 0
|
|
27
|
+
math_element.remove
|
|
28
|
+
else
|
|
29
|
+
math_element.replace "~#{text_to_asciimath(math_element.text)}~"
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
to_asciimath.css('sup').each do |math_element|
|
|
34
|
+
case math_element.text.length
|
|
35
|
+
when 0
|
|
36
|
+
math_element.remove
|
|
37
|
+
else
|
|
38
|
+
math_element.replace "^#{text_to_asciimath(math_element.text)}^"
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
to_asciimath.css('ol').each do |element|
|
|
43
|
+
element.css('li').each do |li|
|
|
44
|
+
li.replace ". #{li.text}"
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
to_asciimath.css('ul').each do |element|
|
|
49
|
+
element.css('li').each do |li|
|
|
50
|
+
li.replace "* #{li.text}"
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
# Replace sans-serif font with monospace
|
|
55
|
+
to_asciimath.css('font[style*="sans-serif"]').each do |x|
|
|
56
|
+
x.replace "`#{x.text}`"
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
html_entities_to_stem(
|
|
60
|
+
to_asciimath.children.to_s.gsub(/\]stem:\[/, '').gsub(/<\/?[uo]l>/, '')
|
|
61
|
+
)
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def text_to_asciimath(text)
|
|
65
|
+
html_entities_to_asciimath(text.decode_html)
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
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("≥", "≥")
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
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]")
|
|
154
|
+
end
|
|
155
|
+
end
|
|
156
|
+
end
|
|
157
|
+
end
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
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'
|
|
27
|
+
|
|
28
|
+
module Stepmod
|
|
29
|
+
module Utils
|
|
30
|
+
class SmrlDescriptionConverter
|
|
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
|
|
39
|
+
|
|
40
|
+
root || (return '')
|
|
41
|
+
|
|
42
|
+
ReverseAdoc.config.with(options) do
|
|
43
|
+
result = ReverseAdoc::Converters.lookup(root.name).convert(root)
|
|
44
|
+
Stepmod::Utils::Cleaner.new.tidy(result)
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|