asciimath2unitsml 0.2.2 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.rubocop.yml +14 -0
- data/README.adoc +4 -1
- data/asciimath2unitsml.gemspec +1 -1
- data/lib/asciimath2unitsml/conv.rb +37 -19
- data/lib/asciimath2unitsml/parse.rb +20 -14
- data/lib/asciimath2unitsml/render.rb +3 -2
- data/lib/asciimath2unitsml/version.rb +1 -1
- data/lib/unitsdb/units.yaml +7 -3
- data/lib/unitsdb_ruby/unitsdb.rb +1 -0
- data/spec/conv_spec.rb +436 -113
- metadata +8 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2eabcf099e41ebc168ea5904e903893af61c95667e0f778fdf17e39e18fd867a
|
4
|
+
data.tar.gz: 6316d4d968b656249cd69b255e8c68f9f0c7307055fe55d205902c9409d21a9b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4450d314da42fa0941730c668090c7d3bef43ccd8da4a9ad7e5b29a008dcb8abbf9935732229f988a58cbe624ec10eba52e2400efddb7b09a71b6fe51d9ee579
|
7
|
+
data.tar.gz: 66e66fee285dc9788006a58b98e0e3660b8e829aa29c601eb45a3d2ad263da31582df9267a2a93053f24d0ff89503092395b0ec1ff3ffe8d99ec6161b05a260c
|
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
.rubocop-https--*
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
# This project follows the Ribose OSS style guide.
|
2
|
+
# https://github.com/riboseinc/oss-guides
|
3
|
+
# All project-specific additions and overrides should be specified in this file.
|
4
|
+
inherit_from:
|
5
|
+
- https://raw.githubusercontent.com/riboseinc/oss-guides/master/ci/rubocop.yml
|
6
|
+
|
7
|
+
# local repo-specific modifications
|
8
|
+
|
9
|
+
AllCops:
|
10
|
+
DisplayCopNames: false
|
11
|
+
StyleGuideCopsOnly: false
|
12
|
+
TargetRubyVersion: 2.4
|
13
|
+
Rails:
|
14
|
+
Enabled: true
|
data/README.adoc
CHANGED
@@ -53,6 +53,8 @@ from UnitsDB. For example, `unitsml(cal_th/cm^2, name: langley)`.
|
|
53
53
|
The unit-string gives the canonical representation of the unit, but SYMBOL is what will be rendered.
|
54
54
|
For example, `unitsml(cal_th/cm^2, name: langley, symbol: La)`, or `unitsml(mm*s^-2, symbol: mm cdot s^-2)`.
|
55
55
|
(All variables in SYMBOL are rendered upright, as is the default for units.)
|
56
|
+
* `unitsml(unit-string, multiplier: SYMBOL)` provides an alternate symbol for the multiliper of
|
57
|
+
units. The options are an XML entity, or the values `space` or `nospace` (for which see discussion under _Usage_).
|
56
58
|
|
57
59
|
Standalone prefixes can be recognised by replacing the unit with hyphen; so `unitsml(p-)` corresponds
|
58
60
|
to the standalone prefix "pico" (and is rendered as "p").
|
@@ -230,7 +232,7 @@ This table can be generated (in Asciidoc format) through `Asciimath2UnitsML::Con
|
|
230
232
|
| ton | ton of TNT (energy equivalent): `ton_TNT` | ton of refrigeration (12 000 Btu_IT/h): `ton_refrigeration` | | | |
|
231
233
|
| tsp | teaspoon: `tsp` | teaspoon (FDA): `tsp_label` | | | |
|
232
234
|
| yd | yard: `yd` | yard (based on US survey foot): `yd_US_survey` | | | |
|
233
|
-
| &#
|
235
|
+
| ° | degree (degree of arc): `deg` | | | | |
|
234
236
|
| γ | gamma: `gamma` | | | | |
|
235
237
|
| μ | micron: `micron` | | | | |
|
236
238
|
| Ω | ohm: `Ohm` | | | | |
|
@@ -258,3 +260,4 @@ This table can be generated (in Asciidoc format) through `Asciimath2UnitsML::Con
|
|
258
260
|
| °R | degree Rankine: `degR` | | | | |
|
259
261
|
| ƛ~C~ | natural unit of length: `lambda-bar_C` | | | | |
|
260
262
|
|===
|
263
|
+
|
data/asciimath2unitsml.gemspec
CHANGED
@@ -57,7 +57,7 @@ Gem::Specification.new do |spec|
|
|
57
57
|
spec.add_development_dependency "guard-rspec", "~> 4.7"
|
58
58
|
spec.add_development_dependency "rake", "~> 12.0"
|
59
59
|
spec.add_development_dependency "rspec", "~> 3.6"
|
60
|
-
spec.add_development_dependency "rubocop", "
|
60
|
+
spec.add_development_dependency "rubocop", "~> 1.5.2"
|
61
61
|
spec.add_development_dependency "simplecov", "~> 0.15"
|
62
62
|
spec.add_development_dependency "timecop", "~> 0.9"
|
63
63
|
spec.add_development_dependency "rexml"
|
@@ -10,21 +10,25 @@ require_relative "unit"
|
|
10
10
|
|
11
11
|
module Asciimath2UnitsML
|
12
12
|
MATHML_NS = "http://www.w3.org/1998/Math/MathML".freeze
|
13
|
-
UNITSML_NS = "
|
13
|
+
UNITSML_NS = "https://schema.unitsml.org/unitsml/1.0".freeze
|
14
14
|
|
15
15
|
class Conv
|
16
16
|
def initialize(options = {})
|
17
|
-
@dimensions_id = read_yaml("../unitsdb/dimensions.yaml").
|
17
|
+
@dimensions_id = read_yaml("../unitsdb/dimensions.yaml").
|
18
|
+
each_with_object({}) do |(k, v), m|
|
18
19
|
m[k.to_s] = UnitsDB::Dimension.new(k, v)
|
19
20
|
end
|
20
|
-
@prefixes_id = read_yaml("../unitsdb/prefixes.yaml").
|
21
|
+
@prefixes_id = read_yaml("../unitsdb/prefixes.yaml").
|
22
|
+
each_with_object({}) do |(k, v), m|
|
21
23
|
m[k] = UnitsDB::Prefix.new(k, v)
|
22
24
|
end
|
23
25
|
@prefixes = flip_name_and_symbol(@prefixes_id)
|
24
|
-
@quantities = read_yaml("../unitsdb/quantities.yaml").
|
26
|
+
@quantities = read_yaml("../unitsdb/quantities.yaml").
|
27
|
+
each_with_object({}) do |(k, v), m|
|
25
28
|
m[k.to_s] = UnitsDB::Quantity.new(k, v)
|
26
29
|
end
|
27
|
-
@units_id = read_yaml("../unitsdb/units.yaml").
|
30
|
+
@units_id = read_yaml("../unitsdb/units.yaml").
|
31
|
+
each_with_object({}) do |(k, v), m|
|
28
32
|
m[k.to_s] = UnitsDB::Unit.new(k.to_s, v)
|
29
33
|
end
|
30
34
|
@units = flip_name_and_symbols(@units_id)
|
@@ -63,14 +67,16 @@ module Asciimath2UnitsML
|
|
63
67
|
END
|
64
68
|
end
|
65
69
|
|
66
|
-
|
70
|
+
U2D = {
|
67
71
|
"m" => { dimension: "Length", order: 1, symbol: "L" },
|
68
72
|
"g" => { dimension: "Mass", order: 2, symbol: "M" },
|
69
73
|
"kg" => { dimension: "Mass", order: 2, symbol: "M" },
|
70
74
|
"s" => { dimension: "Time", order: 3, symbol: "T" },
|
71
75
|
"A" => { dimension: "ElectricCurrent", order: 4, symbol: "I" },
|
72
|
-
"K" => { dimension: "ThermodynamicTemperature", order: 5,
|
73
|
-
|
76
|
+
"K" => { dimension: "ThermodynamicTemperature", order: 5,
|
77
|
+
symbol: "Theta" },
|
78
|
+
"degK" => { dimension: "ThermodynamicTemperature", order: 5,
|
79
|
+
symbol: "Theta" },
|
74
80
|
"mol" => { dimension: "AmountOfSubstance", order: 6, symbol: "N" },
|
75
81
|
"cd" => { dimension: "LuminousIntensity", order: 7, symbol: "J" },
|
76
82
|
"deg" => { dimension: "PlaneAngle", order: 8, symbol: "Phi" },
|
@@ -78,7 +84,9 @@ module Asciimath2UnitsML
|
|
78
84
|
|
79
85
|
def units2dimensions(units)
|
80
86
|
norm = decompose_units(units)
|
81
|
-
return if norm.any?
|
87
|
+
return if norm.any? do |u|
|
88
|
+
u[:unit] == "unknown" || u[:prefix] == "unknown" || u[:unit].nil?
|
89
|
+
end
|
82
90
|
norm.map do |u|
|
83
91
|
{ dimension: U2D[u[:unit]][:dimension],
|
84
92
|
unit: u[:unit],
|
@@ -88,7 +96,8 @@ module Asciimath2UnitsML
|
|
88
96
|
end
|
89
97
|
|
90
98
|
def dimension1(u)
|
91
|
-
%(<#{u[:dimension]} symbol="#{u[:symbol]}"
|
99
|
+
%(<#{u[:dimension]} symbol="#{u[:symbol]}"
|
100
|
+
powerNumerator="#{float_to_display(u[:exponent])}"/>)
|
92
101
|
end
|
93
102
|
|
94
103
|
def dim_id(dims)
|
@@ -97,9 +106,11 @@ module Asciimath2UnitsML
|
|
97
106
|
dimsvector = %w(Length Mass Time ElectricCurrent ThermodynamicTemperature
|
98
107
|
AmountOfSubstance LuminousIntensity PlaneAngle)
|
99
108
|
.map { |h| dimhash.dig(h, :exponent) }.join(":")
|
100
|
-
id = @dimensions_id&.values&.select { |d| d.vector == dimsvector }&.
|
109
|
+
id = @dimensions_id&.values&.select { |d| d.vector == dimsvector }&.
|
110
|
+
first&.id and return id.to_s
|
101
111
|
"D_" + dims.map do |d|
|
102
|
-
U2D[d[:unit]][:symbol] +
|
112
|
+
U2D[d[:unit]][:symbol] +
|
113
|
+
(d[:exponent] == 1 ? "" : float_to_display(d[:exponent]))
|
103
114
|
end.join("")
|
104
115
|
end
|
105
116
|
|
@@ -111,9 +122,12 @@ module Asciimath2UnitsML
|
|
111
122
|
units.sort { |a, b| a[:unit] <=> b[:unit] }.each_with_object([]) do |k, m|
|
112
123
|
if m.empty? || m[-1][:unit] != k[:unit] then m << k
|
113
124
|
else
|
114
|
-
m[-1] = {
|
115
|
-
|
116
|
-
|
125
|
+
m[-1] = {
|
126
|
+
prefix: combine_prefixes(
|
127
|
+
@prefixes[m[-1][:prefix]], @prefixes[k[:prefix]]),
|
128
|
+
unit: m[-1][:unit],
|
129
|
+
exponent: (k[:exponent]&.to_f || 1) +
|
130
|
+
(m[-1][:exponent]&.to_f || 1) }
|
117
131
|
end
|
118
132
|
end
|
119
133
|
end
|
@@ -128,8 +142,10 @@ module Asciimath2UnitsML
|
|
128
142
|
{ prefix: u[:prefix], unit: "unknown", exponent: u[:exponent] }
|
129
143
|
else
|
130
144
|
@units[u[:unit]].si_derived_bases.each_with_object([]) do |k, m|
|
131
|
-
|
132
|
-
|
145
|
+
prefix = !k[:prefix].nil? && !k[:prefix].empty? ?
|
146
|
+
combine_prefixes(@prefixes_id[k[:prefix]], @prefixes[u[:prefix]]) :
|
147
|
+
u[:prefix]
|
148
|
+
m << { prefix: prefix,
|
133
149
|
unit: @units_id[k[:id]].symbolid,
|
134
150
|
exponent: (k[:power]&.to_i || 1) * (u[:exponent]&.to_f || 1) }
|
135
151
|
end
|
@@ -156,9 +172,11 @@ module Asciimath2UnitsML
|
|
156
172
|
end
|
157
173
|
|
158
174
|
def quantity(normtext, quantity)
|
159
|
-
return unless @units[normtext] && @units[normtext].quantities.size == 1 ||
|
175
|
+
return unless @units[normtext] && @units[normtext].quantities.size == 1 ||
|
176
|
+
@quantities[quantity]
|
160
177
|
id = quantity || @units[normtext].quantities.first
|
161
|
-
|
178
|
+
@units[normtext]&.dimension and
|
179
|
+
dim = %( dimensionURL="##{@units[normtext].dimension}")
|
162
180
|
<<~END
|
163
181
|
<Quantity xmlns='#{UNITSML_NS}' xml:id="#{id}"#{dim} quantityType="base">
|
164
182
|
#{quantityname(id)}
|
@@ -87,7 +87,7 @@ module Asciimath2UnitsML
|
|
87
87
|
prefix2 = /#{@prefixes.keys.select { |x| x.size == 2 }.join("|")}/.r
|
88
88
|
prefix1 = /#{@prefixes.keys.select { |x| x.size == 1 }.join("|")}/.r
|
89
89
|
unit_keys = @units.keys.reject do |k|
|
90
|
-
|
90
|
+
/\*|\^|\/|^1$/.match(k) || @units[k].prefixed
|
91
91
|
end.map { |k| Regexp.escape(k) }
|
92
92
|
unit1 = /#{unit_keys.sort_by(&:length).reverse.join("|")}/.r
|
93
93
|
exponent = /\^\(-?\d+\)/.r.map { |m| m.sub(/\^/, "").gsub(/[()]/, "") } |
|
@@ -97,14 +97,15 @@ module Asciimath2UnitsML
|
|
97
97
|
seq("sqrt(", unit1, ")") { |x| { prefix: nil, unit: x[1], display_exponent: "0.5" } } |
|
98
98
|
seq("sqrt(", prefix1, unit1, ")") { |x| { prefix: x[1], unit: x[2], display_exponent: "0.5" } } |
|
99
99
|
seq("sqrt(", prefix2, unit1, ")") { |x| { prefix: x[1], unit: x[2], display_exponent: "0.5" } } |
|
100
|
-
seq(unit1, exponent._? & multiplier) { |x| { prefix: nil, unit: x[0], display_exponent: (x[1][0] )} } |
|
100
|
+
seq(unit1, exponent._? & (multiplier | ")".r)) { |x| { prefix: nil, unit: x[0], display_exponent: (x[1][0] )} } |
|
101
101
|
seq(unit1, exponent._?).eof { |x| { prefix: nil, unit: x[0], display_exponent: (x[1][0] )} } |
|
102
102
|
seq(prefix1, unit1, exponent._? ) { |x| { prefix: x[0], unit: x[1], display_exponent: (x[2][0] ) } } |
|
103
103
|
seq(prefix2, unit1, exponent._? ) { |x| { prefix: x[0], unit: x[1], display_exponent: (x[2][0] ) } } |
|
104
|
-
"1".r.map { |_| { prefix: nil, unit: "1", display_exponent: nil } }
|
104
|
+
"1".r.map { |_| { prefix: nil, unit: "1", display_exponent: nil } }
|
105
|
+
units1 = "(".r >> lazy{units} << ")" | unit
|
105
106
|
units = seq(prefix2, "-") { |x| [{ prefix: x[0], unit: nil, display_exponent: nil }] } |
|
106
107
|
seq(prefix1, "-") { |x| [{ prefix: x[0], unit: nil, display_exponent: nil }] } |
|
107
|
-
|
108
|
+
units1.join(multiplier)
|
108
109
|
parser = units.eof
|
109
110
|
end
|
110
111
|
|
@@ -119,22 +120,23 @@ module Asciimath2UnitsML
|
|
119
120
|
end
|
120
121
|
|
121
122
|
def postprocess(units, text)
|
122
|
-
units = postprocess1(units)
|
123
|
+
units = postprocess1(units.flatten)
|
123
124
|
quantity = text[1..-1]&.select { |x| /^quantity:/.match(x) }&.first&.sub(/^quantity:\s*/, "")
|
124
125
|
name = text[1..-1]&.select { |x| /^name:/.match(x) }&.first&.sub(/^name:\s*/, "")
|
125
126
|
symbol = text[1..-1]&.select { |x| /^symbol:/.match(x) }&.first&.sub(/^symbol:\s*/, "")
|
127
|
+
multiplier = text[1..-1]&.select { |x| /^multiplier:/.match(x) }&.first&.sub(/^multiplier:\s*/, "")
|
126
128
|
normtext = units_only(units).each.map do |u|
|
127
129
|
exp = u[:exponent] && u[:exponent] != "1" ? "^#{u[:exponent]}" : ""
|
128
130
|
"#{u[:prefix]}#{u[:unit]}#{exp}"
|
129
131
|
end.join("*")
|
130
|
-
[units, text[0], normtext, quantity, name, symbol]
|
132
|
+
[units, text[0], normtext, quantity, name, symbol, multiplier]
|
131
133
|
end
|
132
134
|
|
133
135
|
def postprocess1(units)
|
134
136
|
inverse = false
|
135
137
|
units.each_with_object([]) do |u, m|
|
136
138
|
if u[:multiplier]
|
137
|
-
inverse = (u[:multiplier] == "/")
|
139
|
+
inverse = !inverse if (u[:multiplier] == "/")
|
138
140
|
else
|
139
141
|
u[:exponent] = inverse ? "-#{u[:display_exponent] || '1'}" : u[:display_exponent]
|
140
142
|
u[:exponent] = u[:exponent]&.sub(/^--+/, "")
|
@@ -154,18 +156,22 @@ module Asciimath2UnitsML
|
|
154
156
|
xml.xpath(".//m:mtext", "m" => MATHML_NS).each do |x|
|
155
157
|
next unless %r{^unitsml\(.+\)$}.match(x.text)
|
156
158
|
text = x.text.sub(%r{^unitsml\((.+)\)$}m, "\\1")
|
157
|
-
units, origtext, normtext, quantity, name, symbol = parse(text)
|
158
|
-
rendering = symbol ? embeddedmathml(asciimath2mathml(symbol)) :
|
159
|
-
|
160
|
-
x.replace("#{
|
159
|
+
units, origtext, normtext, quantity, name, symbol, multiplier = parse(text)
|
160
|
+
rendering = symbol ? embeddedmathml(asciimath2mathml(symbol)) :
|
161
|
+
mathmlsymbol(units, false, multiplier)
|
162
|
+
x.replace("#{delimspace(rendering, x)}<mrow xref='#{unit_id(origtext)}'>#{rendering}</mrow>\n"\
|
161
163
|
"#{unitsml(units, origtext, normtext, quantity, name)}")
|
162
164
|
end
|
163
165
|
dedup_ids(xml)
|
164
166
|
end
|
165
167
|
|
166
|
-
|
167
|
-
|
168
|
-
|
168
|
+
# if previous sibling's last descendent non-whitespace is MathML and mn or mi, no space
|
169
|
+
def delimspace(rendering, elem)
|
170
|
+
prec_text_elem = elem.xpath("./preceding-sibling::*[namespace-uri() = '#{MATHML_NS}']/"\
|
171
|
+
"descendant::text()[normalize-space()!=''][last()]/parent::*").last
|
172
|
+
return "" if prec_text_elem.nil? || !%w(mn mi).include?(prec_text_elem&.name)
|
173
|
+
text = HTMLEntities.new.encode(Nokogiri::XML("<mrow>#{rendering}</mrow>").text.strip)
|
174
|
+
/\p{L}|\p{N}/.match(text) ?
|
169
175
|
"<mo rspace='thickmathspace'>⁢</mo>" : "<mo>⁢</mo>"
|
170
176
|
end
|
171
177
|
|
@@ -42,9 +42,10 @@ module Asciimath2UnitsML
|
|
42
42
|
base
|
43
43
|
end
|
44
44
|
|
45
|
-
def mathmlsymbol(units, normalise)
|
45
|
+
def mathmlsymbol(units, normalise, multiplier = nil)
|
46
|
+
multiplier = multiplier ? "<mo>#{multiplier}</mo>" : @multiplier[:mathml]
|
46
47
|
exp = units.map do |u|
|
47
|
-
if u[:multiplier] then u[:multiplier] == "*" ?
|
48
|
+
if u[:multiplier] then u[:multiplier] == "*" ? multiplier : "<mo>#{u[:multiplier]}</mo>"
|
48
49
|
elsif u[:unit].nil? && u[:prefix]
|
49
50
|
%(<mi mathvariant='normal'>#{htmlent(@prefixes[u[:prefix]].html)}</mi>)
|
50
51
|
else
|
data/lib/unitsdb/units.yaml
CHANGED
@@ -1745,6 +1745,7 @@
|
|
1745
1745
|
dimension_url: "#NISTd15"
|
1746
1746
|
short:
|
1747
1747
|
root: false
|
1748
|
+
prefixed: true
|
1748
1749
|
unit_system:
|
1749
1750
|
type: "non-SI_acceptable"
|
1750
1751
|
name: "non-SI"
|
@@ -2046,6 +2047,7 @@
|
|
2046
2047
|
dimension_url: "#NISTd16"
|
2047
2048
|
short:
|
2048
2049
|
root: false
|
2050
|
+
prefixed: true
|
2049
2051
|
unit_system:
|
2050
2052
|
type: "non-SI_not_acceptable"
|
2051
2053
|
name: "non-SI"
|
@@ -2398,6 +2400,7 @@
|
|
2398
2400
|
dimension_url: "#NISTd14"
|
2399
2401
|
short:
|
2400
2402
|
root: false
|
2403
|
+
prefixed: true
|
2401
2404
|
unit_system:
|
2402
2405
|
type: "non-SI_not_acceptable"
|
2403
2406
|
name: "non-SI"
|
@@ -4337,8 +4340,8 @@
|
|
4337
4340
|
unit_symbols:
|
4338
4341
|
- id: "deg"
|
4339
4342
|
ascii: "deg"
|
4340
|
-
html: "&#
|
4341
|
-
mathml: "<mi mathvariant='normal'>&#
|
4343
|
+
html: "°"
|
4344
|
+
mathml: "<mi mathvariant='normal'>°</mi>"
|
4342
4345
|
latex: \ensuremath{\mathrm{^{\circ}}}
|
4343
4346
|
unicode: "º"
|
4344
4347
|
root_units:
|
@@ -9981,6 +9984,7 @@
|
|
9981
9984
|
dimension_url: "#NISTd56"
|
9982
9985
|
short:
|
9983
9986
|
root: false
|
9987
|
+
prefixed: true
|
9984
9988
|
unit_system:
|
9985
9989
|
type: "non-SI_not_acceptable"
|
9986
9990
|
name: "non-SI"
|
@@ -10439,7 +10443,7 @@
|
|
10439
10443
|
url: "#NISTq1"
|
10440
10444
|
|
10441
10445
|
"NISTu400":
|
10442
|
-
dimension_url: "#
|
10446
|
+
dimension_url: "#NISTd80"
|
10443
10447
|
short:
|
10444
10448
|
root: false
|
10445
10449
|
unit_system:
|
data/lib/unitsdb_ruby/unitsdb.rb
CHANGED
@@ -135,6 +135,7 @@ module UnitsDB
|
|
135
135
|
@root = hash[:root_units][:enumerated_root_units]
|
136
136
|
hash[:quantity_reference] and @quantities = hash[:quantity_reference].map { |x| x[:url].sub(/^#/, "") }
|
137
137
|
hash[:si_derived_bases] and @si_derived_bases = hash[:si_derived_bases]
|
138
|
+
@prefixed = (hash[:prefixed] == true)
|
138
139
|
rescue
|
139
140
|
raise StandardError.new "Parse fail on Unit #{id}: #{hash}"
|
140
141
|
end
|
data/spec/conv_spec.rb
CHANGED
@@ -22,7 +22,7 @@ RSpec.describe Asciimath2UnitsML do
|
|
22
22
|
</mrow>
|
23
23
|
</msup>
|
24
24
|
</mrow>
|
25
|
-
<Unit xmlns='
|
25
|
+
<Unit xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='U_mm.s-2' dimensionURL='#NISTd28'>
|
26
26
|
<UnitSystem name='SI' type='SI_derived' xml:lang='en-US'/>
|
27
27
|
<UnitName xml:lang='en'>mm*s^-2</UnitName>
|
28
28
|
<UnitSymbol type='HTML'>
|
@@ -51,14 +51,14 @@ RSpec.describe Asciimath2UnitsML do
|
|
51
51
|
<EnumeratedRootUnit unit='second' powerNumerator='-2'/>
|
52
52
|
</RootUnits>
|
53
53
|
</Unit>
|
54
|
-
<Prefix xmlns='
|
54
|
+
<Prefix xmlns='https://schema.unitsml.org/unitsml/1.0' prefixBase='10' prefixPower='-3' xml:id='NISTp10_-3'>
|
55
55
|
<PrefixName xml:lang='en'>milli</PrefixName>
|
56
56
|
<PrefixSymbol type='ASCII'>m</PrefixSymbol>
|
57
57
|
<PrefixSymbol type='unicode'>m</PrefixSymbol>
|
58
58
|
<PrefixSymbol type='LaTeX'>m</PrefixSymbol>
|
59
59
|
<PrefixSymbol type='HTML'>m</PrefixSymbol>
|
60
60
|
</Prefix>
|
61
|
-
<Dimension xmlns='
|
61
|
+
<Dimension xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='NISTd28'>
|
62
62
|
<Length symbol='L' powerNumerator='1'/>
|
63
63
|
<Time symbol='T' powerNumerator='-2'/>
|
64
64
|
</Dimension>
|
@@ -66,7 +66,7 @@ RSpec.describe Asciimath2UnitsML do
|
|
66
66
|
OUTPUT
|
67
67
|
end
|
68
68
|
|
69
|
-
|
69
|
+
it "deals with non-Ascii units and prefixes" do
|
70
70
|
expect(xmlpp(Asciimath2UnitsML::Conv.new().Asciimath2UnitsML(<<~INPUT))).to be_equivalent_to xmlpp(<<~OUTPUT)
|
71
71
|
1 "unitsml(um)"
|
72
72
|
INPUT
|
@@ -77,7 +77,7 @@ RSpec.describe Asciimath2UnitsML do
|
|
77
77
|
<mrow xref='U_um'>
|
78
78
|
<mi mathvariant='normal'>µm</mi>
|
79
79
|
</mrow>
|
80
|
-
<Unit xmlns='
|
80
|
+
<Unit xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='U_um' dimensionURL='#NISTd1'>
|
81
81
|
<UnitSystem name='SI' type='SI_derived' xml:lang='en-US'/>
|
82
82
|
<UnitName xml:lang='en'>um</UnitName>
|
83
83
|
<UnitSymbol type='HTML'>um</UnitSymbol>
|
@@ -92,77 +92,196 @@ RSpec.describe Asciimath2UnitsML do
|
|
92
92
|
<EnumeratedRootUnit unit='meter' prefix='u'/>
|
93
93
|
</RootUnits>
|
94
94
|
</Unit>
|
95
|
-
<Prefix xmlns='
|
95
|
+
<Prefix xmlns='https://schema.unitsml.org/unitsml/1.0' prefixBase='10' prefixPower='-6' xml:id='NISTp10_-6'>
|
96
96
|
<PrefixName xml:lang='en'>micro</PrefixName>
|
97
97
|
<PrefixSymbol type='ASCII'>u</PrefixSymbol>
|
98
98
|
<PrefixSymbol type='unicode'>μ</PrefixSymbol>
|
99
99
|
<PrefixSymbol type='LaTeX'>$mu$</PrefixSymbol>
|
100
100
|
<PrefixSymbol type='HTML'>µ</PrefixSymbol>
|
101
101
|
</Prefix>
|
102
|
-
<Dimension xmlns='
|
102
|
+
<Dimension xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='NISTd1'>
|
103
103
|
<Length symbol='L' powerNumerator='1'/>
|
104
104
|
</Dimension>
|
105
105
|
</math>
|
106
106
|
OUTPUT
|
107
107
|
end
|
108
108
|
|
109
|
-
|
109
|
+
it "does not insert space before non-alphabetic units" do
|
110
110
|
expect(xmlpp(Asciimath2UnitsML::Conv.new().Asciimath2UnitsML(<<~INPUT))).to be_equivalent_to xmlpp(<<~OUTPUT)
|
111
|
-
1 "unitsml(degK)" + 1 "unitsml(prime)"
|
111
|
+
1 "unitsml(degK)" + 1 "unitsml(prime)" + ii(theta) = s//r "unitsml(rad)" + 10^(12) "unitsml(Hz)"
|
112
112
|
INPUT
|
113
113
|
<math xmlns='http://www.w3.org/1998/Math/MathML'>
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
114
|
+
<mn>1</mn>
|
115
|
+
<mo rspace='thickmathspace'>⁢</mo>
|
116
|
+
<mrow xref='U_NISTu5'>
|
117
|
+
<mi mathvariant='normal'>°K</mi>
|
118
|
+
</mrow>
|
119
|
+
<Unit xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='U_NISTu5' dimensionURL='#NISTd5'>
|
120
|
+
<UnitSystem name='SI' type='SI_derived' xml:lang='en-US'/>
|
121
|
+
<UnitName xml:lang='en'>kelvin</UnitName>
|
122
|
+
<UnitSymbol type='HTML'>K</UnitSymbol>
|
123
|
+
<UnitSymbol type='MathML'>
|
124
|
+
<math xmlns='http://www.w3.org/1998/Math/MathML'>
|
125
|
+
<mrow>
|
126
|
+
<mi mathvariant='normal'>K</mi>
|
127
|
+
</mrow>
|
128
|
+
</math>
|
129
|
+
</UnitSymbol>
|
130
|
+
</Unit>
|
131
|
+
<Dimension xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='NISTd5'>
|
132
|
+
<ThermodynamicTemperature symbol='Theta' powerNumerator='1'/>
|
133
|
+
</Dimension>
|
134
|
+
<Quantity xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='NISTq5' dimensionURL='#NISTd5' quantityType='base'>
|
135
|
+
<QuantityName xml:lang='en-US'>thermodynamic temperature</QuantityName>
|
136
|
+
</Quantity>
|
137
|
+
<mo>+</mo>
|
138
|
+
<mn>1</mn>
|
139
|
+
<mo>⁢</mo>
|
140
|
+
<mrow xref='U_NISTu147'>
|
141
|
+
<mi mathvariant='normal'>′</mi>
|
142
|
+
</mrow>
|
143
|
+
<Unit xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='U_NISTu147'>
|
144
|
+
<UnitSystem name='not_SI' type='not_SI' xml:lang='en-US'/>
|
145
|
+
<UnitName xml:lang='en'>minute (minute of arc)</UnitName>
|
146
|
+
<UnitSymbol type='HTML'>′</UnitSymbol>
|
147
|
+
<UnitSymbol type='MathML'>
|
148
|
+
<math xmlns='http://www.w3.org/1998/Math/MathML'>
|
149
|
+
<mrow>
|
150
|
+
<mi mathvariant='normal'>′</mi>
|
151
|
+
</mrow>
|
152
|
+
</math>
|
153
|
+
</UnitSymbol>
|
154
|
+
</Unit>
|
155
|
+
<Dimension xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='NISTd9'>
|
156
|
+
<PlaneAngle symbol='Phi' powerNumerator='1'/>
|
157
|
+
</Dimension>
|
158
|
+
<Quantity xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='NISTq9' dimensionURL='#NISTd9' quantityType='base'>
|
159
|
+
<QuantityName xml:lang='en-US'>plane angle</QuantityName>
|
160
|
+
<QuantityName xml:lang='en-US'>angle</QuantityName>
|
161
|
+
</Quantity>
|
162
|
+
<mo>+</mo>
|
163
|
+
<mstyle mathvariant='italic'>
|
164
|
+
<mi>θ</mi>
|
165
|
+
</mstyle>
|
166
|
+
<mo>=</mo>
|
167
|
+
<mi>s</mi>
|
168
|
+
<mo>/</mo>
|
169
|
+
<mi>r</mi>
|
170
|
+
<mo rspace='thickmathspace'>⁢</mo>
|
171
|
+
<mrow xref='U_NISTu9'>
|
172
|
+
<mi mathvariant='normal'>rad</mi>
|
173
|
+
</mrow>
|
174
|
+
<Unit xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='U_NISTu9' dimensionURL='#D_L0'>
|
175
|
+
<UnitSystem name='SI' type='SI_derived' xml:lang='en-US'/>
|
176
|
+
<UnitName xml:lang='en'>radian</UnitName>
|
177
|
+
<UnitSymbol type='HTML'>rad</UnitSymbol>
|
178
|
+
<UnitSymbol type='MathML'>
|
179
|
+
<math xmlns='http://www.w3.org/1998/Math/MathML'>
|
180
|
+
<mrow>
|
181
|
+
<mi mathvariant='normal'>rad</mi>
|
182
|
+
</mrow>
|
183
|
+
</math>
|
184
|
+
</UnitSymbol>
|
185
|
+
</Unit>
|
186
|
+
<Dimension xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='D_L0'>
|
187
|
+
<Length symbol='L' powerNumerator='0'/>
|
188
|
+
</Dimension>
|
189
|
+
<mo>+</mo>
|
190
|
+
<msup>
|
191
|
+
<mrow>
|
192
|
+
<mn>10</mn>
|
193
|
+
</mrow>
|
194
|
+
<mrow>
|
195
|
+
<mn>12</mn>
|
196
|
+
</mrow>
|
197
|
+
</msup>
|
198
|
+
<mo rspace='thickmathspace'>⁢</mo>
|
199
|
+
<mrow xref='U_NISTu31'>
|
200
|
+
<mi mathvariant='normal'>Hz</mi>
|
201
|
+
</mrow>
|
202
|
+
<Unit xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='U_NISTu31' dimensionURL='#NISTd24'>
|
203
|
+
<UnitSystem name='SI' type='SI_derived' xml:lang='en-US'/>
|
204
|
+
<UnitName xml:lang='en'>hertz</UnitName>
|
205
|
+
<UnitSymbol type='HTML'>Hz</UnitSymbol>
|
206
|
+
<UnitSymbol type='MathML'>
|
207
|
+
<math xmlns='http://www.w3.org/1998/Math/MathML'>
|
208
|
+
<mrow>
|
209
|
+
<mi mathvariant='normal'>Hz</mi>
|
210
|
+
</mrow>
|
211
|
+
</math>
|
212
|
+
</UnitSymbol>
|
213
|
+
</Unit>
|
214
|
+
<Dimension xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='NISTd24'>
|
215
|
+
<Time symbol='T' powerNumerator='-1'/>
|
216
|
+
</Dimension>
|
217
|
+
<Quantity xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='NISTq45' dimensionURL='#NISTd24' quantityType='base'>
|
218
|
+
<QuantityName xml:lang='en-US'>frequency</QuantityName>
|
219
|
+
</Quantity>
|
220
|
+
</math>
|
163
221
|
OUTPUT
|
164
222
|
end
|
165
223
|
|
224
|
+
it "does not insert space before operators" do
|
225
|
+
expect(xmlpp(Asciimath2UnitsML::Conv.new().Asciimath2UnitsML(<<~INPUT))).to be_equivalent_to xmlpp(<<~OUTPUT)
|
226
|
+
8 "unitsml(kg)" cdot "unitsml(m)"
|
227
|
+
INPUT
|
228
|
+
<math xmlns='http://www.w3.org/1998/Math/MathML'>
|
229
|
+
<mn>8</mn>
|
230
|
+
<mo rspace='thickmathspace'>⁢</mo>
|
231
|
+
<mrow xref='U_NISTu2'>
|
232
|
+
<mi mathvariant='normal'>kg</mi>
|
233
|
+
</mrow>
|
234
|
+
<Unit xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='U_NISTu2' dimensionURL='#NISTd2'>
|
235
|
+
<UnitSystem name='SI' type='SI_base' xml:lang='en-US'/>
|
236
|
+
<UnitName xml:lang='en'>kilogram</UnitName>
|
237
|
+
<UnitSymbol type='HTML'>kg</UnitSymbol>
|
238
|
+
<UnitSymbol type='MathML'>
|
239
|
+
<math xmlns='http://www.w3.org/1998/Math/MathML'>
|
240
|
+
<mrow>
|
241
|
+
<mi mathvariant='normal'>kg</mi>
|
242
|
+
</mrow>
|
243
|
+
</math>
|
244
|
+
</UnitSymbol>
|
245
|
+
<RootUnits>
|
246
|
+
<EnumeratedRootUnit unit='gram' prefix='k'/>
|
247
|
+
</RootUnits>
|
248
|
+
</Unit>
|
249
|
+
<Prefix xmlns='https://schema.unitsml.org/unitsml/1.0' prefixBase='10' prefixPower='3' xml:id='NISTp10_3'>
|
250
|
+
<PrefixName xml:lang='en'>kilo</PrefixName>
|
251
|
+
<PrefixSymbol type='ASCII'>k</PrefixSymbol>
|
252
|
+
<PrefixSymbol type='unicode'>k</PrefixSymbol>
|
253
|
+
<PrefixSymbol type='LaTeX'>k</PrefixSymbol>
|
254
|
+
<PrefixSymbol type='HTML'>k</PrefixSymbol>
|
255
|
+
</Prefix>
|
256
|
+
<Dimension xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='NISTd2'>
|
257
|
+
<Mass symbol='M' powerNumerator='1'/>
|
258
|
+
</Dimension>
|
259
|
+
<Quantity xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='NISTq2' dimensionURL='#NISTd2' quantityType='base'>
|
260
|
+
<QuantityName xml:lang='en-US'>mass</QuantityName>
|
261
|
+
</Quantity>
|
262
|
+
<mo>⋅</mo>
|
263
|
+
<mrow xref='U_NISTu1'>
|
264
|
+
<mi mathvariant='normal'>m</mi>
|
265
|
+
</mrow>
|
266
|
+
<Unit xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='U_NISTu1' dimensionURL='#NISTd1'>
|
267
|
+
<UnitSystem name='SI' type='SI_derived' xml:lang='en-US'/>
|
268
|
+
<UnitName xml:lang='en'>meter</UnitName>
|
269
|
+
<UnitSymbol type='HTML'>m</UnitSymbol>
|
270
|
+
<UnitSymbol type='MathML'>
|
271
|
+
<math xmlns='http://www.w3.org/1998/Math/MathML'>
|
272
|
+
<mrow>
|
273
|
+
<mi mathvariant='normal'>m</mi>
|
274
|
+
</mrow>
|
275
|
+
</math>
|
276
|
+
</UnitSymbol>
|
277
|
+
</Unit>
|
278
|
+
<Dimension xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='NISTd1'>
|
279
|
+
<Length symbol='L' powerNumerator='1'/>
|
280
|
+
</Dimension>
|
281
|
+
</math>
|
282
|
+
OUTPUT
|
283
|
+
end
|
284
|
+
|
166
285
|
it "deals with sqrt units" do
|
167
286
|
expect(xmlpp(Asciimath2UnitsML::Conv.new().Asciimath2UnitsML(<<~INPUT))).to be_equivalent_to xmlpp(<<~OUTPUT)
|
168
287
|
1 "unitsml(sqrt(Hz))"
|
@@ -175,7 +294,7 @@ OUTPUT
|
|
175
294
|
<mi mathvariant='normal'>Hz</mi>
|
176
295
|
</msqrt>
|
177
296
|
</mrow>
|
178
|
-
<Unit xmlns='
|
297
|
+
<Unit xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='U_Hz0.5' dimensionURL='#D_T-0.5'>
|
179
298
|
<UnitSystem name='SI' type='SI_derived' xml:lang='en-US'/>
|
180
299
|
<UnitName xml:lang='en'>Hz^0.5</UnitName>
|
181
300
|
<UnitSymbol type='HTML'>√Hz</UnitSymbol>
|
@@ -189,7 +308,7 @@ OUTPUT
|
|
189
308
|
</math>
|
190
309
|
</UnitSymbol>
|
191
310
|
</Unit>
|
192
|
-
<Dimension xmlns='
|
311
|
+
<Dimension xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='D_T-0.5'>
|
193
312
|
<Time symbol='T' powerNumerator='-0.5'/>
|
194
313
|
</Dimension>
|
195
314
|
</math>
|
@@ -206,7 +325,7 @@ OUTPUT
|
|
206
325
|
<mrow xref='U_NISTu2'>
|
207
326
|
<mi mathvariant='normal'>kg</mi>
|
208
327
|
</mrow>
|
209
|
-
<Unit xmlns='
|
328
|
+
<Unit xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='U_NISTu2' dimensionURL='#NISTd2'>
|
210
329
|
<UnitSystem name='SI' type='SI_base' xml:lang='en-US'/>
|
211
330
|
<UnitName xml:lang='en'>kilogram</UnitName>
|
212
331
|
<UnitSymbol type='HTML'>kg</UnitSymbol>
|
@@ -221,17 +340,17 @@ OUTPUT
|
|
221
340
|
<EnumeratedRootUnit unit='gram' prefix='k'/>
|
222
341
|
</RootUnits>
|
223
342
|
</Unit>
|
224
|
-
<Prefix xmlns='
|
343
|
+
<Prefix xmlns='https://schema.unitsml.org/unitsml/1.0' prefixBase='10' prefixPower='3' xml:id='NISTp10_3'>
|
225
344
|
<PrefixName xml:lang='en'>kilo</PrefixName>
|
226
345
|
<PrefixSymbol type='ASCII'>k</PrefixSymbol>
|
227
346
|
<PrefixSymbol type='unicode'>k</PrefixSymbol>
|
228
347
|
<PrefixSymbol type='LaTeX'>k</PrefixSymbol>
|
229
348
|
<PrefixSymbol type='HTML'>k</PrefixSymbol>
|
230
349
|
</Prefix>
|
231
|
-
<Dimension xmlns='
|
350
|
+
<Dimension xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='NISTd2'>
|
232
351
|
<Mass symbol='M' powerNumerator='1'/>
|
233
352
|
</Dimension>
|
234
|
-
<Quantity xmlns='
|
353
|
+
<Quantity xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='NISTq2' dimensionURL='#NISTd2' quantityType='base'>
|
235
354
|
<QuantityName xml:lang='en-US'>mass</QuantityName>
|
236
355
|
</Quantity>
|
237
356
|
<mo>+</mo>
|
@@ -240,7 +359,7 @@ OUTPUT
|
|
240
359
|
<mrow xref='U_NISTu27'>
|
241
360
|
<mi mathvariant='normal'>g</mi>
|
242
361
|
</mrow>
|
243
|
-
<Unit xmlns='
|
362
|
+
<Unit xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='U_NISTu27' dimensionURL='#NISTd2'>
|
244
363
|
<UnitSystem name='SI' type='SI_derived' xml:lang='en-US'/>
|
245
364
|
<UnitName xml:lang='en'>gram</UnitName>
|
246
365
|
<UnitSymbol type='HTML'>g</UnitSymbol>
|
@@ -266,7 +385,7 @@ OUTPUT
|
|
266
385
|
<mrow xref='U_NISTu284'>
|
267
386
|
<mi mathvariant='normal'>hp</mi>
|
268
387
|
</mrow>
|
269
|
-
<Unit xmlns='
|
388
|
+
<Unit xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='U_NISTu284'>
|
270
389
|
<UnitSystem name='not_SI' type='not_SI' xml:lang='en-US'/>
|
271
390
|
<UnitName xml:lang='en'>horsepower</UnitName>
|
272
391
|
<UnitSymbol type='HTML'>hp</UnitSymbol>
|
@@ -278,12 +397,12 @@ OUTPUT
|
|
278
397
|
</math>
|
279
398
|
</UnitSymbol>
|
280
399
|
</Unit>
|
281
|
-
<Dimension xmlns='
|
400
|
+
<Dimension xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='NISTd16'>
|
282
401
|
<Length symbol='L' powerNumerator='2'/>
|
283
402
|
<Mass symbol='M' powerNumerator='1'/>
|
284
403
|
<Time symbol='T' powerNumerator='-3'/>
|
285
404
|
</Dimension>
|
286
|
-
<Quantity xmlns='
|
405
|
+
<Quantity xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='NISTq20' dimensionURL='#NISTd16' quantityType='base'>
|
287
406
|
<QuantityName xml:lang='en-US'>power</QuantityName>
|
288
407
|
</Quantity>
|
289
408
|
</math>
|
@@ -310,7 +429,7 @@ OUTPUT
|
|
310
429
|
</mrow>
|
311
430
|
</msup>
|
312
431
|
</mrow>
|
313
|
-
<Unit xmlns='
|
432
|
+
<Unit xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='U_kg.s-2' dimensionURL='#NISTd37'>
|
314
433
|
<UnitSystem name='SI' type='SI_derived' xml:lang='en-US'/>
|
315
434
|
<UnitName xml:lang='en'>kg*s^-2</UnitName>
|
316
435
|
<UnitSymbol type='HTML'>
|
@@ -339,14 +458,14 @@ OUTPUT
|
|
339
458
|
<EnumeratedRootUnit unit='second' powerNumerator='-2'/>
|
340
459
|
</RootUnits>
|
341
460
|
</Unit>
|
342
|
-
<Prefix xmlns='
|
461
|
+
<Prefix xmlns='https://schema.unitsml.org/unitsml/1.0' prefixBase='10' prefixPower='3' xml:id='NISTp10_3'>
|
343
462
|
<PrefixName xml:lang='en'>kilo</PrefixName>
|
344
463
|
<PrefixSymbol type='ASCII'>k</PrefixSymbol>
|
345
464
|
<PrefixSymbol type='unicode'>k</PrefixSymbol>
|
346
465
|
<PrefixSymbol type='LaTeX'>k</PrefixSymbol>
|
347
466
|
<PrefixSymbol type='HTML'>k</PrefixSymbol>
|
348
467
|
</Prefix>
|
349
|
-
<Dimension xmlns='
|
468
|
+
<Dimension xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='NISTd37'>
|
350
469
|
<Mass symbol='M' powerNumerator='1'/>
|
351
470
|
<Time symbol='T' powerNumerator='-2'/>
|
352
471
|
</Dimension>
|
@@ -370,6 +489,78 @@ OUTPUT
|
|
370
489
|
OUTPUT
|
371
490
|
end
|
372
491
|
|
492
|
+
it "deals with parentheses" do
|
493
|
+
expect(xmlpp(Asciimath2UnitsML::Conv.new().Asciimath2UnitsML(<<~INPUT))).to be_equivalent_to xmlpp(<<~OUTPUT)
|
494
|
+
10 "unitsml(K/(kg*m))"
|
495
|
+
INPUT
|
496
|
+
<math xmlns='http://www.w3.org/1998/Math/MathML'>
|
497
|
+
<mn>10</mn>
|
498
|
+
<mo rspace='thickmathspace'>⁢</mo>
|
499
|
+
<mrow xref='U_K/kg.m'>
|
500
|
+
<mi mathvariant='normal'>K</mi>
|
501
|
+
<mo>/</mo>
|
502
|
+
<mi mathvariant='normal'>kg</mi>
|
503
|
+
<mo>·</mo>
|
504
|
+
<mi mathvariant='normal'>m</mi>
|
505
|
+
</mrow>
|
506
|
+
<Unit xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='U_K.kg-1.m-1' dimensionURL='#D_L-1M-1Theta'>
|
507
|
+
<UnitSystem name='SI' type='SI_derived' xml:lang='en-US'/>
|
508
|
+
<UnitName xml:lang='en'>K*kg^-1*m^-1</UnitName>
|
509
|
+
<UnitSymbol type='HTML'>
|
510
|
+
K·kg
|
511
|
+
<sup>−1</sup>
|
512
|
+
·m
|
513
|
+
<sup>−1</sup>
|
514
|
+
</UnitSymbol>
|
515
|
+
<UnitSymbol type='MathML'>
|
516
|
+
<math xmlns='http://www.w3.org/1998/Math/MathML'>
|
517
|
+
<mrow>
|
518
|
+
<mi mathvariant='normal'>K</mi>
|
519
|
+
<mo>·</mo>
|
520
|
+
<msup>
|
521
|
+
<mrow>
|
522
|
+
<mi mathvariant='normal'>kg</mi>
|
523
|
+
</mrow>
|
524
|
+
<mrow>
|
525
|
+
<mo>−</mo>
|
526
|
+
<mn>1</mn>
|
527
|
+
</mrow>
|
528
|
+
</msup>
|
529
|
+
<mo>·</mo>
|
530
|
+
<msup>
|
531
|
+
<mrow>
|
532
|
+
<mi mathvariant='normal'>m</mi>
|
533
|
+
</mrow>
|
534
|
+
<mrow>
|
535
|
+
<mo>−</mo>
|
536
|
+
<mn>1</mn>
|
537
|
+
</mrow>
|
538
|
+
</msup>
|
539
|
+
</mrow>
|
540
|
+
</math>
|
541
|
+
</UnitSymbol>
|
542
|
+
<RootUnits>
|
543
|
+
<EnumeratedRootUnit unit='kelvin'/>
|
544
|
+
<EnumeratedRootUnit unit='gram' prefix='k' powerNumerator='-1'/>
|
545
|
+
<EnumeratedRootUnit unit='meter' powerNumerator='-1'/>
|
546
|
+
</RootUnits>
|
547
|
+
</Unit>
|
548
|
+
<Prefix xmlns='https://schema.unitsml.org/unitsml/1.0' prefixBase='10' prefixPower='3' xml:id='NISTp10_3'>
|
549
|
+
<PrefixName xml:lang='en'>kilo</PrefixName>
|
550
|
+
<PrefixSymbol type='ASCII'>k</PrefixSymbol>
|
551
|
+
<PrefixSymbol type='unicode'>k</PrefixSymbol>
|
552
|
+
<PrefixSymbol type='LaTeX'>k</PrefixSymbol>
|
553
|
+
<PrefixSymbol type='HTML'>k</PrefixSymbol>
|
554
|
+
</Prefix>
|
555
|
+
<Dimension xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='D_L-1M-1Theta'>
|
556
|
+
<Length symbol='L' powerNumerator='-1'/>
|
557
|
+
<Mass symbol='M' powerNumerator='-1'/>
|
558
|
+
<ThermodynamicTemperature symbol='Theta' powerNumerator='1'/>
|
559
|
+
</Dimension>
|
560
|
+
</math>
|
561
|
+
OUTPUT
|
562
|
+
end
|
563
|
+
|
373
564
|
it "deals with notational variants" do
|
374
565
|
expect(xmlpp(Asciimath2UnitsML::Conv.new().Asciimath2UnitsML(<<~INPUT))).to be_equivalent_to xmlpp(<<~OUTPUT)
|
375
566
|
9 "unitsml(degK)" + 10 "unitsml(K)"
|
@@ -380,7 +571,7 @@ INPUT
|
|
380
571
|
<mrow xref='U_NISTu5'>
|
381
572
|
<mi mathvariant='normal'>°K</mi>
|
382
573
|
</mrow>
|
383
|
-
<Unit xmlns='
|
574
|
+
<Unit xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='U_NISTu5' dimensionURL='#NISTd5'>
|
384
575
|
<UnitSystem name='SI' type='SI_derived' xml:lang='en-US'/>
|
385
576
|
<UnitName xml:lang='en'>kelvin</UnitName>
|
386
577
|
<UnitSymbol type='HTML'>K</UnitSymbol>
|
@@ -392,10 +583,10 @@ INPUT
|
|
392
583
|
</math>
|
393
584
|
</UnitSymbol>
|
394
585
|
</Unit>
|
395
|
-
<Dimension xmlns='
|
586
|
+
<Dimension xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='NISTd5'>
|
396
587
|
<ThermodynamicTemperature symbol='Theta' powerNumerator='1'/>
|
397
588
|
</Dimension>
|
398
|
-
<Quantity xmlns='
|
589
|
+
<Quantity xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='NISTq5' dimensionURL='#NISTd5' quantityType='base'>
|
399
590
|
<QuantityName xml:lang='en-US'>thermodynamic temperature</QuantityName>
|
400
591
|
</Quantity>
|
401
592
|
<mo>+</mo>
|
@@ -418,7 +609,7 @@ INPUT
|
|
418
609
|
<mrow xref='U_NISTu362'>
|
419
610
|
<mi mathvariant='normal'>mbar</mi>
|
420
611
|
</mrow>
|
421
|
-
<Unit xmlns='
|
612
|
+
<Unit xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='U_NISTu362'>
|
422
613
|
<UnitSystem name='not_SI' type='not_SI' xml:lang='en-US'/>
|
423
614
|
<UnitName xml:lang='en'>millibar</UnitName>
|
424
615
|
<UnitSymbol type='HTML'>mbar</UnitSymbol>
|
@@ -433,14 +624,14 @@ INPUT
|
|
433
624
|
<EnumeratedRootUnit unit='bar' prefix='m'/>
|
434
625
|
</RootUnits>
|
435
626
|
</Unit>
|
436
|
-
<Prefix xmlns='
|
627
|
+
<Prefix xmlns='https://schema.unitsml.org/unitsml/1.0' prefixBase='10' prefixPower='-3' xml:id='NISTp10_-3'>
|
437
628
|
<PrefixName xml:lang='en'>milli</PrefixName>
|
438
629
|
<PrefixSymbol type='ASCII'>m</PrefixSymbol>
|
439
630
|
<PrefixSymbol type='unicode'>m</PrefixSymbol>
|
440
631
|
<PrefixSymbol type='LaTeX'>m</PrefixSymbol>
|
441
632
|
<PrefixSymbol type='HTML'>m</PrefixSymbol>
|
442
633
|
</Prefix>
|
443
|
-
<Dimension xmlns='
|
634
|
+
<Dimension xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='NISTd14'>
|
444
635
|
<Length symbol='L' powerNumerator='-1'/>
|
445
636
|
<Mass symbol='M' powerNumerator='1'/>
|
446
637
|
<Time symbol='T' powerNumerator='-2'/>
|
@@ -457,7 +648,7 @@ OUTPUT
|
|
457
648
|
<mrow xref='NISTp10_-12'>
|
458
649
|
<mi mathvariant='normal'>p</mi>
|
459
650
|
</mrow>
|
460
|
-
<Prefix xmlns='
|
651
|
+
<Prefix xmlns='https://schema.unitsml.org/unitsml/1.0' prefixBase='10' prefixPower='-12' xml:id='NISTp10_-12'>
|
461
652
|
<PrefixName xml:lang='en'>pico</PrefixName>
|
462
653
|
<PrefixSymbol type='ASCII'>p</PrefixSymbol>
|
463
654
|
<PrefixSymbol type='unicode'>p</PrefixSymbol>
|
@@ -468,7 +659,7 @@ OUTPUT
|
|
468
659
|
<mrow xref='NISTp10_1'>
|
469
660
|
<mi mathvariant='normal'>da</mi>
|
470
661
|
</mrow>
|
471
|
-
<Prefix xmlns='
|
662
|
+
<Prefix xmlns='https://schema.unitsml.org/unitsml/1.0' prefixBase='10' prefixPower='1' xml:id='NISTp10_1'>
|
472
663
|
<PrefixName xml:lang='en'>deka</PrefixName>
|
473
664
|
<PrefixSymbol type='ASCII'>da</PrefixSymbol>
|
474
665
|
<PrefixSymbol type='unicode'>da</PrefixSymbol>
|
@@ -487,25 +678,24 @@ INPUT
|
|
487
678
|
<mrow xref='NISTp10_-6'>
|
488
679
|
<mi mathvariant='normal'>µ</mi>
|
489
680
|
</mrow>
|
490
|
-
<Prefix xmlns='
|
681
|
+
<Prefix xmlns='https://schema.unitsml.org/unitsml/1.0' prefixBase='10' prefixPower='-6' xml:id='NISTp10_-6'>
|
491
682
|
<PrefixName xml:lang='en'>micro</PrefixName>
|
492
683
|
<PrefixSymbol type='ASCII'>u</PrefixSymbol>
|
493
684
|
<PrefixSymbol type='unicode'>μ</PrefixSymbol>
|
494
685
|
<PrefixSymbol type='LaTeX'>$mu$</PrefixSymbol>
|
495
686
|
<PrefixSymbol type='HTML'>µ</PrefixSymbol>
|
496
687
|
</Prefix>
|
497
|
-
<Dimension xmlns='
|
688
|
+
<Dimension xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='NISTd2'>
|
498
689
|
<Mass symbol='M' powerNumerator='1'/>
|
499
690
|
</Dimension>
|
500
|
-
<Quantity xmlns='
|
691
|
+
<Quantity xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='NISTq2' dimensionURL='#NISTd2' quantityType='base'>
|
501
692
|
<QuantityName xml:lang='en-US'>mass</QuantityName>
|
502
693
|
</Quantity>
|
503
694
|
<mo>+</mo>
|
504
|
-
<mo rspace='thickmathspace'>⁢</mo>
|
505
695
|
<mrow xref='U_um'>
|
506
696
|
<mi mathvariant='normal'>µm</mi>
|
507
697
|
</mrow>
|
508
|
-
<Unit xmlns='
|
698
|
+
<Unit xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='U_um' dimensionURL='#NISTd1'>
|
509
699
|
<UnitSystem name='SI' type='SI_derived' xml:lang='en-US'/>
|
510
700
|
<UnitName xml:lang='en'>um</UnitName>
|
511
701
|
<UnitSymbol type='HTML'>um</UnitSymbol>
|
@@ -520,7 +710,7 @@ INPUT
|
|
520
710
|
<EnumeratedRootUnit unit='meter' prefix='u'/>
|
521
711
|
</RootUnits>
|
522
712
|
</Unit>
|
523
|
-
<Dimension xmlns='
|
713
|
+
<Dimension xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='NISTd1'>
|
524
714
|
<Length symbol='L' powerNumerator='1'/>
|
525
715
|
</Dimension>
|
526
716
|
</math>
|
@@ -529,7 +719,7 @@ INPUT
|
|
529
719
|
|
530
720
|
it "deals with units division" do
|
531
721
|
expect(xmlpp(Asciimath2UnitsML::Conv.new().Asciimath2UnitsML(<<~INPUT))).to be_equivalent_to xmlpp(<<~OUTPUT)
|
532
|
-
9 "unitsml(A*C^3)" + 13 "unitsml(A/C^-3)"
|
722
|
+
9 "unitsml(A*C^3)" + 13 "unitsml(A/C^-3)" + 2 "unitsml(J/kg*K)"
|
533
723
|
INPUT
|
534
724
|
<math xmlns='http://www.w3.org/1998/Math/MathML'>
|
535
725
|
<mn>9</mn>
|
@@ -546,7 +736,7 @@ INPUT
|
|
546
736
|
</mrow>
|
547
737
|
</msup>
|
548
738
|
</mrow>
|
549
|
-
<Unit xmlns='
|
739
|
+
<Unit xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='U_A.C3' dimensionURL='#D_M3I4'>
|
550
740
|
<UnitSystem name='SI' type='SI_derived' xml:lang='en-US'/>
|
551
741
|
<UnitName xml:lang='en'>A*C^3</UnitName>
|
552
742
|
<UnitSymbol type='HTML'>
|
@@ -574,7 +764,7 @@ INPUT
|
|
574
764
|
<EnumeratedRootUnit unit='coulomb' powerNumerator='3'/>
|
575
765
|
</RootUnits>
|
576
766
|
</Unit>
|
577
|
-
<Dimension xmlns='
|
767
|
+
<Dimension xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='D_M3I4'>
|
578
768
|
<Mass symbol='M' powerNumerator='3'/>
|
579
769
|
<ElectricCurrent symbol='I' powerNumerator='4'/>
|
580
770
|
</Dimension>
|
@@ -594,6 +784,76 @@ INPUT
|
|
594
784
|
</mrow>
|
595
785
|
</msup>
|
596
786
|
</mrow>
|
787
|
+
<mo>+</mo>
|
788
|
+
<mn>2</mn>
|
789
|
+
<mo rspace='thickmathspace'>⁢</mo>
|
790
|
+
<mrow xref='U_J/kg.K'>
|
791
|
+
<mi mathvariant='normal'>J</mi>
|
792
|
+
<mo>/</mo>
|
793
|
+
<mi mathvariant='normal'>kg</mi>
|
794
|
+
<mo>·</mo>
|
795
|
+
<mi mathvariant='normal'>K</mi>
|
796
|
+
</mrow>
|
797
|
+
<Unit xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='U_NISTu13.u27p10_3e-1/1.u5e-1/1' dimensionURL='#D_L2M0T-2Theta-1'>
|
798
|
+
<UnitSystem name='SI' type='SI_derived' xml:lang='en-US'/>
|
799
|
+
<UnitName xml:lang='en'>joule per kilogram kelvin</UnitName>
|
800
|
+
<UnitSymbol type='HTML'>
|
801
|
+
J·kg
|
802
|
+
<sup>−1</sup>
|
803
|
+
·K
|
804
|
+
<sup>−1</sup>
|
805
|
+
</UnitSymbol>
|
806
|
+
<UnitSymbol type='MathML'>
|
807
|
+
<math xmlns='http://www.w3.org/1998/Math/MathML'>
|
808
|
+
<mrow>
|
809
|
+
<mi mathvariant='normal'>J</mi>
|
810
|
+
<mo>·</mo>
|
811
|
+
<msup>
|
812
|
+
<mrow>
|
813
|
+
<mi mathvariant='normal'>kg</mi>
|
814
|
+
</mrow>
|
815
|
+
<mrow>
|
816
|
+
<mo>−</mo>
|
817
|
+
<mn>1</mn>
|
818
|
+
</mrow>
|
819
|
+
</msup>
|
820
|
+
<mo>·</mo>
|
821
|
+
<msup>
|
822
|
+
<mrow>
|
823
|
+
<mi mathvariant='normal'>K</mi>
|
824
|
+
</mrow>
|
825
|
+
<mrow>
|
826
|
+
<mo>−</mo>
|
827
|
+
<mn>1</mn>
|
828
|
+
</mrow>
|
829
|
+
</msup>
|
830
|
+
</mrow>
|
831
|
+
</math>
|
832
|
+
</UnitSymbol>
|
833
|
+
<RootUnits>
|
834
|
+
<EnumeratedRootUnit unit='joule'/>
|
835
|
+
<EnumeratedRootUnit unit='gram' prefix='k' powerNumerator='-1'/>
|
836
|
+
<EnumeratedRootUnit unit='kelvin' powerNumerator='-1'/>
|
837
|
+
</RootUnits>
|
838
|
+
</Unit>
|
839
|
+
<Prefix xmlns='https://schema.unitsml.org/unitsml/1.0' prefixBase='10' prefixPower='3' xml:id='NISTp10_3'>
|
840
|
+
<PrefixName xml:lang='en'>kilo</PrefixName>
|
841
|
+
<PrefixSymbol type='ASCII'>k</PrefixSymbol>
|
842
|
+
<PrefixSymbol type='unicode'>k</PrefixSymbol>
|
843
|
+
<PrefixSymbol type='LaTeX'>k</PrefixSymbol>
|
844
|
+
<PrefixSymbol type='HTML'>k</PrefixSymbol>
|
845
|
+
</Prefix>
|
846
|
+
<Dimension xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='NISTd40'>
|
847
|
+
<Length symbol='L' powerNumerator='2'/>
|
848
|
+
<Time symbol='T' powerNumerator='-2'/>
|
849
|
+
<ThermodynamicTemperature symbol='Theta' powerNumerator='-1'/>
|
850
|
+
</Dimension>
|
851
|
+
<Dimension xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='D_L2M0T-2Theta-1'>
|
852
|
+
<Length symbol='L' powerNumerator='2'/>
|
853
|
+
<Mass symbol='M' powerNumerator='0'/>
|
854
|
+
<Time symbol='T' powerNumerator='-2'/>
|
855
|
+
<ThermodynamicTemperature symbol='Theta' powerNumerator='-1'/>
|
856
|
+
</Dimension>
|
597
857
|
</math>
|
598
858
|
OUTPUT
|
599
859
|
end
|
@@ -628,7 +888,7 @@ OUTPUT
|
|
628
888
|
</mrow>
|
629
889
|
</msup>
|
630
890
|
</mrow>
|
631
|
-
<Unit xmlns='
|
891
|
+
<Unit xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='U_kg-2' dimensionURL='#D_M-2'>
|
632
892
|
<UnitSystem name='SI' type='SI_base' xml:lang='en-US'/>
|
633
893
|
<UnitName xml:lang='en'>kg^-2</UnitName>
|
634
894
|
<UnitSymbol type='HTML'>
|
@@ -654,14 +914,14 @@ OUTPUT
|
|
654
914
|
<EnumeratedRootUnit unit='gram' prefix='k' powerNumerator='-2'/>
|
655
915
|
</RootUnits>
|
656
916
|
</Unit>
|
657
|
-
<Prefix xmlns='
|
917
|
+
<Prefix xmlns='https://schema.unitsml.org/unitsml/1.0' prefixBase='10' prefixPower='3' xml:id='NISTp10_3'>
|
658
918
|
<PrefixName xml:lang='en'>kilo</PrefixName>
|
659
919
|
<PrefixSymbol type='ASCII'>k</PrefixSymbol>
|
660
920
|
<PrefixSymbol type='unicode'>k</PrefixSymbol>
|
661
921
|
<PrefixSymbol type='LaTeX'>k</PrefixSymbol>
|
662
922
|
<PrefixSymbol type='HTML'>k</PrefixSymbol>
|
663
923
|
</Prefix>
|
664
|
-
<Dimension xmlns='
|
924
|
+
<Dimension xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='D_M-2'>
|
665
925
|
<Mass symbol='M' powerNumerator='-2'/>
|
666
926
|
</Dimension>
|
667
927
|
</math>
|
@@ -696,7 +956,7 @@ OUTPUT
|
|
696
956
|
</mrow>
|
697
957
|
</msup>
|
698
958
|
</mrow>
|
699
|
-
<Unit xmlns='
|
959
|
+
<Unit xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='U_kg.s-2' dimensionURL='#NISTd37'>
|
700
960
|
<UnitSystem name='SI' type='SI_derived' xml:lang='en-US'/>
|
701
961
|
<UnitName xml:lang='en'>kg*s^-2</UnitName>
|
702
962
|
<UnitSymbol type='HTML'>
|
@@ -725,14 +985,14 @@ OUTPUT
|
|
725
985
|
<EnumeratedRootUnit unit='second' powerNumerator='-2'/>
|
726
986
|
</RootUnits>
|
727
987
|
</Unit>
|
728
|
-
<Prefix xmlns='
|
988
|
+
<Prefix xmlns='https://schema.unitsml.org/unitsml/1.0' prefixBase='10' prefixPower='3' xml:id='NISTp10_3'>
|
729
989
|
<PrefixName xml:lang='en'>kilo</PrefixName>
|
730
990
|
<PrefixSymbol type='ASCII'>k</PrefixSymbol>
|
731
991
|
<PrefixSymbol type='unicode'>k</PrefixSymbol>
|
732
992
|
<PrefixSymbol type='LaTeX'>k</PrefixSymbol>
|
733
993
|
<PrefixSymbol type='HTML'>k</PrefixSymbol>
|
734
994
|
</Prefix>
|
735
|
-
<Dimension xmlns='
|
995
|
+
<Dimension xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='NISTd37'>
|
736
996
|
<Mass symbol='M' powerNumerator='1'/>
|
737
997
|
<Time symbol='T' powerNumerator='-2'/>
|
738
998
|
</Dimension>
|
@@ -757,7 +1017,7 @@ OUTPUT
|
|
757
1017
|
</mrow>
|
758
1018
|
</msup>
|
759
1019
|
</mrow>
|
760
|
-
<Unit xmlns='
|
1020
|
+
<Unit xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='U_kg.s-2' dimensionURL='#NISTd37'>
|
761
1021
|
<UnitSystem name='SI' type='SI_derived' xml:lang='en-US'/>
|
762
1022
|
<UnitName xml:lang='en'>kg*s^-2</UnitName>
|
763
1023
|
<UnitSymbol type='HTML'>
|
@@ -786,14 +1046,14 @@ OUTPUT
|
|
786
1046
|
<EnumeratedRootUnit unit='second' powerNumerator='-2'/>
|
787
1047
|
</RootUnits>
|
788
1048
|
</Unit>
|
789
|
-
<Prefix xmlns='
|
1049
|
+
<Prefix xmlns='https://schema.unitsml.org/unitsml/1.0' prefixBase='10' prefixPower='3' xml:id='NISTp10_3'>
|
790
1050
|
<PrefixName xml:lang='en'>kilo</PrefixName>
|
791
1051
|
<PrefixSymbol type='ASCII'>k</PrefixSymbol>
|
792
1052
|
<PrefixSymbol type='unicode'>k</PrefixSymbol>
|
793
1053
|
<PrefixSymbol type='LaTeX'>k</PrefixSymbol>
|
794
1054
|
<PrefixSymbol type='HTML'>k</PrefixSymbol>
|
795
1055
|
</Prefix>
|
796
|
-
<Dimension xmlns='
|
1056
|
+
<Dimension xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='NISTd37'>
|
797
1057
|
<Mass symbol='M' powerNumerator='1'/>
|
798
1058
|
<Time symbol='T' powerNumerator='-2'/>
|
799
1059
|
</Dimension>
|
@@ -818,7 +1078,7 @@ OUTPUT
|
|
818
1078
|
</mrow>
|
819
1079
|
</msup>
|
820
1080
|
</mrow>
|
821
|
-
<Unit xmlns='
|
1081
|
+
<Unit xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='U_kg.s-2' dimensionURL='#NISTd37'>
|
822
1082
|
<UnitSystem name='SI' type='SI_derived' xml:lang='en-US'/>
|
823
1083
|
<UnitName xml:lang='en'>kg*s^-2</UnitName>
|
824
1084
|
<UnitSymbol type='HTML'>
|
@@ -847,14 +1107,14 @@ OUTPUT
|
|
847
1107
|
<EnumeratedRootUnit unit='second' powerNumerator='-2'/>
|
848
1108
|
</RootUnits>
|
849
1109
|
</Unit>
|
850
|
-
<Prefix xmlns='
|
1110
|
+
<Prefix xmlns='https://schema.unitsml.org/unitsml/1.0' prefixBase='10' prefixPower='3' xml:id='NISTp10_3'>
|
851
1111
|
<PrefixName xml:lang='en'>kilo</PrefixName>
|
852
1112
|
<PrefixSymbol type='ASCII'>k</PrefixSymbol>
|
853
1113
|
<PrefixSymbol type='unicode'>k</PrefixSymbol>
|
854
1114
|
<PrefixSymbol type='LaTeX'>k</PrefixSymbol>
|
855
1115
|
<PrefixSymbol type='HTML'>k</PrefixSymbol>
|
856
1116
|
</Prefix>
|
857
|
-
<Dimension xmlns='
|
1117
|
+
<Dimension xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='NISTd37'>
|
858
1118
|
<Mass symbol='M' powerNumerator='1'/>
|
859
1119
|
<Time symbol='T' powerNumerator='-2'/>
|
860
1120
|
</Dimension>
|
@@ -882,7 +1142,7 @@ INPUT
|
|
882
1142
|
</mrow>
|
883
1143
|
</msup>
|
884
1144
|
</mrow>
|
885
|
-
<Unit xmlns='
|
1145
|
+
<Unit xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='U_mW.cm-2'>
|
886
1146
|
<UnitSystem name='SI' type='SI_derived' xml:lang='en-US'/>
|
887
1147
|
<UnitName xml:lang='en'>mW*cm^-2</UnitName>
|
888
1148
|
<UnitSymbol type='HTML'>
|
@@ -911,14 +1171,14 @@ INPUT
|
|
911
1171
|
<EnumeratedRootUnit unit='meter' prefix='c' powerNumerator='-2'/>
|
912
1172
|
</RootUnits>
|
913
1173
|
</Unit>
|
914
|
-
<Prefix xmlns='
|
1174
|
+
<Prefix xmlns='https://schema.unitsml.org/unitsml/1.0' prefixBase='10' prefixPower='-3' xml:id='NISTp10_-3'>
|
915
1175
|
<PrefixName xml:lang='en'>milli</PrefixName>
|
916
1176
|
<PrefixSymbol type='ASCII'>m</PrefixSymbol>
|
917
1177
|
<PrefixSymbol type='unicode'>m</PrefixSymbol>
|
918
1178
|
<PrefixSymbol type='LaTeX'>m</PrefixSymbol>
|
919
1179
|
<PrefixSymbol type='HTML'>m</PrefixSymbol>
|
920
1180
|
</Prefix>
|
921
|
-
<Prefix xmlns='
|
1181
|
+
<Prefix xmlns='https://schema.unitsml.org/unitsml/1.0' prefixBase='10' prefixPower='-2' xml:id='NISTp10_-2'>
|
922
1182
|
<PrefixName xml:lang='en'>centi</PrefixName>
|
923
1183
|
<PrefixSymbol type='ASCII'>c</PrefixSymbol>
|
924
1184
|
<PrefixSymbol type='unicode'>c</PrefixSymbol>
|
@@ -939,7 +1199,7 @@ INPUT
|
|
939
1199
|
<mrow xref='U_NISTu1'>
|
940
1200
|
<mi mathvariant='normal'>m</mi>
|
941
1201
|
</mrow>
|
942
|
-
<Unit xmlns='
|
1202
|
+
<Unit xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='U_NISTu1' dimensionURL='#NISTd1'>
|
943
1203
|
<UnitSystem name='SI' type='SI_derived' xml:lang='en-US'/>
|
944
1204
|
<UnitName xml:lang='en'>meter</UnitName>
|
945
1205
|
<UnitSymbol type='HTML'>m</UnitSymbol>
|
@@ -951,10 +1211,10 @@ INPUT
|
|
951
1211
|
</math>
|
952
1212
|
</UnitSymbol>
|
953
1213
|
</Unit>
|
954
|
-
<Dimension xmlns='
|
1214
|
+
<Dimension xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='NISTd1'>
|
955
1215
|
<Length symbol='L' powerNumerator='1'/>
|
956
1216
|
</Dimension>
|
957
|
-
<Quantity xmlns='
|
1217
|
+
<Quantity xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='NISTq103' dimensionURL='#NISTd1' quantityType='base'>
|
958
1218
|
<QuantityName xml:lang='en-US'>position vector</QuantityName>
|
959
1219
|
</Quantity>
|
960
1220
|
</math>
|
@@ -987,7 +1247,7 @@ INPUT
|
|
987
1247
|
</mrow>
|
988
1248
|
</msup>
|
989
1249
|
</mrow>
|
990
|
-
<Unit xmlns='
|
1250
|
+
<Unit xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='U_cal_th.cm-2'>
|
991
1251
|
<UnitSystem name='not_SI' type='not_SI' xml:lang='en-US'/>
|
992
1252
|
<UnitSystem name='SI' type='SI_derived' xml:lang='en-US'/>
|
993
1253
|
<UnitName xml:lang='en'>langley</UnitName>
|
@@ -1026,7 +1286,7 @@ INPUT
|
|
1026
1286
|
<EnumeratedRootUnit unit='meter' prefix='c' powerNumerator='-2'/>
|
1027
1287
|
</RootUnits>
|
1028
1288
|
</Unit>
|
1029
|
-
<Prefix xmlns='
|
1289
|
+
<Prefix xmlns='https://schema.unitsml.org/unitsml/1.0' prefixBase='10' prefixPower='-2' xml:id='NISTp10_-2'>
|
1030
1290
|
<PrefixName xml:lang='en'>centi</PrefixName>
|
1031
1291
|
<PrefixSymbol type='ASCII'>c</PrefixSymbol>
|
1032
1292
|
<PrefixSymbol type='unicode'>c</PrefixSymbol>
|
@@ -1050,7 +1310,7 @@ INPUT
|
|
1050
1310
|
<mi mathvariant='normal'>a</mi>
|
1051
1311
|
</math>
|
1052
1312
|
</mrow>
|
1053
|
-
<Unit xmlns='
|
1313
|
+
<Unit xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='U_NISTu1' dimensionURL='#NISTd1'>
|
1054
1314
|
<UnitSystem name='SI' type='SI_derived' xml:lang='en-US'/>
|
1055
1315
|
<UnitName xml:lang='en'>meter</UnitName>
|
1056
1316
|
<UnitSymbol type='HTML'>m</UnitSymbol>
|
@@ -1062,7 +1322,7 @@ INPUT
|
|
1062
1322
|
</math>
|
1063
1323
|
</UnitSymbol>
|
1064
1324
|
</Unit>
|
1065
|
-
<Dimension xmlns='
|
1325
|
+
<Dimension xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='NISTd1'>
|
1066
1326
|
<Length symbol='L' powerNumerator='1'/>
|
1067
1327
|
</Dimension>
|
1068
1328
|
<mo>+</mo>
|
@@ -1084,7 +1344,7 @@ INPUT
|
|
1084
1344
|
<mn>2</mn>
|
1085
1345
|
</math>
|
1086
1346
|
</mrow>
|
1087
|
-
<Unit xmlns='
|
1347
|
+
<Unit xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='U_cm.s-2' dimensionURL='#NISTd28'>
|
1088
1348
|
<UnitSystem name='SI' type='SI_derived' xml:lang='en-US'/>
|
1089
1349
|
<UnitName xml:lang='en'>cm*s^-2</UnitName>
|
1090
1350
|
<UnitSymbol type='HTML'>
|
@@ -1113,14 +1373,14 @@ INPUT
|
|
1113
1373
|
<EnumeratedRootUnit unit='second' powerNumerator='-2'/>
|
1114
1374
|
</RootUnits>
|
1115
1375
|
</Unit>
|
1116
|
-
<Prefix xmlns='
|
1376
|
+
<Prefix xmlns='https://schema.unitsml.org/unitsml/1.0' prefixBase='10' prefixPower='-2' xml:id='NISTp10_-2'>
|
1117
1377
|
<PrefixName xml:lang='en'>centi</PrefixName>
|
1118
1378
|
<PrefixSymbol type='ASCII'>c</PrefixSymbol>
|
1119
1379
|
<PrefixSymbol type='unicode'>c</PrefixSymbol>
|
1120
1380
|
<PrefixSymbol type='LaTeX'>c</PrefixSymbol>
|
1121
1381
|
<PrefixSymbol type='HTML'>c</PrefixSymbol>
|
1122
1382
|
</Prefix>
|
1123
|
-
<Dimension xmlns='
|
1383
|
+
<Dimension xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='NISTd28'>
|
1124
1384
|
<Length symbol='L' powerNumerator='1'/>
|
1125
1385
|
<Time symbol='T' powerNumerator='-2'/>
|
1126
1386
|
</Dimension>
|
@@ -1128,5 +1388,68 @@ INPUT
|
|
1128
1388
|
OUTPUT
|
1129
1389
|
end
|
1130
1390
|
|
1391
|
+
it "deals with multiplier input" do
|
1392
|
+
expect(xmlpp(Asciimath2UnitsML::Conv.new().Asciimath2UnitsML(<<~INPUT))).to be_equivalent_to xmlpp(<<~OUTPUT)
|
1393
|
+
10 "unitsml(cm*s^-2, multiplier: xx)"
|
1394
|
+
INPUT
|
1395
|
+
<math xmlns='http://www.w3.org/1998/Math/MathML'>
|
1396
|
+
<mn>10</mn>
|
1397
|
+
<mo rspace='thickmathspace'>⁢</mo>
|
1398
|
+
<mrow xref='U_cm.s-2'>
|
1399
|
+
<mi mathvariant='normal'>cm</mi>
|
1400
|
+
<mo>xx</mo>
|
1401
|
+
<msup>
|
1402
|
+
<mrow>
|
1403
|
+
<mi mathvariant='normal'>s</mi>
|
1404
|
+
</mrow>
|
1405
|
+
<mrow>
|
1406
|
+
<mo>−</mo>
|
1407
|
+
<mn>2</mn>
|
1408
|
+
</mrow>
|
1409
|
+
</msup>
|
1410
|
+
</mrow>
|
1411
|
+
<Unit xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='U_cm.s-2' dimensionURL='#NISTd28'>
|
1412
|
+
<UnitSystem name='SI' type='SI_derived' xml:lang='en-US'/>
|
1413
|
+
<UnitName xml:lang='en'>cm*s^-2</UnitName>
|
1414
|
+
<UnitSymbol type='HTML'>
|
1415
|
+
cm·s
|
1416
|
+
<sup>−2</sup>
|
1417
|
+
</UnitSymbol>
|
1418
|
+
<UnitSymbol type='MathML'>
|
1419
|
+
<math xmlns='http://www.w3.org/1998/Math/MathML'>
|
1420
|
+
<mrow>
|
1421
|
+
<mi mathvariant='normal'>cm</mi>
|
1422
|
+
<mo>·</mo>
|
1423
|
+
<msup>
|
1424
|
+
<mrow>
|
1425
|
+
<mi mathvariant='normal'>s</mi>
|
1426
|
+
</mrow>
|
1427
|
+
<mrow>
|
1428
|
+
<mo>−</mo>
|
1429
|
+
<mn>2</mn>
|
1430
|
+
</mrow>
|
1431
|
+
</msup>
|
1432
|
+
</mrow>
|
1433
|
+
</math>
|
1434
|
+
</UnitSymbol>
|
1435
|
+
<RootUnits>
|
1436
|
+
<EnumeratedRootUnit unit='meter' prefix='c'/>
|
1437
|
+
<EnumeratedRootUnit unit='second' powerNumerator='-2'/>
|
1438
|
+
</RootUnits>
|
1439
|
+
</Unit>
|
1440
|
+
<Prefix xmlns='https://schema.unitsml.org/unitsml/1.0' prefixBase='10' prefixPower='-2' xml:id='NISTp10_-2'>
|
1441
|
+
<PrefixName xml:lang='en'>centi</PrefixName>
|
1442
|
+
<PrefixSymbol type='ASCII'>c</PrefixSymbol>
|
1443
|
+
<PrefixSymbol type='unicode'>c</PrefixSymbol>
|
1444
|
+
<PrefixSymbol type='LaTeX'>c</PrefixSymbol>
|
1445
|
+
<PrefixSymbol type='HTML'>c</PrefixSymbol>
|
1446
|
+
</Prefix>
|
1447
|
+
<Dimension xmlns='https://schema.unitsml.org/unitsml/1.0' xml:id='NISTd28'>
|
1448
|
+
<Length symbol='L' powerNumerator='1'/>
|
1449
|
+
<Time symbol='T' powerNumerator='-2'/>
|
1450
|
+
</Dimension>
|
1451
|
+
</math>
|
1452
|
+
OUTPUT
|
1453
|
+
end
|
1131
1454
|
|
1132
1455
|
end
|