stepmod-utils 0.6.10.pre.alpha.1 → 0.6.11
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/release.yml +6 -0
- data/.rubocop.yml +1 -1
- data/README.adoc +67 -0
- data/exe/stepmod-convert-bibliography +97 -0
- data/lib/stepmod/utils/bibliography_converter.rb +294 -0
- data/lib/stepmod/utils/ceradoc_compat.rb +95 -0
- data/lib/stepmod/utils/change.rb +3 -109
- data/lib/stepmod/utils/change_collection.rb +3 -3
- data/lib/stepmod/utils/change_file.rb +117 -0
- data/lib/stepmod/utils/cleaner.rb +25 -5
- data/lib/stepmod/utils/converters/a.rb +15 -1
- data/lib/stepmod/utils/converters/arm.rb +1 -1
- data/lib/stepmod/utils/converters/base.rb +3 -3
- data/lib/stepmod/utils/converters/clause_ref.rb +1 -1
- data/lib/stepmod/utils/converters/comment.rb +1 -1
- data/lib/stepmod/utils/converters/dd.rb +1 -1
- data/lib/stepmod/utils/converters/def.rb +2 -2
- data/lib/stepmod/utils/converters/definition.rb +1 -1
- data/lib/stepmod/utils/converters/description.rb +1 -1
- data/lib/stepmod/utils/converters/dl.rb +1 -1
- data/lib/stepmod/utils/converters/dt.rb +1 -1
- data/lib/stepmod/utils/converters/em.rb +2 -2
- data/lib/stepmod/utils/converters/em_express_description.rb +30 -1
- data/lib/stepmod/utils/converters/eqn.rb +2 -2
- data/lib/stepmod/utils/converters/example.rb +1 -1
- data/lib/stepmod/utils/converters/express_figure.rb +1 -1
- data/lib/stepmod/utils/converters/express_g.rb +1 -1
- data/lib/stepmod/utils/converters/express_note.rb +1 -1
- data/lib/stepmod/utils/converters/express_ref.rb +1 -1
- data/lib/stepmod/utils/converters/express_ref_express_description.rb +1 -1
- data/lib/stepmod/utils/converters/ext_description.rb +1 -1
- data/lib/stepmod/utils/converters/ext_descriptions.rb +1 -1
- data/lib/stepmod/utils/converters/figure.rb +6 -5
- data/lib/stepmod/utils/converters/fund_cons.rb +1 -1
- data/lib/stepmod/utils/converters/introduction.rb +1 -1
- data/lib/stepmod/utils/converters/li.rb +3 -3
- data/lib/stepmod/utils/converters/module_ref.rb +1 -1
- data/lib/stepmod/utils/converters/module_ref_express_description.rb +1 -1
- data/lib/stepmod/utils/converters/note.rb +1 -1
- data/lib/stepmod/utils/converters/ol.rb +3 -3
- data/lib/stepmod/utils/converters/resource.rb +1 -1
- data/lib/stepmod/utils/converters/schema.rb +1 -1
- data/lib/stepmod/utils/converters/schema_diag.rb +1 -1
- data/lib/stepmod/utils/converters/stepmod_ext_description.rb +1 -1
- data/lib/stepmod/utils/converters/strong.rb +31 -9
- 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 +1 -1
- data/lib/stepmod/utils/converters/table.rb +2 -2
- data/lib/stepmod/utils/converters/term.rb +1 -1
- data/lib/stepmod/utils/converters/text.rb +2 -2
- data/lib/stepmod/utils/converters/tr.rb +3 -3
- data/lib/stepmod/utils/equation_logger.rb +1 -0
- data/lib/stepmod/utils/express_bibdata.rb +3 -1
- data/lib/stepmod/utils/mapping_change.rb +17 -0
- data/lib/stepmod/utils/schema_change.rb +19 -0
- data/lib/stepmod/utils/smrl_description_converter.rb +2 -2
- data/lib/stepmod/utils/smrl_resource_converter.rb +9 -9
- data/lib/stepmod/utils/stepmod_definition_converter.rb +18 -18
- data/lib/stepmod/utils/stepmod_file_annotator.rb +15 -13
- data/lib/stepmod/utils/terms_extractor.rb +3 -3
- data/lib/stepmod/utils/version.rb +1 -1
- data/stepmod-utils.gemspec +14 -3
- metadata +75 -9
data/lib/stepmod/utils/change.rb
CHANGED
|
@@ -1,116 +1,10 @@
|
|
|
1
|
-
require "psych"
|
|
2
|
-
require "stepmod/utils/change_edition"
|
|
3
|
-
require "stepmod/utils/change_edition_collection"
|
|
4
|
-
|
|
5
1
|
module Stepmod
|
|
6
2
|
module Utils
|
|
7
3
|
class Change
|
|
8
|
-
attr_accessor :schema_name, :mapping_table
|
|
9
|
-
attr_reader :change_editions
|
|
10
|
-
|
|
11
|
-
MODULE_TYPES = {
|
|
12
|
-
arm: "arm",
|
|
13
|
-
mim: "mim",
|
|
14
|
-
arm_longform: "arm_lf",
|
|
15
|
-
mim_longform: "mim_lf",
|
|
16
|
-
mapping: "mapping",
|
|
17
|
-
changes: "changes",
|
|
18
|
-
mapping_table: "mapping",
|
|
19
|
-
}.freeze
|
|
20
|
-
|
|
21
|
-
TYPES_WITHOUT_EXTENSION = %w[
|
|
22
|
-
changes
|
|
23
|
-
mapping_table
|
|
24
|
-
].freeze
|
|
25
|
-
|
|
26
|
-
def initialize(stepmod_dir:, schema_name:, type:)
|
|
27
|
-
@stepmod_dir = stepmod_dir
|
|
28
|
-
@change_editions = Stepmod::Utils::ChangeEditionCollection.new
|
|
29
|
-
@mapping_table = {}
|
|
30
|
-
@schema_name = schema_name
|
|
31
|
-
@type = type
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
def resource?
|
|
35
|
-
!module?
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
def module?
|
|
39
|
-
MODULE_TYPES.key?(@type.to_sym) || MODULE_TYPES.value?(@type.to_s)
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
def add_change_edition(change_edition)
|
|
43
|
-
@change_editions[change_edition["version"]] = change_edition
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
def fetch_change_edition(version)
|
|
47
|
-
@change_editions[version]
|
|
48
|
-
end
|
|
49
|
-
alias_method :[], :fetch_change_edition
|
|
50
|
-
|
|
51
|
-
def save_to_file
|
|
52
|
-
change_hash = if @type == "mapping_table"
|
|
53
|
-
@mapping_table
|
|
54
|
-
else
|
|
55
|
-
to_h
|
|
56
|
-
end
|
|
57
|
-
return if change_hash.empty?
|
|
58
|
-
|
|
59
|
-
File.write(filepath(@type), Psych.dump(stringify_keys(change_hash)))
|
|
60
|
-
end
|
|
61
|
-
|
|
62
4
|
def to_h
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
{
|
|
68
|
-
"schema" => schema_name,
|
|
69
|
-
"change_edition" => change_editions_list,
|
|
70
|
-
}
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
private
|
|
74
|
-
|
|
75
|
-
def filepath(type)
|
|
76
|
-
File.join(
|
|
77
|
-
@stepmod_dir,
|
|
78
|
-
"data",
|
|
79
|
-
base_folder,
|
|
80
|
-
schema_name,
|
|
81
|
-
filename(type),
|
|
82
|
-
)
|
|
83
|
-
end
|
|
84
|
-
|
|
85
|
-
def filename(type)
|
|
86
|
-
return "#{MODULE_TYPES[type.to_sym]}.yaml" if TYPES_WITHOUT_EXTENSION.include?(type.to_s)
|
|
87
|
-
|
|
88
|
-
"#{MODULE_TYPES[type.to_sym] || schema_name}.changes.yaml"
|
|
89
|
-
end
|
|
90
|
-
|
|
91
|
-
def base_folder
|
|
92
|
-
if resource?
|
|
93
|
-
"resources"
|
|
94
|
-
else
|
|
95
|
-
"modules"
|
|
96
|
-
end
|
|
97
|
-
end
|
|
98
|
-
|
|
99
|
-
# Hash#transform_keys is not available in Ruby 2.4
|
|
100
|
-
# so we have to do this ourselves :(
|
|
101
|
-
# symbolize hash keys
|
|
102
|
-
def stringify_keys(hash)
|
|
103
|
-
result = {}
|
|
104
|
-
hash.each_pair do |key, value|
|
|
105
|
-
result[key.to_s] = if value.is_a?(Hash)
|
|
106
|
-
stringify_keys(value)
|
|
107
|
-
elsif value.is_a?(Array)
|
|
108
|
-
value.map { |v| stringify_keys(v) }
|
|
109
|
-
else
|
|
110
|
-
value
|
|
111
|
-
end
|
|
112
|
-
end
|
|
113
|
-
result
|
|
5
|
+
self.class::ATTRIBUTES
|
|
6
|
+
.to_h { |name| [name.to_s, public_send(name)] }
|
|
7
|
+
.compact
|
|
114
8
|
end
|
|
115
9
|
end
|
|
116
10
|
end
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
require "stepmod/utils/
|
|
1
|
+
require "stepmod/utils/change_file"
|
|
2
2
|
|
|
3
3
|
module Stepmod
|
|
4
4
|
module Utils
|
|
@@ -11,7 +11,7 @@ module Stepmod
|
|
|
11
11
|
def fetch_or_initialize(change, type)
|
|
12
12
|
schema = schema_name(change)
|
|
13
13
|
|
|
14
|
-
@changes[schema_identifier(schema, type)] ||=
|
|
14
|
+
@changes[schema_identifier(schema, type)] ||= ChangeFile.new(
|
|
15
15
|
type: type,
|
|
16
16
|
stepmod_dir: @stepmod_dir,
|
|
17
17
|
schema_name: schema,
|
|
@@ -39,7 +39,7 @@ module Stepmod
|
|
|
39
39
|
private
|
|
40
40
|
|
|
41
41
|
def schema_name(change)
|
|
42
|
-
change.is_a?(Stepmod::Utils::
|
|
42
|
+
change.is_a?(Stepmod::Utils::ChangeFile) ? change.schema_name : change
|
|
43
43
|
end
|
|
44
44
|
|
|
45
45
|
def schema_identifier(schema_name, type)
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
require "psych"
|
|
2
|
+
require "stepmod/utils/change_edition"
|
|
3
|
+
require "stepmod/utils/change_edition_collection"
|
|
4
|
+
|
|
5
|
+
module Stepmod
|
|
6
|
+
module Utils
|
|
7
|
+
class ChangeFile
|
|
8
|
+
attr_accessor :schema_name, :mapping_table
|
|
9
|
+
attr_reader :change_editions
|
|
10
|
+
|
|
11
|
+
MODULE_TYPES = {
|
|
12
|
+
arm: "arm",
|
|
13
|
+
mim: "mim",
|
|
14
|
+
arm_longform: "arm_lf",
|
|
15
|
+
mim_longform: "mim_lf",
|
|
16
|
+
mapping: "mapping",
|
|
17
|
+
changes: "changes",
|
|
18
|
+
mapping_table: "mapping",
|
|
19
|
+
}.freeze
|
|
20
|
+
|
|
21
|
+
TYPES_WITHOUT_EXTENSION = %w[
|
|
22
|
+
changes
|
|
23
|
+
mapping_table
|
|
24
|
+
].freeze
|
|
25
|
+
|
|
26
|
+
def initialize(stepmod_dir:, schema_name:, type:)
|
|
27
|
+
@stepmod_dir = stepmod_dir
|
|
28
|
+
@change_editions = Stepmod::Utils::ChangeEditionCollection.new
|
|
29
|
+
@mapping_table = {}
|
|
30
|
+
@schema_name = schema_name
|
|
31
|
+
@type = type
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def resource?
|
|
35
|
+
!module?
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def module?
|
|
39
|
+
MODULE_TYPES.key?(@type.to_sym) || MODULE_TYPES.value?(@type.to_s)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def add_change_edition(change_edition)
|
|
43
|
+
@change_editions[change_edition["version"]] = change_edition
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def fetch_change_edition(version)
|
|
47
|
+
@change_editions[version]
|
|
48
|
+
end
|
|
49
|
+
alias_method :[], :fetch_change_edition
|
|
50
|
+
|
|
51
|
+
def save_to_file
|
|
52
|
+
change_hash = if @type == "mapping_table"
|
|
53
|
+
@mapping_table
|
|
54
|
+
else
|
|
55
|
+
to_h
|
|
56
|
+
end
|
|
57
|
+
return if change_hash.empty?
|
|
58
|
+
|
|
59
|
+
File.write(filepath(@type), Psych.dump(stringify_keys(change_hash)))
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def to_h
|
|
63
|
+
change_editions_list = change_editions.to_h
|
|
64
|
+
|
|
65
|
+
return {} if change_editions_list.empty?
|
|
66
|
+
|
|
67
|
+
{
|
|
68
|
+
"schema" => schema_name,
|
|
69
|
+
"change_edition" => change_editions_list,
|
|
70
|
+
}
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
private
|
|
74
|
+
|
|
75
|
+
def filepath(type)
|
|
76
|
+
File.join(
|
|
77
|
+
@stepmod_dir,
|
|
78
|
+
"data",
|
|
79
|
+
base_folder,
|
|
80
|
+
schema_name,
|
|
81
|
+
filename(type),
|
|
82
|
+
)
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
def filename(type)
|
|
86
|
+
return "#{MODULE_TYPES[type.to_sym]}.yaml" if TYPES_WITHOUT_EXTENSION.include?(type.to_s)
|
|
87
|
+
|
|
88
|
+
"#{MODULE_TYPES[type.to_sym] || schema_name}.changes.yaml"
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
def base_folder
|
|
92
|
+
if resource?
|
|
93
|
+
"resources"
|
|
94
|
+
else
|
|
95
|
+
"modules"
|
|
96
|
+
end
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
# Hash#transform_keys is not available in Ruby 2.4
|
|
100
|
+
# so we have to do this ourselves :(
|
|
101
|
+
# symbolize hash keys
|
|
102
|
+
def stringify_keys(hash)
|
|
103
|
+
result = {}
|
|
104
|
+
hash.each_pair do |key, value|
|
|
105
|
+
result[key.to_s] = if value.is_a?(Hash)
|
|
106
|
+
stringify_keys(value)
|
|
107
|
+
elsif value.is_a?(Array)
|
|
108
|
+
value.map { |v| stringify_keys(v) }
|
|
109
|
+
else
|
|
110
|
+
value
|
|
111
|
+
end
|
|
112
|
+
end
|
|
113
|
+
result
|
|
114
|
+
end
|
|
115
|
+
end
|
|
116
|
+
end
|
|
117
|
+
end
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
require "
|
|
1
|
+
require "ceradoc/html/cleaner"
|
|
2
2
|
|
|
3
3
|
module Stepmod
|
|
4
4
|
module Utils
|
|
5
|
-
class Cleaner <
|
|
5
|
+
class Cleaner < Ceradoc::Html::Cleaner
|
|
6
6
|
def tidy(string)
|
|
7
7
|
super
|
|
8
8
|
.gsub(/^ +/, "")
|
|
@@ -12,7 +12,8 @@ module Stepmod
|
|
|
12
12
|
# Find non-asterisk content that is enclosed by two or
|
|
13
13
|
# more asterisks. Ensure that only one whitespace occurs
|
|
14
14
|
# in the border area.
|
|
15
|
-
# Same for underscores and brackets.
|
|
15
|
+
# Same for underscores and brackets. A missing border is added, except
|
|
16
|
+
# next to a word character: unconstrained markup may sit inside a word.
|
|
16
17
|
def clean_tag_borders(string)
|
|
17
18
|
patterns = {
|
|
18
19
|
/\s?\*{2,}.*?\*{2,}\s?/ => "**",
|
|
@@ -23,8 +24,7 @@ module Stepmod
|
|
|
23
24
|
result = string.dup
|
|
24
25
|
patterns.each do |pattern, value|
|
|
25
26
|
result = result.gsub(pattern) do |match|
|
|
26
|
-
|
|
27
|
-
default_border: Coradoc::Input::Html.config.tag_border) do
|
|
27
|
+
border_tags(match, Regexp.last_match) do
|
|
28
28
|
match.strip.sub(" #{value}", value).sub("#{value} ", value)
|
|
29
29
|
end
|
|
30
30
|
end
|
|
@@ -37,6 +37,26 @@ module Stepmod
|
|
|
37
37
|
end
|
|
38
38
|
result
|
|
39
39
|
end
|
|
40
|
+
|
|
41
|
+
private
|
|
42
|
+
|
|
43
|
+
# Like preserve_border_whitespaces, but a border is only invented where
|
|
44
|
+
# the neighbouring character is not part of a word.
|
|
45
|
+
def border_tags(match, matched)
|
|
46
|
+
return match if /\A\s*\Z/.match?(match)
|
|
47
|
+
|
|
48
|
+
invent = !/[\[(\])]/.match?(match)
|
|
49
|
+
start = match[/\A\s*/]
|
|
50
|
+
finish = match[/\s*\Z/]
|
|
51
|
+
start = border(matched.pre_match[-1]) if start.empty? && invent
|
|
52
|
+
finish = border(matched.post_match[0]) if finish.empty? && invent
|
|
53
|
+
|
|
54
|
+
start + yield + finish
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def border(neighbour)
|
|
58
|
+
neighbour&.match?(/\w/) ? "" : Ceradoc::Html.input_config.tag_border
|
|
59
|
+
end
|
|
40
60
|
end
|
|
41
61
|
end
|
|
42
62
|
end
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require_relative "figure"
|
|
4
|
+
|
|
3
5
|
module Stepmod
|
|
4
6
|
module Utils
|
|
5
7
|
module Converters
|
|
@@ -18,6 +20,7 @@ module Stepmod
|
|
|
18
20
|
"[[#{id}]]"
|
|
19
21
|
elsif href.to_s.start_with?("#")
|
|
20
22
|
href = href.sub(/^#/, "").gsub(/\s/, "").gsub(/__+/, "_")
|
|
23
|
+
href = figure_anchor(href, state) || href
|
|
21
24
|
if name.empty? || number_with_optional_prefix?(name)
|
|
22
25
|
"<<#{href}>>"
|
|
23
26
|
else
|
|
@@ -36,12 +39,23 @@ module Stepmod
|
|
|
36
39
|
|
|
37
40
|
private
|
|
38
41
|
|
|
42
|
+
# A reference to a figure must use the id the figure is given by
|
|
43
|
+
# Figure.pattern, or the link does not resolve.
|
|
44
|
+
def figure_anchor(href, state)
|
|
45
|
+
return unless state[:schema_and_entity] || state[:schema_name]
|
|
46
|
+
|
|
47
|
+
figure_id = href[/\Afigure[_-](.+)\z/, 1]
|
|
48
|
+
figure_id = href if figure_id.nil? &&
|
|
49
|
+
Array(state[:figure_ids]).include?(href)
|
|
50
|
+
Figure.pattern(state, figure_id) if figure_id
|
|
51
|
+
end
|
|
52
|
+
|
|
39
53
|
def number_with_optional_prefix?(name)
|
|
40
54
|
/.*?\s*\(?\d+\)?/.match(name)
|
|
41
55
|
end
|
|
42
56
|
end
|
|
43
57
|
|
|
44
|
-
|
|
58
|
+
Ceradoc::Html::Converters.register :a, A.new
|
|
45
59
|
end
|
|
46
60
|
end
|
|
47
61
|
end
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
require "
|
|
2
|
-
require "
|
|
1
|
+
require "ceradoc"
|
|
2
|
+
require "stepmod/utils/ceradoc_compat"
|
|
3
3
|
|
|
4
4
|
module Stepmod
|
|
5
5
|
module Utils
|
|
6
6
|
module Converters
|
|
7
|
-
class Base <
|
|
7
|
+
class Base < Ceradoc::Html::Converters::Base
|
|
8
8
|
end
|
|
9
9
|
end
|
|
10
10
|
end
|
|
@@ -78,8 +78,8 @@ module Stepmod
|
|
|
78
78
|
end
|
|
79
79
|
end
|
|
80
80
|
|
|
81
|
-
|
|
82
|
-
|
|
81
|
+
Ceradoc::Html::Converters.register :def, Def.new
|
|
82
|
+
Ceradoc::Html::Converters.register :description, Def.new
|
|
83
83
|
end
|
|
84
84
|
end
|
|
85
85
|
end
|
|
@@ -14,8 +14,8 @@ module Stepmod
|
|
|
14
14
|
end
|
|
15
15
|
end
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
Ceradoc::Html::Converters.register :em, Em.new
|
|
18
|
+
Ceradoc::Html::Converters.register :cite, Em.new
|
|
19
19
|
end
|
|
20
20
|
end
|
|
21
21
|
end
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require_relative "strong"
|
|
4
|
+
|
|
3
5
|
module Stepmod
|
|
4
6
|
module Utils
|
|
5
7
|
module Converters
|
|
6
8
|
class Em < Stepmod::Utils::Converters::Base
|
|
9
|
+
BOLD_TAGS = %w[b strong].freeze
|
|
10
|
+
|
|
7
11
|
def convert(node, state = {})
|
|
8
12
|
italic_converted(node, state)
|
|
9
13
|
end
|
|
@@ -15,6 +19,11 @@ module Stepmod
|
|
|
15
19
|
private
|
|
16
20
|
|
|
17
21
|
def italic_converted(node, state)
|
|
22
|
+
bold = sole_bold_child(node)
|
|
23
|
+
if bold && !state[:already_italic]
|
|
24
|
+
return bold_italic(node, bold, state)
|
|
25
|
+
end
|
|
26
|
+
|
|
18
27
|
cloned_node = node.clone
|
|
19
28
|
equations = extract_equations(cloned_node)
|
|
20
29
|
content = treat_children(cloned_node,
|
|
@@ -34,6 +43,26 @@ module Stepmod
|
|
|
34
43
|
[content, equation_content].compact.join("")
|
|
35
44
|
end
|
|
36
45
|
|
|
46
|
+
# <i><b>x</b></i> is written bold outside, italic inside: `*_x_*`.
|
|
47
|
+
def bold_italic(node, bold, state)
|
|
48
|
+
content = treat_children(bold, state.merge(already_italic: true))
|
|
49
|
+
return content if content.strip.empty?
|
|
50
|
+
|
|
51
|
+
lead = content[/^\s*/]
|
|
52
|
+
trail = content[/\s*$/]
|
|
53
|
+
Strong.new.mark_up(node, "#{lead}_#{content.strip}_#{trail}", state)
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def sole_bold_child(node)
|
|
57
|
+
return unless node.element_children.one?
|
|
58
|
+
return if node.children.any? { |c| c.text? && !c.text.strip.empty? }
|
|
59
|
+
|
|
60
|
+
bold = node.element_children.first
|
|
61
|
+
return unless BOLD_TAGS.include?(bold.name)
|
|
62
|
+
|
|
63
|
+
bold unless bold.element_children.any? { |c| c.name == "eqn" }
|
|
64
|
+
end
|
|
65
|
+
|
|
37
66
|
def extract_equations(node)
|
|
38
67
|
equations = []
|
|
39
68
|
|
|
@@ -48,7 +77,7 @@ module Stepmod
|
|
|
48
77
|
end
|
|
49
78
|
end
|
|
50
79
|
|
|
51
|
-
|
|
80
|
+
Ceradoc::Html::Converters.register :i, Em.new
|
|
52
81
|
end
|
|
53
82
|
end
|
|
54
83
|
end
|
|
@@ -123,8 +123,8 @@ module Stepmod
|
|
|
123
123
|
end
|
|
124
124
|
end
|
|
125
125
|
|
|
126
|
-
|
|
127
|
-
|
|
126
|
+
Ceradoc::Html::Converters.register :eqn, Eqn.new
|
|
127
|
+
Ceradoc::Html::Converters.register :bigeqn, Eqn.new
|
|
128
128
|
end
|
|
129
129
|
end
|
|
130
130
|
end
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require "
|
|
3
|
+
require "ceradoc/html/converters/figure"
|
|
4
4
|
|
|
5
5
|
module Stepmod
|
|
6
6
|
module Utils
|
|
7
7
|
module Converters
|
|
8
|
-
class Figure <
|
|
8
|
+
class Figure < Ceradoc::Html::Converters::Figure
|
|
9
9
|
def self.pattern(state, id)
|
|
10
|
-
|
|
10
|
+
schema_and_entity = state[:schema_and_entity] || state[:schema_name]
|
|
11
|
+
if schema_and_entity.nil?
|
|
11
12
|
raise StandardError.new("[figure]: no state given, #{id}")
|
|
12
13
|
end
|
|
13
14
|
|
|
14
|
-
schema =
|
|
15
|
+
schema = schema_and_entity.split(".").first
|
|
15
16
|
"figure-#{schema}-#{id}"
|
|
16
17
|
end
|
|
17
18
|
|
|
@@ -43,7 +44,7 @@ module Stepmod
|
|
|
43
44
|
end
|
|
44
45
|
|
|
45
46
|
# This replaces the converter
|
|
46
|
-
|
|
47
|
+
Ceradoc::Html::Converters.register :figure, Figure.new
|
|
47
48
|
end
|
|
48
49
|
end
|
|
49
50
|
end
|