asciimath2unitsml 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 939880ec148bae10c193dc7958d2866ff5788d7e98617158bfde25a736576b13
4
- data.tar.gz: dc8d0afdfc6c134341735b55bfed5ae68b50da906ea5765e8404135d58adf011
3
+ metadata.gz: 559a334bc2dbe285ed496346392630e62b5c301fc23e521ff57a6f2161a3a0ed
4
+ data.tar.gz: 981ab1de7d97ce54dd464d707217aab81bfb9be404686c52f3999ef3ec7f44af
5
5
  SHA512:
6
- metadata.gz: f2f5e07977df15d3354ce4e509c585de929caf592ccd9ccd6974d5830b932b0982bd1c7c3cc0483c028e64846032925907316406f0f95cb9c6dda49ecb1ef2b6
7
- data.tar.gz: e1f358839665b8b815772e32c30ecaea7581061962d7b87cb5e844aaddaed666ae1b95fb2885e7f8eff4bc0d656325660eeba5cf5a45414690614e987da7f31f
6
+ metadata.gz: fa493805c784f5f18bad7b16eecaf4e4bac7667e72088f5cf712017c8693703a0006122c827e42f8b4665ad5c3a75d8a86bf79ed361409db5555b77f0694f0c5
7
+ data.tar.gz: 8c0cf5a14e1cba4e915266c838fd2eb2f019009cab9b029f14241d89c2f9c0f78bcb53b7f03712324fccbc9f4914b8f9af461cdc65037c63ee919e7cba4b4a14
@@ -48,7 +48,7 @@ module Asciimath2UnitsML
48
48
  <PrefixSymbol type="ASCII">#{@prefixes[p].ascii}</PrefixSymbol>
49
49
  <PrefixSymbol type="unicode">#{@prefixes[p].unicode}</PrefixSymbol>
50
50
  <PrefixSymbol type="LaTeX">#{@prefixes[p].latex}</PrefixSymbol>
51
- <PrefixSymbol type="HTML">#{HTMLEntities.new.encode(@prefixes[p].html, :basic)}</PrefixSymbol>
51
+ <PrefixSymbol type="HTML">#{htmlent @prefixes[p].html}</PrefixSymbol>
52
52
  </Prefix>
53
53
  END
54
54
  end.join("\n")
@@ -63,6 +63,19 @@ module Asciimath2UnitsML
63
63
  END
64
64
  end
65
65
 
66
+ U2D = {
67
+ "m" => { dimension: "Length", order: 1, symbol: "L" },
68
+ "g" => { dimension: "Mass", order: 2, symbol: "M" },
69
+ "kg" => { dimension: "Mass", order: 2, symbol: "M" },
70
+ "s" => { dimension: "Time", order: 3, symbol: "T" },
71
+ "A" => { dimension: "ElectricCurrent", order: 4, symbol: "I" },
72
+ "K" => { dimension: "ThermodynamicTemperature", order: 5, symbol: "Theta" },
73
+ "degK" => { dimension: "ThermodynamicTemperature", order: 5, symbol: "Theta" },
74
+ "mol" => { dimension: "AmountOfSubstance", order: 6, symbol: "N" },
75
+ "cd" => { dimension: "LuminousIntensity", order: 7, symbol: "J" },
76
+ "deg" => { dimension: "PlaneAngle", order: 8, symbol: "Phi" },
77
+ }.freeze
78
+
66
79
  def units2dimensions(units)
67
80
  norm = decompose_units(units)
68
81
  return if norm.any? { |u| u[:unit] == "unknown" || u[:prefix] == "unknown" || u[:unit].nil? }
@@ -143,19 +143,6 @@ module Asciimath2UnitsML
143
143
  end
144
144
  end
145
145
 
