stepmod-utils 0.2.0 → 0.2.7
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 +42 -0
- data/.github/workflows/release.yml +23 -20
- data/Gemfile +2 -1
- data/Makefile +5 -0
- data/README.adoc +82 -1
- 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 +3 -3
- data/exe/stepmod-find-express-files +23 -0
- data/lib/stepmod/utils/cleaner.rb +11 -0
- 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 +97 -0
- data/lib/stepmod/utils/converters/example.rb +1 -6
- data/lib/stepmod/utils/converters/express_g.rb +49 -0
- data/lib/stepmod/utils/converters/express_ref_express_description.rb +13 -0
- data/lib/stepmod/utils/converters/ext_description.rb +17 -0
- data/lib/stepmod/utils/converters/ext_descriptions.rb +14 -0
- data/lib/stepmod/utils/converters/fund_cons.rb +21 -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 +19 -0
- data/lib/stepmod/utils/converters/schema_diag.rb +14 -0
- data/lib/stepmod/utils/converters/strong.rb +41 -0
- data/lib/stepmod/utils/converters/sub.rb +24 -0
- data/lib/stepmod/utils/converters/sup.rb +22 -0
- data/lib/stepmod/utils/converters/table.rb +62 -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 +78 -0
- data/lib/stepmod/utils/version.rb +1 -1
- data/migrating_from_cvs.adoc +190 -0
- data/stepmod-utils.gemspec +1 -0
- metadata +69 -8
- data/.github/workflows/macos.yml +0 -39
- data/.github/workflows/ubuntu.yml +0 -53
- data/.github/workflows/windows.yml +0 -41
@@ -0,0 +1,13 @@
|
|
1
|
+
module Stepmod
|
2
|
+
module Utils
|
3
|
+
module Converters
|
4
|
+
class ExpressRefExpressDescription < ReverseAdoc::Converters::Base
|
5
|
+
def convert(node, _state = {})
|
6
|
+
parts = node['linkend'].to_s.split(':').last.split('.')
|
7
|
+
"<<express:#{parts.join('.').strip},#{parts.last.strip}>>"
|
8
|
+
end
|
9
|
+
end
|
10
|
+
ReverseAdoc::Converters.register :express_ref, ExpressRefExpressDescription.new
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Stepmod
|
2
|
+
module Utils
|
3
|
+
module Converters
|
4
|
+
class ExtDescription < ReverseAdoc::Converters::Base
|
5
|
+
def convert(node, state = {})
|
6
|
+
state = state.merge(schema_name: node['linkend'])
|
7
|
+
<<~TEMPLATE
|
8
|
+
(*"#{node['linkend']}"
|
9
|
+
#{treat_children(node, state).strip}
|
10
|
+
*)
|
11
|
+
TEMPLATE
|
12
|
+
end
|
13
|
+
end
|
14
|
+
ReverseAdoc::Converters.register :ext_description, ExtDescription.new
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Stepmod
|
4
|
+
module Utils
|
5
|
+
module Converters
|
6
|
+
class ExtDescriptions < ReverseAdoc::Converters::Base
|
7
|
+
def convert(node, state = {})
|
8
|
+
treat_children(node, state)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
ReverseAdoc::Converters.register :ext_descriptions, ExtDescriptions.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 FundCons < ReverseAdoc::Converters::Base
|
7
|
+
def convert(node, state = {})
|
8
|
+
<<~TEXT
|
9
|
+
|
10
|
+
*)
|
11
|
+
(*"#{state.fetch(:schema_name)}.__fund_cons"
|
12
|
+
|
13
|
+
#{treat_children(node, state).strip}
|
14
|
+
TEXT
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
ReverseAdoc::Converters.register :fund_cons, FundCons.new
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Stepmod
|
4
|
+
module Utils
|
5
|
+
module Converters
|
6
|
+
class Head < ReverseAdoc::Converters::Base
|
7
|
+
def convert(node, state = {})
|
8
|
+
title = extract_title(node)
|
9
|
+
"= #{title}\n:stem:\n\n"
|
10
|
+
end
|
11
|
+
|
12
|
+
def extract_title(node)
|
13
|
+
title = node.at("./title")
|
14
|
+
return "(???)" if title.nil?
|
15
|
+
title.text
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
ReverseAdoc::Converters.register :head, Head.new
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Stepmod
|
4
|
+
module Utils
|
5
|
+
module Converters
|
6
|
+
class Hr < ReverseAdoc::Converters::Base
|
7
|
+
def convert(node, state = {})
|
8
|
+
"\n* * *\n"
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
ReverseAdoc::Converters.register :hr, Hr.new
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Stepmod
|
4
|
+
module Utils
|
5
|
+
module Converters
|
6
|
+
class Ignore < ReverseAdoc::Converters::Base
|
7
|
+
def convert(node, state = {})
|
8
|
+
'' # noop
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
ReverseAdoc::Converters.register :colgroup, Ignore.new
|
13
|
+
ReverseAdoc::Converters.register :col, Ignore.new
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Stepmod
|
4
|
+
module Utils
|
5
|
+
module Converters
|
6
|
+
class Introduction < ReverseAdoc::Converters::Base
|
7
|
+
def convert(node, state = {})
|
8
|
+
treat_children(node, state)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
ReverseAdoc::Converters.register :introduction, Introduction.new
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -5,12 +5,7 @@ module Stepmod
|
|
5
5
|
module Converters
|
6
6
|
class Note < ReverseAdoc::Converters::Base
|
7
7
|
def convert(node, state = {})
|
8
|
-
|
9
|
-
[NOTE]
|
10
|
-
--
|
11
|
-
#{treat_children(node, state).strip}
|
12
|
-
--
|
13
|
-
TEMPLATE
|
8
|
+
"\n\n[NOTE]\n--\n#{treat_children(node, state).strip}\n--\n\n"
|
14
9
|
end
|
15
10
|
end
|
16
11
|
ReverseAdoc::Converters.register :note, Note.new
|
@@ -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, tdsinglepara: true))}\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,19 @@
|
|
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
|
+
state = state.merge(schema_name: node['name'])
|
9
|
+
<<~TEMPLATE
|
10
|
+
(*"#{node['name']}"
|
11
|
+
#{treat_children(node, state).strip}
|
12
|
+
*)
|
13
|
+
TEMPLATE
|
14
|
+
end
|
15
|
+
end
|
16
|
+
ReverseAdoc::Converters.register :schema, Schema.new
|
17
|
+
end
|
18
|
+
end
|
19
|
+
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,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Stepmod
|
4
|
+
module Utils
|
5
|
+
module Converters
|
6
|
+
class Strong < ReverseAdoc::Converters::Base
|
7
|
+
BLANK_CHARS = "{blank}".freeze
|
8
|
+
|
9
|
+
def convert(node, state = {})
|
10
|
+
content = treat_children(node, state.merge(already_strong: true))
|
11
|
+
if content.strip.empty? || state[:already_strong]
|
12
|
+
content
|
13
|
+
else
|
14
|
+
handle_express_escape_seq(node, "#{content[/^\s*/]}*#{content.strip}*#{content[/\s*$/]}")
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def handle_express_escape_seq(node, content)
|
21
|
+
res = content
|
22
|
+
if braces_sibling?(node.previous, true)
|
23
|
+
res = "#{BLANK_CHARS}#{res}"
|
24
|
+
end
|
25
|
+
if braces_sibling?(node.next)
|
26
|
+
res = "#{res}#{BLANK_CHARS}"
|
27
|
+
end
|
28
|
+
res
|
29
|
+
end
|
30
|
+
|
31
|
+
def braces_sibling?(sibling, end_of_text = false)
|
32
|
+
match = end_of_text ? /\($/ : /^\)/
|
33
|
+
sibling && sibling.text? && sibling.text =~ match
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
ReverseAdoc::Converters.register :strong, Strong.new
|
38
|
+
ReverseAdoc::Converters.register :b, Strong.new
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,24 @@
|
|
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
|
+
return stem_notation(content) if node.parent.name == 'eqn'
|
10
|
+
|
11
|
+
"#{content[/^\s*/]}~#{content.strip}~#{content[/\s*$/]}"
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def stem_notation(content)
|
17
|
+
"_{#{content}}"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
ReverseAdoc::Converters.register :sub, Sub.new
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,22 @@
|
|
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
|
+
return stem_notation(content) if node.parent.name == 'eqn'
|
10
|
+
|
11
|
+
"#{content[/^\s*/]}^#{content.strip}^#{content[/\s*$/]}"
|
12
|
+
end
|
13
|
+
|
14
|
+
def stem_notation(content)
|
15
|
+
"^{#{content}}"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
ReverseAdoc::Converters.register :sup, Sup.new
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Stepmod
|
4
|
+
module Utils
|
5
|
+
module Converters
|
6
|
+
class Table < ReverseAdoc::Converters::Base
|
7
|
+
def convert(node, state = {})
|
8
|
+
id = node['id']
|
9
|
+
anchor = id ? "[[#{id}]]\n" : ""
|
10
|
+
title = node['caption'].to_s
|
11
|
+
title = ".#{title}\n" unless title.empty?
|
12
|
+
attrs = style(node)
|
13
|
+
"\n\n#{anchor}#{attrs}#{title}|===\n#{treat_children(node, state)}\n|===\n"
|
14
|
+
end
|
15
|
+
|
16
|
+
def frame(node)
|
17
|
+
case node["frame"]
|
18
|
+
when "void"
|
19
|
+
"frame=none"
|
20
|
+
when "hsides"
|
21
|
+
"frame=topbot"
|
22
|
+
when "vsides"
|
23
|
+
"frame=sides"
|
24
|
+
when "box", "border"
|
25
|
+
"frame=all"
|
26
|
+
else
|
27
|
+
nil
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def rules(node)
|
32
|
+
case node["rules"]
|
33
|
+
when "all"
|
34
|
+
"rules=all"
|
35
|
+
when "rows"
|
36
|
+
"rules=rows"
|
37
|
+
when "cols"
|
38
|
+
"rules=cols"
|
39
|
+
when "none"
|
40
|
+
"rules=none"
|
41
|
+
else
|
42
|
+
nil
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def style(node)
|
47
|
+
width = "width=#{node['width']}" if node['width']
|
48
|
+
attrs = []
|
49
|
+
frame_attr = frame(node)
|
50
|
+
rules_attr = rules(node)
|
51
|
+
attrs += width if width
|
52
|
+
attrs += frame_attr if frame_attr
|
53
|
+
attrs += rules_attr if rules_attr
|
54
|
+
return "" if attrs.empty?
|
55
|
+
"[#{attrs.join(',')}]\n"
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
ReverseAdoc::Converters.register :table, Table.new
|
60
|
+
end
|
61
|
+
end
|
62
|
+
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
|