Skip to content

Commit

Permalink
Reverting adding bb and ii in equations (#192)
Browse files Browse the repository at this point in the history
  • Loading branch information
HassanAkbar authored Nov 24, 2023
1 parent 226176f commit 2a31266
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 19 deletions.
4 changes: 1 addition & 3 deletions lib/stepmod/utils/converters/em_express_description.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ def italic_converted(node, state)
treat(equation, state.merge(equation: true, already_italic: true))
end

content = if state[:equation] && !content.strip.empty?
"ii(#{content.strip})"
elsif content.strip.empty? || state[:already_italic]
content = if content.strip.empty? || state[:already_italic] || state[:equation]
content
else
"#{content[/^\s*/]}_#{content.strip}_#{content[/\s*$/]}"
Expand Down
3 changes: 1 addition & 2 deletions lib/stepmod/utils/converters/eqn.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ def definition_converted(cloned_node, state)
end

def stem_converted(cloned_node, state)
# We are now adding bb() or ii() for bold and italic respectively
# remove_tags_not_in_context(cloned_node)
remove_tags_not_in_context(cloned_node)
internal_content = treat_children(cloned_node, state.merge(equation: true))
content = Stepmod::Utils::HtmlToAsciimath.new.call(internal_content)
res = <<~TEMPLATE
Expand Down
4 changes: 1 addition & 3 deletions lib/stepmod/utils/converters/strong.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ def bold_converted(node, state)
treat(equation, state.merge(equation: true, already_strong: true))
end

content = if state[:equation]
"bb(#{content.strip})"
elsif content.strip.empty? || state[:already_strong]
content = if content.strip.empty? || state[:already_strong] || state[:equation]
content
else
strong_tag = state[:non_flanking_whitesapce] ? '**' : '*'
Expand Down
4 changes: 2 additions & 2 deletions spec/stepmod/converters/em_express_description_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
[stem]
++++
χ bb(My node)_{ms} = bb(V - E + 2F - L)_{l}bb(- 2(S - G)^{s}) = 0
χ My node_{ms} = V - E + 2F - L_{l} - 2(S - G^{s}) = 0
++++
XML
Expand Down Expand Up @@ -69,7 +69,7 @@
[stem]
++++
χ bb(My node)_{ms} = bb(V - E + 2F - L)_{l}bb(- 2(S - G)^{s}) = 0
χ My node_{ms} = V - E + 2F - L_{l} - 2(S - G^{s}) = 0
++++
XML
Expand Down
12 changes: 6 additions & 6 deletions spec/stepmod/converters/eqn_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
[stem]
++++
ii(χ bb(My node)_{ms}ii(Italic text) = bb(ii(V - E + 2F - L))_{l}bb(- 2(S - G)^{s})) = 0
χ My node_{ms}Italic text = V - E + 2F - L_{l} - 2(S - G^{s}) = 0
++++
XML
Expand All @@ -60,13 +60,13 @@
[stem]
++++
bb(λ)ii((u)) = bb(C) + R(cos(ii(u))bb(x) + sin(ii(u))bb(y))
λ(u) = C + R(cos(u)x + sin(u)y)
++++
OUTPUT
end

it "should add bb() and ii() for bold and italics respectively" do
it "should remove all bold and italics tags from equation" do
expect(convert).to eq(expected_output)
end
end
Expand All @@ -83,7 +83,7 @@
[stem]
++++
ii(χ_{ms} = bb(V - E + 2F - L)_{l} bb(- 2(S - G) ^{s})) = 0
χ_{ms} = V - E + 2F - L_{l} - 2(S - G ^{s}) = 0
++++
XML
Expand Down Expand Up @@ -124,7 +124,7 @@
[stem]
++++
ii(K1) = bb("upper_index_on_u_control_points")
K1 = "upper_index_on_u_control_points"
++++
XML
Expand All @@ -146,7 +146,7 @@
[stem]
++++
bb(s)(u,v) = (1 - u -v)^{3}bb(P_{1}) + u^{3}bb(P_{2}) + v^{3}bb(P_{3}) + 3(1 - u -v)^{2}ubb(P_{4}) + 3(1 - u -v)u^{2}bb(P_{5}) + 3u^{2}vbb(P_{6}) + 3uv^{2}bb(P_{7}) + 3(1 - u -v)v^{2}bb(P_{8}) + 3(1 - u -v)^{2}vbb(P_{9}) + 6uv(1 - u -v)bb(P_{10})
s(u,v) = (1 - u -v)^{3}P_{1} + u^{3}P_{2} + v^{3}P_{3} + 3(1 - u -v)^{2}uP_{4} + 3(1 - u -v)u^{2}P_{5} + 3u^{2}vP_{6} + 3uv^{2}P_{7} + 3(1 - u -v)v^{2}P_{8} + 3(1 - u -v)^{2}vP_{9} + 6uv(1 - u -v)P_{10}
++++
XML
Expand Down
4 changes: 2 additions & 2 deletions spec/stepmod/converters/strong_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
[stem]
++++
χ bb(My node)_{ms} = bb(V - E + 2F - L)_{l}bb(- 2(S - G)^{s}) = 0
χ My node_{ms} = V - E + 2F - L_{l} - 2(S - G^{s}) = 0
++++
XML
Expand Down Expand Up @@ -69,7 +69,7 @@
[stem]
++++
χ bb(My node)_{ms} = bb(V - E + 2F - L)_{l}bb(- 2(S - G)^{s}) = 0
χ My node_{ms} = V - E + 2F - L_{l} - 2(S - G^{s}) = 0
++++
XML
Expand Down
2 changes: 1 addition & 1 deletion spec/stepmod/smrl_resource_converter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@
[stem]
++++
ii(χ_{ms} = bb(V - E + 2F - L)_{l}bb(- 2(S - G)^{s})) = 0
χ_{ms} = V - E + 2F - L_{l} - 2(S - G^{s}) = 0
++++
is different from the type of the corresponding assembly constraint in the compared assembly data set.
Expand Down

0 comments on commit 2a31266

Please sign in to comment.