146
- U2D = {
147
- "m" => { dimension: "Length", order: 1, symbol: "L" },
148
- "g" => { dimension: "Mass", order: 2, symbol: "M" },
149
- "kg" => { dimension: "Mass", order: 2, symbol: "M" },
150
- "s" => { dimension: "Time", order: 3, symbol: "T" },
151
- "A" => { dimension: "ElectricCurrent", order: 4, symbol: "I" },
152
- "K" => { dimension: "ThermodynamicTemperature", order: 5, symbol: "Theta" },
153
- "degK" => { dimension: "ThermodynamicTemperature", order: 5, symbol: "Theta" },
154
- "mol" => { dimension: "AmountOfSubstance", order: 6, symbol: "N" },
155
- "cd" => { dimension: "LuminousIntensity", order: 7, symbol: "J" },
156
- "deg" => { dimension: "PlaneAngle", order: 8, symbol: "Phi" },
157
- }.freeze
158
-
159
146
  def Asciimath2UnitsML(expression)
160
147
  xml = Nokogiri::XML(asciimath2mathml(expression))
161
148
  MathML2UnitsML(xml).to_xml
@@ -169,7 +156,7 @@ module Asciimath2UnitsML
169
156
  text = x.text.sub(%r{^unitsml\((.+)\)$}m, "\\1")
170
157
  units, origtext, normtext, quantity, name, symbol = parse(text)
171
158
  rendering = symbol ? embeddedmathml(asciimath2mathml(symbol)) : mathmlsymbol(units, false)
172
- delim = x&.previous_element&.name == "mn" ? delimspace(rendering) : ""
159
+ delim = x&.previous_element ? delimspace(rendering) : ""
173
160
  x.replace("#{delim}<mrow xref='#{unit_id(origtext)}'>#{rendering}</mrow>\n"\
174
161
  "#{unitsml(units, origtext, normtext, quantity, name)}")
175
162
  end
@@ -15,6 +15,11 @@ module Asciimath2UnitsML
15
15
  @symbols[unit][style] || unit
16
16
  end
17
17
 
18
+ def htmlent(x)
19
+ HTMLEntities.new.decode(x).split(/([<>&])/)
20
+ .map { |c| /[<>'"]/.match(c) ? c : HTMLEntities.new.encode(c, :hexadecimal) }.join
21
+ end
22
+
18
23
  def htmlsymbol(units, normalise)
19
24
  units.map do |u|
20
25
  if u[:multiplier] then u[:multiplier] == "*" ? @multiplier[:html] : u[:multiplier]
@@ -41,7 +46,7 @@ module Asciimath2UnitsML
41
46
  exp = units.map do |u|
42
47
  if u[:multiplier] then u[:multiplier] == "*" ? @multiplier[:mathml] : "<mo>#{u[:multiplier]}</mo>"
43
48
  elsif u[:unit].nil? && u[:prefix]
44
- %(<mi mathvariant='normal'>#{@prefixes[u[:prefix]].html}</mi>)
49
+ %(<mi mathvariant='normal'>#{htmlent(@prefixes[u[:prefix]].html)}</mi>)
45
50
  else
46
51
  mathmlsymbol1(u, normalise)
47
52
  end
@@ -51,9 +56,10 @@ module Asciimath2UnitsML
51
56
  def mathmlsymbol1(u, normalise)
52
57
  base = render(normalise ? @units[u[:unit]].symbolid : u[:unit], :mathml)
53
58
  if u[:prefix]
59
+ prefix = htmlent(@prefixes[u[:prefix]].html)
54
60
  base = base.match(/<mi mathvariant='normal'>/) ?
55
- base.sub(/<mi mathvariant='normal'>/, "<mi mathvariant='normal'>#{u[:prefix]}") :
56
- "<mrow><mi mathvariant='normal'>#{u[:prefix]}#{base}</mrow>"
61
+ base.sub(/<mi mathvariant='normal'>/, "<mi mathvariant='normal'>#{prefix}") :
62
+ "<mrow><mi mathvariant='normal'>#{prefix}#{base}</mrow>"
57
63
  end
58
64
  mathmlsymbol_exponent(u, base)
59
65
  end
@@ -7,7 +7,7 @@ module Asciimath2UnitsML
7
7
  def unit_id(text)
8
8
  text = text.gsub(/[()]/, "")
9
9
  /-$/.match(text) and return @prefixes[text.sub(/-$/, "")].id
10
- "U_" + (@units[text] ? @units[text].id : text.gsub(/\*/, ".").gsub(/\^/, ""))
10
+ "U_" + (@units[text] ? @units[text].id.gsub(/'/, "_") : text.gsub(/\*/, ".").gsub(/\^/, ""))
11
11
  end
12
12
 
13
13
  def unit(units, origtext, normtext, dims, name)
@@ -1,3 +1,3 @@
1
1
  module Asciimath2UnitsML
2
- VERSION = '0.2.1'.freeze
2
+ VERSION = '0.2.2'.freeze
3
3
  end
@@ -753,50 +753,50 @@ NISTd75:
753
753
  powerNumerator: 1
754
754
  symbol: I
755
755
 
756
- NISTd85:
757
- dimensionless: true
756
+ #NISTd85:
757
+ #dimensionless: true
758
758
 
759
- NISTd84:
760
- dimensionless: true
759
+ #NISTd84:
760
+ #dimensionless: true
761
761
 
762
- NISTd87:
763
- dimensionless: true
762
+ #NISTd87:
763
+ #dimensionless: true
764
764
 
765
- NISTd86:
766
- dimensionless: true
765
+ #NISTd86:
766
+ #dimensionless: true
767
767
 
768
- NISTd81:
769
- dimensionless: true
768
+ #NISTd81:
769
+ #dimensionless: true
770
770
 
771
771
  NISTd80:
772
- dimensionless: true
772
+ dimensionless: true
773
773
 
774
- NISTd83:
775
- dimensionless: true
774
+ #NISTd83:
775
+ #dimensionless: true
776
776
 
777
- NISTd82:
778
- dimensionless: true
777
+ #NISTd82:
778
+ #dimensionless: true
779
779
 
780
- NISTd95:
781
- dimensionless: true
780
+ #NISTd95:
781
+ #dimensionless: true
782
782
 
783
- NISTd94:
784
- dimensionless: true
783
+ #NISTd94:
784
+ #dimensionless: true
785
785
 
786
- NISTd89:
787
- dimensionless: true
786
+ #NISTd89:
787
+ #dimensionless: true
788
788
 
789
- NISTd88:
790
- dimensionless: true
789
+ #NISTd88:
790
+ #dimensionless: true
791
791
 
792
- NISTd91:
793
- dimensionless: true
792
+ #NISTd91:
793
+ #dimensionless: true
794
794
 
795
- NISTd90:
796
- dimensionless: true
795
+ #NISTd90:
796
+ #dimensionless: true
797
797
 
798
- NISTd92:
799
- dimensionless: true
798
+ #NISTd92:
799
+ #dimensionless: true
800
800
 
801
- NISTd93:
802
- dimensionless: true
801
+ #NISTd93:
802
+ #dimensionless: true
@@ -1153,13 +1153,13 @@ NISTq88:
1153
1153
  url: "#NISTu14.u10e-1/1"
1154
1154
 
1155
1155
  NISTq111:
1156
- dimension_url: "#NISTd82"
1156
+ dimension_url: "#NISTd80"
1157
1157
  quantity_type: derived
1158
1158
  quantity_name:
1159
1159
  - rotation
1160
1160
  unit_reference:
1161
1161
  - name: one
1162
- url: "#NISTu181"
1162
+ url: "#NISTu61"
1163
1163
 
1164
1164
  NISTq112:
1165
1165
  dimension_url: "#NISTd24"
@@ -1234,13 +1234,13 @@ NISTq118:
1234
1234
  url: "#NISTu154"
1235
1235
 
1236
1236
  NISTq121:
1237
- dimension_url: "#NISTd85"
1237
+ dimension_url: "#NISTd80"
1238
1238
  quantity_type: derived
1239
1239
  quantity_name:
1240
1240
  - logarithmic decrement
1241
1241
  unit_reference:
1242
1242
  - name: one
1243
- url: "#NISTu132"
1243
+ url: "#NISTu61"
1244
1244
  - name: neper
1245
1245
  url: "#NISTu153"
1246
1246
 
@@ -1385,14 +1385,14 @@ NISTq124:
1385
1385
  url: "#NISTu1e-1/1"
1386
1386
 
1387
1387
  NISTq125:
1388
- dimension_url: "#NISTd86"
1388
+ dimension_url: "#NISTd80"
1389
1389
  quantity_type: derived
1390
1390
  quantity_name:
1391
1391
  - relative mass density
1392
1392
  - relative density
1393
1393
  unit_reference:
1394
1394
  - name: one
1395
- url: "#NISTu368"
1395
+ url: "#NISTu61"
1396
1396
 
1397
1397
  NISTq122:
1398
1398
  dimension_url: "#NISTd29"
@@ -1546,22 +1546,22 @@ NISTq71:
1546
1546
  url: "#NISTu293"
1547
1547
 
1548
1548
  NISTq137:
1549
- dimension_url: "#NISTd88"
1549
+ dimension_url: "#NISTd80"
1550
1550
  quantity_type: derived
1551
1551
  quantity_name:
1552
1552
  - shear strain
1553
1553
  unit_reference:
1554
1554
  - name: one
1555
- url: "#NISTu370"
1555
+ url: "#NISTu61"
1556
1556
 
1557
1557
  NISTq138:
1558
- dimension_url: "#NISTd89"
1558
+ dimension_url: "#NISTd80"
1559
1559
  quantity_type: derived
1560
1560
  quantity_name:
1561
1561
  - volume strain
1562
1562
  unit_reference:
1563
1563
  - name: one
1564
- url: "#NISTu371"
1564
+ url: "#NISTu61"
1565
1565
 
1566
1566
  NISTq139:
1567
1567
  dimension_url: "#NISTd63"
@@ -1637,13 +1637,13 @@ NISTq135:
1637
1637
  url: "#NISTu12"
1638
1638
 
1639
1639
  NISTq136:
1640
- dimension_url: "#NISTd87"
1640
+ dimension_url: "#NISTd80"
1641
1641
  quantity_type: derived
1642
1642
  quantity_name:
1643
1643
  - linear strain
1644
1644
  unit_reference:
1645
1645
  - name: one
1646
- url: "#NISTu369"
1646
+ url: "#NISTu61"
1647
1647
 
1648
1648
  NISTq21:
1649
1649
  dimension_url: "#NISTd16"
@@ -1672,13 +1672,13 @@ NISTq141:
1672
1672
  url: "#NISTu12"
1673
1673
 
1674
1674
  NISTq140:
1675
- dimension_url: "#NISTd90"
1675
+ dimension_url: "#NISTd80"
1676
1676
  quantity_type: derived
1677
1677
  quantity_name:
1678
1678
  - Poisson number
1679
1679
  unit_reference:
1680
1680
  - name: one
1681
- url: "#NISTu372"
1681
+ url: "#NISTu61"
1682
1682
 
1683
1683
  NISTq22:
1684
1684
  dimension_url: "#NISTd17"
@@ -1840,13 +1840,13 @@ NISTq146:
1840
1840
  url: "#NISTu209"
1841
1841
 
1842
1842
  NISTq147:
1843
- dimension_url: "#NISTd91"
1843
+ dimension_url: "#NISTd80"
1844
1844
  quantity_type: derived
1845
1845
  quantity_name:
1846
1846
  - dynamic friction factor
1847
1847
  unit_reference:
1848
1848
  - name: one
1849
- url: "#NISTu373"
1849
+ url: "#NISTu61"
1850
1850
 
1851
1851
  NISTq144:
1852
1852
  dimension_url: "#NISTd57"
@@ -2387,13 +2387,13 @@ NISTq95:
2387
2387
  url: "#NISTu1"
2388
2388
 
2389
2389
  NISTq94:
2390
- dimension_url: "#NISTd81"
2390
+ dimension_url: "#NISTd80"
2391
2391
  quantity_type: derived
2392
2392
  quantity_name:
2393
2393
  - relative permeability
2394
2394
  unit_reference:
2395
2395
  - name: one
2396
- url: "#NISTu174"
2396
+ url: "#NISTu61"
2397
2397
 
2398
2398
  NISTq97:
2399
2399
  dimension_url: "#NISTd1"
@@ -2413,7 +2413,6 @@ NISTq96:
2413
2413
  - name: meter
2414
2414
  url: "#NISTu1"
2415
2415
 
2416
-
2417
2416
  NISTq40:
2418
2417
  dimension_url: "#NISTd25"
2419
2418
  quantity_type: derived
@@ -2457,4 +2456,12 @@ NISTq1001:
2457
2456
  - name: var
2458
2457
  url: "#NISTu401"
2459
2458
 
2459
+ NISTq1002:
2460
+ dimension_url: "#NISTd80"
2461
+ quantity_type: derived
2462
+ quantity_name:
2463
+ - nil
2464
+ unit_reference:
2465
+ - name: one
2466
+ url: "#NISTu61"
2460
2467
 
@@ -1817,26 +1817,6 @@
1817
1817
  - name: "potential energy"
1818
1818
  url: "#NISTq77"
1819
1819
 
1820
- "NISTu132":
1821
- dimension_url: "#NISTd85"
1822
- short:
1823
- root: false
1824
- unit_system:
1825
- type: "SI_derived_non-special"
1826
- name: "SI"
1827
- unit_name:
1828
- - "one"
1829
- unit_symbols:
1830
- - id: "1"
1831
- ascii: "1"
1832
- html: "1"
1833
- mathml: "<mi mathvariant='normal'>1</mi>"
1834
- latex: \ensuremath{\mathrm{1}}
1835
- unicode: "1"
1836
- quantity_reference:
1837
- - name: "logarithmic decrement"
1838
- url: "#NISTq121"
1839
-
1840
1820
  "NISTu63":
1841
1821
  dimension_url: "#NISTd15"
1842
1822
  short: table_kg_calorie
@@ -3521,6 +3501,26 @@
3521
3501
  quantity_reference:
3522
3502
  - name: "refractive index"
3523
3503
  url: "#NISTq93"
3504
+ - name: "rotation"
3505
+ url: "#NISTq111"
3506
+ - name: "relative permeability"
3507
+ url: "#NISTq94"
3508
+ - name: "relative mass density"
3509
+ url: "#NISTq125"
3510
+ - name: "linear strain"
3511
+ url: "#NISTq136"
3512
+ - name: "shear strain"
3513
+ url: "#NISTq137"
3514
+ - name: "volume strain"
3515
+ url: "#NISTq138"
3516
+ - name: "Poisson number"
3517
+ url: "#NISTq140"
3518
+ - name: "dynamic friction factor"
3519
+ url: "#NISTq147"
3520
+ - name: "logarithmic decrement"
3521
+ url: "#NISTq121"
3522
+ - name: "nil"
3523
+ url: "#NISTq1002"
3524
3524
 
3525
3525
  "NISTu166":
3526
3526
  dimension_url: "#NISTd15"
@@ -5053,26 +5053,6 @@
5053
5053
  - name: "volume"
5054
5054
  url: "#NISTq10"
5055
5055
 
5056
- "NISTu181":
5057
- dimension_url: "#NISTd82"
5058
- short:
5059
- root: false
5060
- unit_system:
5061
- type: "SI_derived_non-special"
5062
- name: "SI"
5063
- unit_name:
5064
- - "one"
5065
- unit_symbols:
5066
- - id: "1"
5067
- ascii: "1"
5068
- html: "1"
5069
- mathml: "<mi mathvariant='normal'>1</mi>"
5070
- latex: \ensuremath{\mathrm{1}}
5071
- unicode: "1"
5072
- quantity_reference:
5073
- - name: "rotation"
5074
- url: "#NISTq111"
5075
-
5076
5056
  "NISTu175":
5077
5057
  dimension_url: "#NISTd10"
5078
5058
  short: us_gallon
@@ -5230,26 +5210,6 @@
5230
5210
  - name: "volume"
5231
5211
  url: "#NISTq10"
5232
5212
 
5233
- "NISTu174":
5234
- dimension_url: "#NISTd81"
5235
- short:
5236
- root: false
5237
- unit_system:
5238
- type: "SI_derived_non-special"
5239
- name: "SI"
5240
- unit_name:
5241
- - "one"
5242
- unit_symbols:
5243
- - id: "1"
5244
- ascii: "1"
5245
- html: "1"
5246
- mathml: "<mi mathvariant='normal'>1</mi>"
5247
- latex: \ensuremath{\mathrm{1}}
5248
- unicode: "1"
5249
- quantity_reference:
5250
- - name: "relative permeability"
5251
- url: "#NISTq94"
5252
-
5253
5213
  "NISTu182":
5254
5214
  dimension_url: "#NISTd1"
5255
5215
  short: light_year
@@ -10378,160 +10338,6 @@
10378
10338
  - name: "molality of solute B"
10379
10339
  url: "#NISTq179"
10380
10340
 
10381
- "NISTu368":
10382
- dimension_url: "#NISTd86"
10383
- short:
10384
- root: false
10385
- unit_system:
10386
- type: "SI_derived_non-special"
10387
- name: "SI"
10388
- unit_name:
10389
- - "one"
10390
- unit_symbols:
10391
- - id: "1"
10392
- ascii: "1"
10393
- html: "1"
10394
- mathml: "<mi mathvariant='normal'>1</mi>"
10395
- latex: \ensuremath{\mathrm{1}}
10396
- unicode: "1"
10397
- quantity_reference:
10398
- - name: "relative mass density"
10399
- url: "#NISTq125"
10400
-
10401
- "NISTu369":
10402
- dimension_url: "#NISTd87"
10403
- short:
10404
- root: false
10405
- unit_system:
10406
- type: "SI_derived_non-special"
10407
- name: "SI"
10408
- unit_name:
10409
- - "one"
10410
- unit_symbols:
10411
- - id: "1"
10412
- ascii: "1"
10413
- html: "1"
10414
- mathml: "<mi mathvariant='normal'>1</mi>"
10415
- latex: \ensuremath{\mathrm{1}}
10416
- unicode: "1"
10417
- quantity_reference:
10418
- - name: "linear strain"
10419
- url: "#NISTq136"
10420
-
10421
- "NISTu370":
10422
- dimension_url: "#NISTd88"
10423
- short:
10424
- root: false
10425
- unit_system:
10426
- type: "SI_derived_non-special"
10427
- name: "SI"
10428
- unit_name:
10429
- - "one"
10430
- unit_symbols:
10431
- - id: "1"
10432
- ascii: "1"
10433
- html: "1"
10434
- mathml: "<mi mathvariant='normal'>1</mi>"
10435
- latex: \ensuremath{\mathrm{1}}
10436
- unicode: "1"
10437
- quantity_reference:
10438
- - name: "shear strain"
10439
- url: "#NISTq137"
10440
-
10441
- "NISTu371":
10442
- dimension_url: "#NISTd89"
10443
- short:
10444
- root: false
10445
- unit_system:
10446
- type: "SI_derived_non-special"
10447
- name: "SI"
10448
- unit_name:
10449
- - "one"
10450
- unit_symbols:
10451
- - id: "1"
10452
- ascii: "1"
10453
- html: "1"
10454
- mathml: "<mi mathvariant='normal'>1</mi>"
10455
- latex: \ensuremath{\mathrm{1}}
10456
- unicode: "1"
10457
- quantity_reference:
10458
- - name: "volume strain"
10459
- url: "#NISTq138"
10460
-
10461
- "NISTu372":
10462
- dimension_url: "#NISTd90"
10463
- short:
10464
- root: false
10465
- unit_system:
10466
- type: "SI_derived_non-special"
10467
- name: "SI"
10468
- unit_name:
10469
- - "one"
10470
- unit_symbols:
10471
- - id: "1"
10472
- ascii: "1"
10473
- html: "1"
10474
- mathml: "<mi mathvariant='normal'>1</mi>"
10475
- latex: \ensuremath{\mathrm{1}}
10476
- unicode: "1"
10477
- quantity_reference:
10478
- - name: "Poisson number"
10479
- url: "#NISTq140"
10480
-
10481
- "NISTu373":
10482
- dimension_url: "#NISTd91"
10483
- short:
10484
- root: false
10485
- unit_system:
10486
- type: "SI_derived_non-special"
10487
- name: "SI"
10488
- unit_name:
10489
- - "one"
10490
- unit_symbols:
10491
- - id: "1"
10492
- ascii: "1"
10493
- html: "1"
10494
- mathml: "<mi mathvariant='normal'>1</mi>"
10495
- latex: \ensuremath{\mathrm{1}}
10496
- unicode: "1"
10497
- quantity_reference:
10498
- - name: "dynamic friction factor"
10499
- url: "#NISTq147"
10500
-
10501
- "NISTu374":
10502
- dimension_url: "#NISTd92"
10503
- short:
10504
- root: false
10505
- unit_system:
10506
- type: "SI_derived_non-special"
10507
- name: "SI"
10508
- unit_name:
10509
- - "one"
10510
- unit_symbols:
10511
- - id: "1"
10512
- ascii: "1"
10513
- html: "1"
10514
- mathml: "<mi mathvariant='normal'>1</mi>"
10515
- latex: \ensuremath{\mathrm{1}}
10516
- unicode: "1"
10517
-
10518
- "NISTu375":
10519
- dimension_url: "#NISTd93"
10520
- short:
10521
- root: false
10522
- unit_system:
10523
- type: "SI_derived_non-special"
10524
- name: "SI"
10525
- unit_name:
10526
- - "one"
10527
- unit_symbols:
10528
- - id: "1"
10529
- ascii: "1"
10530
- html: "1"
10531
- mathml: "<mi mathvariant='normal'>1</mi>"
10532
- latex: \ensuremath{\mathrm{1}}
10533
- unicode: "1"
10534
-
10535
10341
  "NISTu376":
10536
10342
  dimension_url: "#NISTd1"
10537
10343
  short: light_week
data/spec/conv_spec.rb CHANGED
@@ -75,7 +75,7 @@ RSpec.describe Asciimath2UnitsML do
75
75
  <mn>1</mn>
76
76
  <mo rspace='thickmathspace'>&#x2062;</mo>
77
77
  <mrow xref='U_um'>
78
- <mi mathvariant='normal'>um</mi>
78
+ <mi mathvariant='normal'>&#xB5;m</mi>
79
79
  </mrow>
80
80
  <Unit xmlns='http://unitsml.nist.gov/2005' xml:id='U_um' dimensionURL='#NISTd1'>
81
81
  <UnitSystem name='SI' type='SI_derived' xml:lang='en-US'/>
@@ -84,7 +84,7 @@ RSpec.describe Asciimath2UnitsML do
84
84
  <UnitSymbol type='MathML'>
85
85
  <math xmlns='http://www.w3.org/1998/Math/MathML'>
86
86
  <mrow>
87
- <mi mathvariant='normal'>um</mi>
87
+ <mi mathvariant='normal'>&#xB5;m</mi>
88
88
  </mrow>
89
89
  </math>
90
90
  </UnitSymbol>
@@ -97,7 +97,7 @@ RSpec.describe Asciimath2UnitsML do
97
97
  <PrefixSymbol type='ASCII'>u</PrefixSymbol>
98
98
  <PrefixSymbol type='unicode'>&#x3BC;</PrefixSymbol>
99
99
  <PrefixSymbol type='LaTeX'>$mu$</PrefixSymbol>
100
- <PrefixSymbol type='HTML'>&amp;micro;</PrefixSymbol>
100
+ <PrefixSymbol type='HTML'>&#xB5;</PrefixSymbol>
101
101
  </Prefix>
102
102
  <Dimension xmlns='http://unitsml.nist.gov/2005' xml:id='NISTd1'>
103
103
  <Length symbol='L' powerNumerator='1'/>
@@ -464,6 +464,7 @@ OUTPUT
464
464
  <PrefixSymbol type='LaTeX'>p</PrefixSymbol>
465
465
  <PrefixSymbol type='HTML'>p</PrefixSymbol>
466
466
  </Prefix>
467
+ <mo rspace='thickmathspace'>&#x2062;</mo>
467
468
  <mrow xref='NISTp10_1'>
468
469
  <mi mathvariant='normal'>da</mi>
469
470
  </mrow>
@@ -478,6 +479,54 @@ OUTPUT
478
479
  OUTPUT
479
480
  end
480
481
 
482
+ it "deals with HTML entities in UnitsDB" do
483
+ expect(xmlpp(Asciimath2UnitsML::Conv.new().Asciimath2UnitsML(<<~INPUT))).to be_equivalent_to xmlpp(<<~OUTPUT)
484
+ "unitsml(u-)" + "unitsml(um)"
485
+ INPUT
486
+ <math xmlns='http://www.w3.org/1998/Math/MathML'>
487
+ <mrow xref='NISTp10_-6'>
488
+ <mi mathvariant='normal'>&#xB5;</mi>
489
+ </mrow>
490
+ <Prefix xmlns='http://unitsml.nist.gov/2005' prefixBase='10' prefixPower='-6' xml:id='NISTp10_-6'>
491
+ <PrefixName xml:lang='en'>micro</PrefixName>
492
+ <PrefixSymbol type='ASCII'>u</PrefixSymbol>
493
+ <PrefixSymbol type='unicode'>&#x3BC;</PrefixSymbol>
494
+ <PrefixSymbol type='LaTeX'>$mu$</PrefixSymbol>
495
+ <PrefixSymbol type='HTML'>&#xB5;</PrefixSymbol>
496
+ </Prefix>
497
+ <Dimension xmlns='http://unitsml.nist.gov/2005' xml:id='NISTd2'>
498
+ <Mass symbol='M' powerNumerator='1'/>
499
+ </Dimension>
500
+ <Quantity xmlns='http://unitsml.nist.gov/2005' xml:id='NISTq2' dimensionURL='#NISTd2' quantityType='base'>
501
+ <QuantityName xml:lang='en-US'>mass</QuantityName>
502
+ </Quantity>
503
+ <mo>+</mo>
504
+ <mo rspace='thickmathspace'>&#x2062;</mo>
505
+ <mrow xref='U_um'>
506
+ <mi mathvariant='normal'>&#xB5;m</mi>
507
+ </mrow>
508
+ <Unit xmlns='http://unitsml.nist.gov/2005' xml:id='U_um' dimensionURL='#NISTd1'>
509
+ <UnitSystem name='SI' type='SI_derived' xml:lang='en-US'/>
510
+ <UnitName xml:lang='en'>um</UnitName>
511
+ <UnitSymbol type='HTML'>um</UnitSymbol>
512
+ <UnitSymbol type='MathML'>
513
+ <math xmlns='http://www.w3.org/1998/Math/MathML'>
514
+ <mrow>
515
+ <mi mathvariant='normal'>&#xB5;m</mi>
516
+ </mrow>
517
+ </math>
518
+ </UnitSymbol>
519
+ <RootUnits>
520
+ <EnumeratedRootUnit unit='meter' prefix='u'/>
521
+ </RootUnits>
522
+ </Unit>
523
+ <Dimension xmlns='http://unitsml.nist.gov/2005' xml:id='NISTd1'>
524
+ <Length symbol='L' powerNumerator='1'/>
525
+ </Dimension>
526
+ </math>
527
+ OUTPUT
528
+ end
529
+
481
530
  it "deals with units division" do
482
531
  expect(xmlpp(Asciimath2UnitsML::Conv.new().Asciimath2UnitsML(<<~INPUT))).to be_equivalent_to xmlpp(<<~OUTPUT)
483
532
  9 "unitsml(A*C^3)" + 13 "unitsml(A/C^-3)"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: asciimath2unitsml
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-03-11 00:00:00.000000000 Z
11
+ date: 2021-03-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: asciimath