asciimath2unitsml 0.3.2 → 0.3.3

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: f51b82e234fddaf66252f77a276a3acf68dae4356502a3c900253f5d4d4dffcf
4
- data.tar.gz: 59dd18f009952329c1c07af2132ec06123c06dd3caea4ee7f22f17c0f4ec1cbc
3
+ metadata.gz: 829d573c90a88f5d26b2310d69f5ea575084df208cd3f441342435b0a6a3d353
4
+ data.tar.gz: 534c2ea7485b1de1c126de112a1ad8c9b10683797034e99313fda199c5f7e572
5
5
  SHA512:
6
- metadata.gz: 9a925e3db85d3086d676c07c101609e87674d620394f5fa0a536ab3652f3aa9c0cc6a74507d79264e0154bf51ea4121d47b7275a94212bc934b822b0392a9970
7
- data.tar.gz: 59d98ebd629a20e8f03dc32a1870474e5808b9d38f51a87feec5eae9f0746535bed9dcf38b1faf3939319bb3989b1d926088e8d834388e48f045070e3749312a
6
+ metadata.gz: c6eec2cb24fff7931d236a9a14a6d4ae1a938fe348d1e1d02a4d2f9be8e7f72e124e633ef0ef4b0f1e476ee8a2dee900210e60010600e0b082eb95237d2c70d2
7
+ data.tar.gz: e6943596be90a3bd1e6336b7bfa395cee4aa41e88ab6e5b2d003216a2271fc72249a018218d65c4ef446f4d246412e2b9fa0ac0d9721095abd4d9baa95515389
@@ -16,21 +16,11 @@ jobs:
16
16
  strategy:
17
17
  fail-fast: false
18
18
  matrix:
19
- ruby: [ '2.7', '2.6', '2.5', '2.4' ]
19
+ ruby: [ '3.0', '2.7', '2.6', '2.5', '2.4' ]
20
20
  os: [ ubuntu-latest, windows-latest, macos-latest ]
21
21
  experimental: [ false ]
22
- include:
23
- - ruby: '3.0'
24
- os: 'ubuntu-latest'
25
- experimental: true
26
- - ruby: '3.0'
27
- os: 'windows-latest'
28
- experimental: true
29
- - ruby: '3.0'
30
- os: 'macos-latest'
31
- experimental: true
32
22
  steps:
33
- - uses: actions/checkout@master
23
+ - uses: actions/checkout@v2
34
24
  with:
35
25
  submodules: true
36
26
 
@@ -40,14 +30,3 @@ jobs:
40
30
  bundler-cache: true
41
31
 
42
32
  - run: bundle exec rake
43
-
44
- tests-passed:
45
- needs: rake
46
- runs-on: ubuntu-latest
47
- steps:
48
- - uses: peter-evans/repository-dispatch@v1
49
- with:
50
- token: ${{ secrets.METANORMA_CI_PAT_TOKEN || secrets.GITHUB_TOKEN }}
51
- repository: ${{ github.repository }}
52
- event-type: notify
53
- client-payload: '{"ref": "${{ github.ref }}", "sha": "${{ github.sha }}"}'
data/.hound.yml ADDED
@@ -0,0 +1,5 @@
1
+ # Auto-generated by Cimas: Do not edit it manually!
2
+ # See https://github.com/metanorma/cimas
3
+ ruby:
4
+ enabled: true
5
+ config_file: .rubocop.yml
data/.rubocop.yml CHANGED
@@ -1,14 +1,10 @@
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.
1
+ # Auto-generated by Cimas: Do not edit it manually!
2
+ # See https://github.com/metanorma/cimas
4
3
  inherit_from:
5
4
  - https://raw.githubusercontent.com/riboseinc/oss-guides/master/ci/rubocop.yml
6
5
 
7
6
  # local repo-specific modifications
7
+ # ...
8
8
 
9
9
  AllCops:
10
- DisplayCopNames: false
11
- StyleGuideCopsOnly: false
12
10
  TargetRubyVersion: 2.4
13
- Rails:
14
- Enabled: true
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
1
  source "https://rubygems.org"
2
-
2
+
3
3
  # Specify your gem's dependencies in ruby-vobject.gemspec
4
4
  gemspec
data/Rakefile CHANGED
@@ -3,4 +3,4 @@ require "rspec/core/rake_task"
3
3
 
4
4
  RSpec::Core::RakeTask.new(:spec)
5
5
 
