stepmod-utils 0.3.35 → 0.3.37

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d49969e2f3e60a1f5c56132b91a492f695aa1339bb9312b5264d72d54a4d4163
4
- data.tar.gz: 8cc9498d0a6bdd52e4b387b32ebf90ec4735d3be3a009a92dfad35cd0a30c21c
3
+ metadata.gz: ce39eaa361d527a10f6fc6f903f4fed05d61f4a9a41cb212b9a1540addc89a0d
4
+ data.tar.gz: 25191fe5b6fab1f15d1c3fcd3193a38adcf05a69918ab460a3c410eccedcefd0
5
5
  SHA512:
6
- metadata.gz: c95c28d9b783137773da3bfc003dfdda5488368f48c3eb49a5494b62a47a60f2aa55ed218f3f0042ab558d386ea2d47445a1a44573078365725b5ac04b1246f6
7
- data.tar.gz: c9a1d29d6d777f4914596724b5fad8fb256a6ce15ffcc857cbe8a233c37c01db5eebea9dbc7104537037a273d3080cbafc8f9db11d545fecdb5bd3293a970026
6
+ metadata.gz: 7196d637c4704b34e743680bcfad24232769c2c1919b9795f40e8ea634a0174f1b0b6a6a6dc9673354b717956bc3b65a346d27563abc462563c7b2f35b26eacd
7
+ data.tar.gz: a0f729d5d7bdebe7d707aa8153de5f9e04fdeb766fdb0e40516136f768a9ce959e76f504721dac1a03cf17efe6ca90ecf6aef3fb78c84742548e2fd5ed8adb64
@@ -5,14 +5,39 @@ module Stepmod
5
5
  module Converters
6
6
  class Em < ReverseAdoc::Converters::Base
7
7
  def convert(node, state = {})
8
- content = treat_children(node, state.merge(already_italic: true))
9
- if state[:equation]
10
- "ii(#{content.strip})"
11
- elsif content.strip.empty? || state[:already_italic]
8
+ italic_converted(node, state)
9
+ end
10
+
11
+ private
12
+
13
+ def italic_converted(node, state)
14
+ cloned_node = node.clone
15
+ equations = extract_equations(cloned_node)
16
+ content = treat_children(cloned_node, state.merge(already_italic: true))
17
+ equation_content = equations.map do |equation|
18
+ treat(equation, state.merge(equation: true, already_italic: true))
19
+ end
20
+
21
+ content = if content.strip.empty? || state[:already_italic] || state[:equation]
12
22
  content
13
23
  else
14
24
  "#{content[/^\s*/]}_#{content.strip}_#{content[/\s*$/]}"
15
25
  end
26
+
27
+ [content, equation_content].compact.join("")
28
+ end
29
+
30
+ def extract_equations(node)
31
+ equations = []
32
+
33
+ node.children.each do |n|
34
+ next if n.name != "eqn"
35
+
36
+ equations << n
37
+ n.unlink
38
+ end
39
+
40
+ equations
16
41
  end
17
42
  end
18
43
 
@@ -50,8 +50,7 @@ module Stepmod
50
50
  end
51
51
 
52
52
  def stem_converted(cloned_node, state)
53
- # We are now adding bb() or ii() for bold and italic respectively
54
- # remove_tags_not_in_context(cloned_node)
53
+ remove_tags_not_in_context(cloned_node)
55
54
  internal_content = treat_children(cloned_node, state.merge(equation: true))
56
55
  content = Stepmod::Utils::HtmlToAsciimath.new.call(internal_content)
57
56
  res = <<~TEMPLATE
@@ -20,9 +20,7 @@ module Stepmod
20
20
  treat(equation, state.merge(equation: true, already_strong: true))
21
21
  end
22
22
 
23
- content = if state[:equation]
24
- "bb(#{content.strip})"
25
- elsif content.strip.empty? || state[:already_strong]
23
+ content = if content.strip.empty? || state[:already_strong] || state[:equation]
26
24
  content
27
25
  else
28
26
  strong_tag = state[:non_flanking_whitesapce] ? '**' : '*'
@@ -1,5 +1,5 @@
1
1
  module Stepmod
2
2
  module Utils
3
- VERSION = "0.3.35".freeze
3
+ VERSION = "0.3.37".freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stepmod-utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.35
4
+ version: 0.3.37
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-11-13 00:00:00.000000000 Z
11
+ date: 2023-11-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby