unitsml 0.4.2 → 0.4.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/lib/unitsml/extender.rb +26 -16
- data/lib/unitsml/formula.rb +10 -9
- data/lib/unitsml/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 11547b56b21b1dc3c1b34bfa84e230c7e917258c80e094b4f39da986b6497720
|
4
|
+
data.tar.gz: aa06a261218c5445af439f0c88fbfd55ca97dc87c9c135fc489e58eb2dcead57
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 45f920c409f2a1c6c3cab70dcf16ae2b432f4732c5491bab7de6ce6bc01f44d9f40df7325cce1d357ad74a11f3d043156276293f4e74c4e953fc5ff495185f23
|
7
|
+
data.tar.gz: 39994002be2a3f211eb6a4eb9826c63dcf6f06695ac65f42269479981436abad0969c054f3a68929847acbb35b4e3d56ebc1cb371916fadab8f0b824f1b96656
|
data/lib/unitsml/extender.rb
CHANGED
@@ -14,37 +14,47 @@ module Unitsml
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def to_mathml(options)
|
17
|
-
|
18
|
-
|
19
|
-
rspace = "thickmathspace"
|
20
|
-
"⁢"
|
21
|
-
when :nospace
|
22
|
-
"⁢"
|
23
|
-
else
|
24
|
-
extender = options[:multiplier] || "⋅"
|
25
|
-
Utility.string_to_html_entity(extender)
|
26
|
-
end
|
17
|
+
rspace = "thickmathspace" if options[:multiplier] == :space
|
18
|
+
extender = multiplier(options[:multiplier] || "⋅", unicode: true)
|
27
19
|
{
|
28
20
|
method_name: :mo,
|
29
|
-
value: ::Mml::Mo.new(value:
|
21
|
+
value: ::Mml::Mo.new(value: extender, rspace: rspace),
|
30
22
|
}
|
31
23
|
end
|
32
24
|
|
33
25
|
def to_latex(options)
|
34
|
-
options[:multiplier] || "/"
|
26
|
+
multiplier(options[:multiplier] || "/")
|
35
27
|
end
|
36
28
|
|
37
29
|
def to_asciimath(options)
|
38
|
-
options[:multiplier] || symbol
|
30
|
+
multiplier(options[:multiplier] || symbol)
|
39
31
|
end
|
40
32
|
|
41
33
|
def to_html(options)
|
42
|
-
options[:multiplier] || "
|
34
|
+
multiplier(options[:multiplier] || "⋅", unicode: true, html: true)
|
43
35
|
end
|
44
36
|
|
45
37
|
def to_unicode(options)
|
46
|
-
options[:multiplier] ||
|
47
|
-
|
38
|
+
extender = options[:multiplier] ||
|
39
|
+
symbol == "*" ? "·" : symbol
|
40
|
+
multiplier(extender)
|
41
|
+
end
|
42
|
+
|
43
|
+
private
|
44
|
+
|
45
|
+
def multiplier(extender, unicode: false, html: false)
|
46
|
+
case extender
|
47
|
+
when :space
|
48
|
+
if html
|
49
|
+
" "
|
50
|
+
else
|
51
|
+
unicode ? "⁢" : " "
|
52
|
+
end
|
53
|
+
when :nospace
|
54
|
+
unicode ? "⁢" : ""
|
55
|
+
else
|
56
|
+
unicode ? Utility.string_to_html_entity(extender) : extender
|
57
|
+
end
|
48
58
|
end
|
49
59
|
end
|
50
60
|
end
|
data/lib/unitsml/formula.rb
CHANGED
@@ -33,15 +33,7 @@ module Unitsml
|
|
33
33
|
math = ::Mml::MathWithNamespace.new(display: "block")
|
34
34
|
math.ordered = true
|
35
35
|
math.element_order ||= []
|
36
|
-
value.each
|
37
|
-
processed_instance = instance.to_mathml(options)
|
38
|
-
case processed_instance
|
39
|
-
when Array
|
40
|
-
processed_instance.each { |hash| add_math_element(math, hash) }
|
41
|
-
when Hash
|
42
|
-
add_math_element(math, processed_instance)
|
43
|
-
end
|
44
|
-
end
|
36
|
+
value.each { |instance| process_value(math, instance.to_mathml(options)) }
|
45
37
|
reset_mml_models if plurimath_available?
|
46
38
|
math.to_xml.gsub(/&(.*?)(?=<\/)/, '&\1')
|
47
39
|
else
|
@@ -186,6 +178,15 @@ module Unitsml
|
|
186
178
|
::Mml::Configuration.custom_models = Plurimath::Mathml::Parser::CONFIGURATION
|
187
179
|
end
|
188
180
|
|
181
|
+
def process_value(math, mathml_instances)
|
182
|
+
case mathml_instances
|
183
|
+
when Array
|
184
|
+
mathml_instances.each { |hash| process_value(math, hash) }
|
185
|
+
when Hash
|
186
|
+
add_math_element(math, mathml_instances)
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
189
190
|
def update_options(options)
|
190
191
|
return options unless root
|
191
192
|
|
data/lib/unitsml/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: unitsml
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-03-
|
11
|
+
date: 2025-03-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: htmlentities
|