6
- task :default => :spec
6
+ task default: :spec
@@ -1,6 +1,6 @@
1
1
  # coding: utf-8
2
2
 
3
- lib = File.expand_path("../lib", __FILE__)
3
+ lib = File.expand_path("lib", __dir__)
4
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
5
  require "asciimath2unitsml/version"
6
6
 
@@ -29,25 +29,23 @@ Gem::Specification.new do |spec|
29
29
  .split("\n")
30
30
  .map { |kv_str| kv_str.split(" ") }
31
31
  .each do |(_, submodule_path)|
32
+ # for each submodule, change working directory to that submodule
33
+ Dir.chdir(submodule_path) do
34
+ # issue git ls-files in submodule's directory
35
+ submodule_files = `git ls-files | grep -i '.yaml$'`.split($\)
32
36
 
33
- # for each submodule, change working directory to that submodule
34
- Dir.chdir(submodule_path) do
35
-
36
- # issue git ls-files in submodule's directory
37
- submodule_files = `git ls-files | grep -i '.yaml$'`.split($\)
38
-
39
- submodule_files_paths = submodule_files.map do |filename|
40
- File.join submodule_path, filename
41
- end
42
-
43
- # add relative paths to gem.files
44
- spec.files += submodule_files_paths
37
+ submodule_files_paths = submodule_files.map do |filename|
38
+ File.join submodule_path, filename
45
39
  end
40
+
41
+ # add relative paths to gem.files
42
+ spec.files += submodule_files_paths
43
+ end
46
44
  end
47
45
 
48
46
  spec.add_dependency "asciimath"
49
47
  spec.add_dependency "htmlentities"
50
- spec.add_dependency "nokogiri", "~> 1.10.4"
48
+ spec.add_dependency "nokogiri", "~> 1.11"
51
49
  spec.add_dependency "rsec", "~> 1.0.0"
52
50
 
53
51
  spec.add_development_dependency "bundler"
@@ -56,10 +54,9 @@ Gem::Specification.new do |spec|
56
54
  spec.add_development_dependency "guard", "~> 2.14"
57
55
  spec.add_development_dependency "guard-rspec", "~> 4.7"
58
56
  spec.add_development_dependency "rake", "~> 12.0"
57
+ spec.add_development_dependency "rexml"
59
58
  spec.add_development_dependency "rspec", "~> 3.6"
60
59
  spec.add_development_dependency "rubocop", "~> 1.5.2"
61
60
  spec.add_development_dependency "simplecov", "~> 0.15"
62
61
  spec.add_development_dependency "timecop", "~> 0.9"
63
- spec.add_development_dependency "rexml"
64
62
  end
65
-
data/bin/rspec CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
-
2
+
3
3
  # This file was generated by Bundler.
4
4
  #
5
5
  # The application 'rspec' is installed as part of a gem, and
@@ -15,4 +15,3 @@ require "rubygems"
15
15
  require "bundler/setup"
16
16
 
17
17
  load Gem.bin_path("rspec-core", "rspec")
18
-
@@ -1,4 +1,3 @@
1
1
  require_relative "asciimath2unitsml/version"
2
2
  require_relative "asciimath2unitsml/conv"
3
3
  require_relative "unitsdb_ruby/unitsdb"
4
-
@@ -46,7 +46,7 @@ module Asciimath2UnitsML
46
46
 
47
47
  def prefix(units)
48
48
  units.map { |u| u[:prefix] }.reject(&:nil?).uniq.map do |p|
49
- <<~END
49
+ <<~XML
50
50
  <Prefix xmlns='#{UNITSML_NS}' prefixBase='#{@prefixes[p].base}'
51
51
  prefixPower='#{@prefixes[p].power}' xml:id='#{@prefixes[p].id}'>
52
52
  <PrefixName xml:lang="en">#{@prefixes[p].name}</PrefixName>
@@ -55,18 +55,18 @@ module Asciimath2UnitsML
55
55
  <PrefixSymbol type="LaTeX">#{@prefixes[p].latex}</PrefixSymbol>
56
56
  <PrefixSymbol type="HTML">#{htmlent @prefixes[p].html}</PrefixSymbol>
57
57
  </Prefix>
58
- END
58
+ XML
59
59
  end.join("\n")
60
60
  end
61
61
 
62
62
  def dimension_components(dims)
63
63
  return if dims.nil? || dims.empty?
64
64
 
65
- <<~END
65
+ <<~XML
66
66
  <Dimension xmlns='#{UNITSML_NS}' xml:id="#{dim_id(dims)}">
67
67
  #{dims.map { |u| dimension1(u) }.join("\n")}
68
68
  </Dimension>
69
- END
69
+ XML
70
70
  end
71
71
 
72
72
  U2D = {
@@ -98,9 +98,9 @@ module Asciimath2UnitsML
98
98
  end.sort { |a, b| U2D[a[:unit]][:order] <=> U2D[b[:unit]][:order] }
99
99
  end
100
100
 
101
- def dimension1(u)
102
- %(<#{u[:dimension]} symbol="#{u[:symbol]}"
103
- powerNumerator="#{float_to_display(u[:exponent])}"/>)
101
+ def dimension1(dim)
102
+ %(<#{dim[:dimension]} symbol="#{dim[:symbol]}"
103
+ powerNumerator="#{float_to_display(dim[:exponent])}"/>)
104
104
  end
105
105
 
106
106
  def dim_id(dims)
@@ -188,11 +188,11 @@ module Asciimath2UnitsML
188
188
  id = quantity || @units[normtext].quantities.first
189
189
  @units[normtext]&.dimension and
190
190
  dim = %( dimensionURL="##{@units[normtext].dimension}")
191
- <<~END
191
+ <<~XML
192
192
  <Quantity xmlns='#{UNITSML_NS}' xml:id="#{id}"#{dim} quantityType="base">
193
193
  #{quantityname(id)}
194
194
  </Quantity>
195
- END
195
+ XML
196
196
  end
197
197
 
198
198
  def dimid2dimensions(normtext)
@@ -207,22 +207,22 @@ module Asciimath2UnitsML
207
207
  return unless @units[normtext]&.dimension
208
208
 
209
209
  dims = dimid2dimensions(@units[normtext]&.dimension)
210
- <<~END
210
+ <<~XML
211
211
  <Dimension xmlns='#{UNITSML_NS}' xml:id="#{@units[normtext]&.dimension}">
212
212
  #{dims.map { |u| dimension1(u) }.join("\n")}
213
213
  </Dimension>
214
- END
214
+ XML
215
215
  end
216
216
 
217
217
  def unitsml(units, origtext, normtext, quantity, name)
218
218
  dims = units2dimensions(units)
219
- <<~END
219
+ <<~XML
220
220
  #{unit(units, origtext, normtext, dims, name)}
221
221
  #{prefix(units)}
222
222
  #{dimension(normtext)}
223
223
  #{dimension_components(dims)}
224
224
  #{quantity(normtext, quantity)}
225
- END
225
+ XML
226
226
  end
227
227
  end
228
228
  end
@@ -67,8 +67,8 @@ module Asciimath2UnitsML
67
67
  parser = units.eof
68
68
  end
69
69
 
70
- def parse(x)
71
- text = Array(x.split(/,\s*/))
70
+ def parse(expr)
71
+ text = Array(expr.split(/,\s*/))
72
72
  units = @parser.parse!(text[0])
73
73
  if !units || Rsec::INVALID[units]
74
74
  raise Rsec::SyntaxError.new "error parsing UnitsML expression", x, 1, 0
@@ -80,10 +80,18 @@ module Asciimath2UnitsML
80
80
 
81
81
  def postprocess(units, text)
82
82
  units = postprocess1(units.flatten)
83
- quantity = text[1..-1]&.select { |x| /^quantity:/.match(x) }&.first&.sub(/^quantity:\s*/, "")
84
- name = text[1..-1]&.select { |x| /^name:/.match(x) }&.first&.sub(/^name:\s*/, "")
85
- symbol = text[1..-1]&.select { |x| /^symbol:/.match(x) }&.first&.sub(/^symbol:\s*/, "")
86
- multiplier = text[1..-1]&.select { |x| /^multiplier:/.match(x) }&.first&.sub(/^multiplier:\s*/, "")
83
+ quantity = text[1..-1]&.select do |x|
84
+ /^quantity:/.match(x)
85
+ end&.first&.sub(/^quantity:\s*/, "")
86
+ name = text[1..-1]&.select do |x|
87
+ /^name:/.match(x)
88
+ end&.first&.sub(/^name:\s*/, "")
89
+ symbol = text[1..-1]&.select do |x|
90
+ /^symbol:/.match(x)
91
+ end&.first&.sub(/^symbol:\s*/, "")
92
+ multiplier = text[1..-1]&.select do |x|
93
+ /^multiplier:/.match(x)
94
+ end&.first&.sub(/^multiplier:\s*/, "")
87
95
  normtext = units_only(units).each.map do |u|
88
96
  exp = u[:exponent] && u[:exponent] != "1" ? "^#{u[:exponent]}" : ""
89
97
  "#{u[:prefix]}#{u[:unit]}#{exp}"
@@ -110,14 +118,16 @@ module Asciimath2UnitsML
110
118
  MathML2UnitsML(xml).to_xml
111
119
  end
112
120
 
113
- # https://www.w3.org/TR/mathml-units/ section 2: delimit number Invisible-Times unit
121
+ # https://www.w3.org/TR/mathml-units/ section 2:
122
+ # delimit number Invisible-Times unit
114
123
  def MathML2UnitsML(xml)
115
124
  xml.is_a? String and xml = Nokogiri::XML(xml)
116
125
  xml.xpath(".//m:mtext", "m" => MATHML_NS).each do |x|
117
- next unless %r{^unitsml\(.+\)$}.match(x.text)
126
+ next unless %r{^unitsml\(.+\)$}.match?(x.text)
118
127
 
119
128
  text = x.text.sub(%r{^unitsml\((.+)\)$}m, "\\1")
120
- units, origtext, normtext, quantity, name, symbol, multiplier = parse(text)
129
+ units, origtext, normtext, quantity, name, symbol, multiplier =
130
+ parse(text)
121
131
  rendering = symbol ? embeddedmathml(asciimath2mathml(symbol)) :
122
132
  mathmlsymbol(units, false, multiplier)
123
133
  x.replace("#{delimspace(rendering, x)}"\
@@ -127,11 +137,13 @@ module Asciimath2UnitsML
127
137
  dedup_ids(xml)
128
138
  end
129
139
 
130
- # if previous sibling's last descendent non-whitespace is MathML and mn or mi, no space
140
+ # if previous sibling's last descendent non-whitespace is MathML and
141
+ # mn or mi, no space
131
142
  def delimspace(rendering, elem)
132
143
  prec_text_elem =
133
144
  elem.xpath("./preceding-sibling::*[namespace-uri() = '#{MATHML_NS}']/"\
134
- "descendant::text()[normalize-space()!=''][last()]/parent::*").last
145
+ "descendant::text()[normalize-space()!='']"\
146
+ "[last()]/parent::*").last
135
147
  return "" if prec_text_elem.nil? ||
136
148
  !%w(mn mi).include?(prec_text_elem&.name)
137
149
 
@@ -157,8 +169,8 @@ module Asciimath2UnitsML
157
169
 
158
170
  def asciimath2mathml(expression)
159
171
  AsciiMath::MathMLBuilder.new(:msword => true).append_expression(
160
- AsciiMath.parse(HTMLEntities.new.decode(expression)).ast).to_s
161
- .gsub(/<math>/, "<math xmlns='#{MATHML_NS}'>")
172
+ AsciiMath.parse(HTMLEntities.new.decode(expression)).ast
173
+ ).to_s.gsub(/<math>/, "<math xmlns='#{MATHML_NS}'>")
162
174
  end
163
175
 
164
176
  def embeddedmathml(mathml)
@@ -185,13 +197,13 @@ module Asciimath2UnitsML
185
197
  def render_ambig_units(u)
186
198
  maxcols = 0
187
199
  u.each { |_, v| maxcols = v.size if maxcols < v.size }
188
- puts %([cols="#{maxcols + 1}*"]\n|===\n|Symbol | Unit + ID #{"| " * (maxcols - 1)}\n)
200
+ puts %([cols="#{maxcols + 1}*"]\n|===\n|Symbol | Unit + ID #{'| ' * (maxcols - 1)}\n)
189
201
  puts "\n\n"
190
202
  u.keys.sort_by { |a| [-u[a].size, a.gsub(%r{\&[^;]+;}, "")
191
203
  .gsub(/[^A-Za-z]/, "").downcase] }.each do |k|
192
204
  print "| #{html2adoc(k)} "
193
205
  u[k].sort_by(&:size).each { |v1| print "| #{@units[v1].name}: `#{v1}` " }
194
- puts "#{'| ' * (maxcols - u[k].size) }\n"
206
+ puts "#{'| ' * (maxcols - u[k].size)}\n"
195
207
  end
196
208
  puts "|===\n"
197
209
  end
@@ -7,7 +7,8 @@ module Asciimath2UnitsML
7
7
  when :nospace
8
8
  { html: "", mathml: "<mo>&#x2062;</mo>" }
9
9
  else
10
- { html: HTMLEntities.new.encode(x), mathml: "<mo>#{HTMLEntities.new.encode(x)}</mo>" }
10
+ { html: HTMLEntities.new.encode(x),
11
+ mathml: "<mo>#{HTMLEntities.new.encode(x)}</mo>" }
11
12
  end
12
13
  end
13
14
 
@@ -15,18 +16,21 @@ module Asciimath2UnitsML
15
16
  @symbols[unit][style] || unit
16
17
  end
17
18
 
18
- def htmlent(x)
19
- HTMLEntities.new.decode(x).split(/([<>&])/)
20
- .map { |c| /[<>'"]/.match(c) ? c : HTMLEntities.new.encode(c, :hexadecimal) }.join
19
+ def htmlent(xml)
20
+ HTMLEntities.new.decode(xml).split(/([<>&])/).map do |c|
21
+ /[<>'"]/.match?(c) ? c : HTMLEntities.new.encode(c, :hexadecimal)
22
+ end.join
21
23
  end
22
24
 
23
25
  def htmlsymbol(units, normalise)
24
26
  units.map do |u|
25
- if u[:multiplier] then u[:multiplier] == "*" ? @multiplier[:html] : u[:multiplier]
27
+ if u[:multiplier]
28
+ u[:multiplier] == "*" ? @multiplier[:html] : u[:multiplier]
26
29
  elsif u[:unit].nil? && u[:prefix]
27
30
  @prefixes[u[:prefix]].html
28
31
  else
29
- base = (u[:prefix] || "") + render(normalise ? @units[u[:unit]].symbolid : u[:unit], :html)
32
+ base = (u[:prefix] || "") +
33
+ render(normalise ? @units[u[:unit]].symbolid : u[:unit], :html)
30
34
  htmlsymbol_exponent(u, base)
31
35
  end
32
36
  end.join("")
@@ -36,7 +40,7 @@ module Asciimath2UnitsML
36
40
  if u[:display_exponent] == "0.5"
37
41
  base = "&#x221a;#{base}"
38
42
  elsif u[:display_exponent]
39
- exp = "<sup>#{u[:display_exponent].sub(/-/, "&#x2212;")}</sup>"
43
+ exp = "<sup>#{u[:display_exponent].sub(/-/, '&#x2212;')}</sup>"
40
44
  base += exp
41
45
  end
42
46
  base
@@ -44,8 +48,9 @@ module Asciimath2UnitsML
44
48
 
45
49
  def mathmlsymbol(units, normalise, multiplier = nil)
46
50
  multiplier = multiplier ? "<mo>#{multiplier}</mo>" : @multiplier[:mathml]
47
- exp = units.map do |u|
48
- if u[:multiplier] then u[:multiplier] == "*" ? multiplier : "<mo>#{u[:multiplier]}</mo>"
51
+ units.map do |u|
52
+ if u[:multiplier]
53
+ u[:multiplier] == "*" ? multiplier : "<mo>#{u[:multiplier]}</mo>"
49
54
  elsif u[:unit].nil? && u[:prefix]
50
55
  %(<mi mathvariant='normal'>#{htmlent(@prefixes[u[:prefix]].html)}</mi>)
51
56
  else
@@ -65,20 +70,21 @@ module Asciimath2UnitsML
65
70
  mathmlsymbol_exponent(u, base)
66
71
  end
67
72
 
68
- def mathmlsymbol_exponent(u, base)
69
- if u[:display_exponent] == "0.5"
73
+ def mathmlsymbol_exponent(unit, base)
74
+ if unit[:display_exponent] == "0.5"
70
75
  base = "<msqrt>#{base}</msqrt>"
71
- elsif u[:display_exponent]
72
- exp = "<mn>#{u[:display_exponent]}</mn>".sub(/<mn>-/, "<mo>&#x2212;</mo><mn>")
76
+ elsif unit[:display_exponent]
77
+ exp = "<mn>#{unit[:display_exponent]}</mn>"
78
+ .sub(/<mn>-/, "<mo>&#x2212;</mo><mn>")
73
79
  base = "<msup><mrow>#{base}</mrow><mrow>#{exp}</mrow></msup>"
74
80
  end
75
81
  base
76
82
  end
77
83
 
78
84
  def mathmlsymbolwrap(units, normalise)
79
- <<~END
80
- <math xmlns='#{MATHML_NS}'><mrow>#{mathmlsymbol(units, normalise)}</mrow></math>
81
- END
85
+ <<~XML
86
+ <math xmlns='#{MATHML_NS}'><mrow>#{mathmlsymbol(units, normalise)}</mrow></math>
87
+ XML
82
88
  end
83
89
  end
84
90
  end
@@ -12,16 +12,17 @@ module Asciimath2UnitsML
12
12
 
13
13
  def unit(units, origtext, normtext, dims, name)
14
14
  return if units_only(units).any? { |x| x[:unit].nil? }
15
+
15
16
  dimid = dim_id(dims)
16
17
  norm_units = normalise_units(units)
17
- <<~END
18
- <Unit xmlns='#{UNITSML_NS}' xml:id='#{unit_id(normtext)}'#{dimid ? " dimensionURL='##{dimid}'" : ""}>
19
- #{unitsystem(units)}
20
- #{unitname(norm_units, normtext, name)}
21
- #{unitsymbol(norm_units)}
22
- #{rootunits(units)}
23
- </Unit>
24
- END
18
+ <<~XML
19
+ <Unit xmlns='#{UNITSML_NS}' xml:id='#{unit_id(normtext)}'#{dimid ? " dimensionURL='##{dimid}'" : ""}>
20
+ #{unitsystem(units)}
21
+ #{unitname(norm_units, normtext, name)}
22
+ #{unitsymbol(norm_units)}
23
+ #{rootunits(units)}
24
+ </Unit>
25
+ XML
25
26
  end
26
27
 
27
28
  def normalise_units(units)
@@ -36,6 +37,7 @@ module Asciimath2UnitsML
36
37
  # kg exception
37
38
  def unitsystem(units)
38
39
  return if units_only(units).any? { |x| x[:unit].nil? }
40
+
39
41
  ret = []
40
42
  units = units_only(units)
41
43
  units.any? { |x| @units[x[:unit]].system_name != "SI" } and
@@ -43,7 +45,7 @@ module Asciimath2UnitsML
43
45
  if units.any? { |x| @units[x[:unit]].system_name == "SI" }
44
46
  base = units.size == 1 && @units[units[0][:unit]].system_type == "SI-base"
45
47
  base = true if units.size == 1 && units[0][:unit] == "g" && units[0][:prefix] == "k"
46
- ret << "<UnitSystem name='SI' type='#{base ? "SI_base" : "SI_derived"}' xml:lang='en-US'/>"
48
+ ret << "<UnitSystem name='SI' type='#{base ? 'SI_base' : 'SI_derived'}' xml:lang='en-US'/>"
47
49
  end
48
50
  ret.join("\n")
49
51
  end
@@ -59,23 +61,25 @@ module Asciimath2UnitsML
59
61
  end
60
62
 
61
63
  def unitsymbol(units)
62
- <<~END
63
- <UnitSymbol type="HTML">#{htmlsymbol(units, true)}</UnitSymbol>
64
- <UnitSymbol type="MathML">#{mathmlsymbolwrap(units, true)}</UnitSymbol>
65
- END
64
+ <<~XML
65
+ <UnitSymbol type="HTML">#{htmlsymbol(units, true)}</UnitSymbol>
66
+ <UnitSymbol type="MathML">#{mathmlsymbolwrap(units, true)}</UnitSymbol>
67
+ XML
66
68
  end
67
69
 
68
70
  def rootunits(units)
69
71
  return if units_only(units).any? { |x| x[:unit].nil? }
70
72
  return if units.size == 1 && !units[0][:prefix]
73
+
71
74
  exp = units_only(units).map do |u|
72
75
  prefix = " prefix='#{u[:prefix]}'" if u[:prefix]
73
- exponent = " powerNumerator='#{u[:exponent]}'" if u[:exponent] && u[:exponent] != "1"
76
+ u[:exponent] && u[:exponent] != "1" and
77
+ exponent = " powerNumerator='#{u[:exponent]}'"
74
78
  "<EnumeratedRootUnit unit='#{@units[u[:unit]].name}'#{prefix}#{exponent}/>"
75
79
  end.join("\n")
76
- <<~END
77
- <RootUnits>#{exp}</RootUnits>
78
- END
80
+ <<~XML
81
+ <RootUnits>#{exp}</RootUnits>
82
+ XML
79
83
  end
80
84
  end
81
85
  end