plurimath 0.8.15 → 0.8.17

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/gen_docs.yml +10 -8
  3. data/README.adoc +4 -0
  4. data/Rakefile +55 -8
  5. data/intent_supported_classes.adoc +82 -0
  6. data/lib/plurimath/formatter/number_formatter.rb +6 -6
  7. data/lib/plurimath/formatter/numeric_formatter.rb +6 -8
  8. data/lib/plurimath/formatter/standard.rb +5 -1
  9. data/lib/plurimath/formatter.rb +14 -0
  10. data/lib/plurimath/latex/parse.rb +2 -1
  11. data/lib/plurimath/math/core.rb +2 -2
  12. data/lib/plurimath/math/formula.rb +26 -6
  13. data/lib/plurimath/math/function/abs.rb +5 -1
  14. data/lib/plurimath/math/function/fenced.rb +19 -7
  15. data/lib/plurimath/math/function/frac.rb +8 -1
  16. data/lib/plurimath/math/function/inf.rb +5 -1
  17. data/lib/plurimath/math/function/int.rb +5 -1
  18. data/lib/plurimath/math/function/intent.rb +6 -2
  19. data/lib/plurimath/math/function/lim.rb +5 -1
  20. data/lib/plurimath/math/function/nary.rb +13 -1
  21. data/lib/plurimath/math/function/oint.rb +5 -1
  22. data/lib/plurimath/math/function/prod.rb +5 -1
  23. data/lib/plurimath/math/function/sum.rb +5 -1
  24. data/lib/plurimath/math/function/table/array.rb +1 -1
  25. data/lib/plurimath/math/function/table/bmatrix.rb +1 -1
  26. data/lib/plurimath/math/function/table/cases.rb +2 -2
  27. data/lib/plurimath/math/function/table/eqarray.rb +2 -2
  28. data/lib/plurimath/math/function/table/pmatrix.rb +1 -1
  29. data/lib/plurimath/math/function/table/vmatrix.rb +1 -1
  30. data/lib/plurimath/math/function/table.rb +12 -0
  31. data/lib/plurimath/math/function/unary_function.rb +5 -1
  32. data/lib/plurimath/math/symbols/bigwedge.rb +4 -0
  33. data/lib/plurimath/math/symbols/cap.rb +0 -4
  34. data/lib/plurimath/math/symbols/clockoint.rb +1 -1
  35. data/lib/plurimath/math/symbols/cntclockoint.rb +1 -1
  36. data/lib/plurimath/math/symbols/coprod.rb +1 -1
  37. data/lib/plurimath/math/symbols/dd.rb +4 -0
  38. data/lib/plurimath/math/symbols/dint.rb +4 -0
  39. data/lib/plurimath/math/symbols/duni.rb +4 -0
  40. data/lib/plurimath/math/symbols/ii.rb +4 -0
  41. data/lib/plurimath/math/symbols/iiiint.rb +1 -1
  42. data/lib/plurimath/math/symbols/iiint.rb +4 -0
  43. data/lib/plurimath/math/symbols/iint.rb +1 -1
  44. data/lib/plurimath/math/symbols/intclockwise.rb +1 -1
  45. data/lib/plurimath/math/symbols/intercal.rb +4 -0
  46. data/lib/plurimath/math/symbols/jj.rb +4 -0
  47. data/lib/plurimath/math/symbols/oiiint.rb +1 -1
  48. data/lib/plurimath/math/symbols/oiint.rb +1 -1
  49. data/lib/plurimath/math/symbols/oint.rb +1 -1
  50. data/lib/plurimath/math/symbols/upcase_dd.rb +4 -0
  51. data/lib/plurimath/math.rb +1 -0
  52. data/lib/plurimath/mathml/transform.rb +2 -0
  53. data/lib/plurimath/number_formatter.rb +5 -5
  54. data/lib/plurimath/unitsml.rb +3 -1
  55. data/lib/plurimath/utility/intent_encoding.rb +21 -21
  56. data/lib/plurimath/version.rb +1 -1
  57. metadata +4 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1783cc0eadbbb06f0f9f8cf7ec7c1c67151ae7c85e5a8f6bd8d4f325a2823fc7
4
- data.tar.gz: 8f59467437e61ab7e53d828256967f014eed2417400f6df29d3a9a037b7f9545
3
+ metadata.gz: f232ae9e7e95e99742976ce89205bd3a21269cfaf2df31941de6fbd9594aff9e
4
+ data.tar.gz: 93a5a1f1e6faf693ea589c17cb0429aaba81426c838ce9c993747c8db185beb4
5
5
  SHA512:
6
- metadata.gz: 91199c6a3c324fd5ac78147c402ba60ff1dc972d4f99dd33006230700f0b9aa07042e38f677f8440a6873663e977c1c0f9c6db09ce04dac1206535f99cdc43da
7
- data.tar.gz: f21bffba36efc43968174c803319992edde54f4cf64e9dc840d5fa7fe9637898c01068d30021b933972ce349615d82ca477dd79ff63142178bd981feb8c09fd5
6
+ metadata.gz: 41e48748d0e213ee5910a6e5e6fcf2d012e87bc7a0731d1036b2e432e40677460c841fe50340763cf7c8778a9ac30ed91c2f1b6795b601bb2ad843f148a2cebc
7
+ data.tar.gz: 5262d5b7474b0544c82937e50e1b44342d2b2b64aa85adadf4b9a5ec0f9afbbfb23db8d45e514c25745c326c22aef8eae8321ad699a803e04ed084793c9d86e3
@@ -9,6 +9,13 @@ on:
9
9
  jobs:
10
10
  generate_docs:
11
11
  runs-on: ubuntu-latest
12
+ strategy:
13
+ matrix:
14
+ filename:
15
+ - supported_parens_list.adoc
16
+ - supported_symbols_list.adoc
17
+ - intent_supported_classes.adoc
18
+
12
19
  steps:
13
20
  - uses: actions/checkout@v4
14
21
 
@@ -17,12 +24,7 @@ jobs:
17
24
  ruby-version: '3.3'
18
25
  bundler-cache: true
19
26
 
20
- - name: Generate supported_parens_list.adoc
21
- run: |
22
- rm -f supported_parens_list.adoc
23
- bundle exec rake supported_parens_list.adoc
24
-
25
- - name: Generate supported_symbols_list.adoc
27
+ - name: Generate documentation
26
28
  run: |
27
- rm -f supported_symbols_list.adoc
28
- bundle exec rake supported_symbols_list.adoc
29
+ rm -f ${{ matrix.filename }}
30
+ bundle exec rake ${{ matrix.filename }}
data/README.adoc CHANGED
@@ -583,6 +583,10 @@ Consult the following tables for details on supported symbols and parentheses:
583
583
  * link:supported_symbols_list.adoc[Symbols]
584
584
  * link:supported_parens_list.adoc[Parentheses]
585
585
 
586
+ The following table shows the classes that support MathML "intent" encoding:
587
+
588
+ * link:intent_supported_classes.adoc[Classes that support MathML Intent]
589
+
586
590
  NOTE: To regenerate these files, delete them and run:
587
591
  `bundle exec rake supported_symbols_list.adoc`.
588
592
 
data/Rakefile CHANGED
@@ -18,6 +18,7 @@ end
18
18
  DOC_FILES = {
19
19
  "supported_parens_list.adoc" => :paren,
20
20
  "supported_symbols_list.adoc" => :symbols,
21
+ "intent_supported_classes.adoc" => :intent,
21
22
  }.freeze
22
23
 
23
24
  DOC_FILES.each do |file_name, type|
@@ -28,17 +29,26 @@ end
28
29
 
29
30
  def write_doc_file(doc_file, type:)
30
31
  File.open(doc_file, "a") do |file|
31
- file.write(file_header)
32
-
33
- Plurimath::Utility.send(:"#{type}_files").each do |klass|
34
- next if klass::INPUT.empty?
35
-
36
- file_name = File.basename(klass.const_source_location(:INPUT).first, ".rb")
37
- file.write(documentation_content(file_name, klass))
32
+ case type
33
+ when :intent
34
+ write_intent_doc_file(file)
35
+ else
36
+ paren_symbols_doc(file, type)
38
37
  end
38
+ end
39
+ end
40
+
41
+ def paren_symbols_doc(file, type)
42
+ file.write(file_header)
39
43
 
40
- file.write("|===")
44
+ Plurimath::Utility.send(:"#{type}_files").each do |klass|
45
+ next if klass::INPUT.empty?
46
+
47
+ file_name = File.basename(klass.const_source_location(:INPUT).first, ".rb")
48
+ file.write(documentation_content(file_name, klass))
41
49
  end
50
+
51
+ file.write("|===")
42
52
  end
43
53
 
44
54
  def documentation_content(file_name, klass)
@@ -75,4 +85,41 @@ def format_input(format, klass)
75
85
  end.join(", ").gsub(/\|/, "\\|")
76
86
  end
77
87
 
88
+ def write_intent_doc_file(file)
89
+ file.write("= List of classes supporting `intent` encoding with relevant values\n")
90
+
91
+ intent_classes.each do |klass|
92
+ intents = klass.new.intent_names.values.map do |intent|
93
+ "`#{intent}`"
94
+ end
95
+
96
+ file.write(
97
+ <<~INTENT
98
+
99
+ * `#{klass.name.gsub("Plurimath::Math::", "")}`
100
+ ** #{intents.join("\n** ")}
101
+ INTENT
102
+ )
103
+ end
104
+
105
+ file.write("\nIntent for unary classes like, sin, cos, tan, etc. will be `Function`.\n")
106
+ end
107
+
108
+ def intent_classes
109
+ intent_classes = [
110
+ Plurimath::Math::Function::TernaryFunction.descendants,
111
+ Plurimath::Math::Function::BinaryFunction.descendants,
112
+ Plurimath::Math::Function::UnaryFunction.descendants,
113
+ Plurimath::Math::Function::Table.descendants,
114
+ Plurimath::Math::Symbols::Symbol.descendants,
115
+ Plurimath::Math::Function::UnaryFunction,
116
+ Plurimath::Math::Function::Table,
117
+ Plurimath::Math::Function::Nary,
118
+ Plurimath::Math::Formula,
119
+ ].flatten
120
+ intent_classes.select do |klass|
121
+ klass.instance_methods(false).include?(:intent_names)
122
+ end
123
+ end
124
+
78
125
  task :default => :spec
@@ -0,0 +1,82 @@
1
+ = List of classes supporting `intent` encoding with relevant values
2
+
3
+ * `Function::Fenced`
4
+ ** `open-closed-interval`
5
+ ** `closed-open-interval`
6
+ ** `binomial-coefficient`
7
+ ** `closed-interval`
8
+ ** `open-interval`
9
+ ** `:fenced`
10
+
11
+ * `Function::Int`
12
+ ** `:integral`
13
+
14
+ * `Function::Oint`
15
+ ** `:contour integral`
16
+
17
+ * `Function::Prod`
18
+ ** `:product`
19
+
20
+ * `Function::Sum`
21
+ ** `:sum`
22
+
23
+ * `Function::Frac`
24
+ ** `:derivative`
25
+ ** `:partial-derivative`
26
+
27
+ * `Function::Inf`
28
+ ** `:function`
29
+
30
+ * `Function::Intent`
31
+ ** `:derivative`
32
+
33
+ * `Function::Lim`
34
+ ** `:function`
35
+
36
+ * `Function::Abs`
37
+ ** `absolute-value`
38
+
39
+ * `Symbols::Dd`
40
+ ** `ⅆ`
41
+
42
+ * `Symbols::Ii`
43
+ ** `ⅈ`
44
+
45
+ * `Symbols::Intercal`
46
+ ** `transpose`
47
+
48
+ * `Symbols::Jj`
49
+ ** `ⅉ`
50
+
51
+ * `Symbols::UpcaseDd`
52
+ ** `ⅅ`
53
+
54
+ * `Function::UnaryFunction`
55
+ ** `:function`
56
+
57
+ * `Function::Table`
58
+ ** `:curly-braced-matrix`
59
+ ** `:parenthesized-matrix`
60
+ ** `:bracketed-matrix`
61
+ ** `:normed-matrix`
62
+ ** `:determinant`
63
+ ** `:equations`
64
+ ** `:cases`
65
+
66
+ * `Function::Nary`
67
+ ** `:n-ary`
68
+ ** `:anticlockwise contour integral`
69
+ ** `:coproduct`
70
+ ** `:quadruple integral`
71
+ ** `:triple integral`
72
+ ** `:double integral`
73
+ ** `:clockwise contour integral`
74
+ ** `:volume integral`
75
+ ** `:surface integral`
76
+ ** `:contour integral`
77
+
78
+ * `Formula`
79
+ ** `:partial-derivative`
80
+ ** `:derivative`
81
+
82
+ Intent for unary classes like, sin, cos, tan, etc. will be `Function`.
@@ -3,7 +3,7 @@
3
3
  module Plurimath
4
4
  module Formatter
5
5
  class NumberFormatter
6
- attr_reader :number, :data_reader
6
+ attr_reader :number, :data_reader, :prefix
7
7
 
8
8
  STRING_SYMBOLS = {
9
9
  dot: ".".freeze,
@@ -13,6 +13,7 @@ module Plurimath
13
13
  def initialize(number, data_reader = {})
14
14
  @number = number
15
15
  @data_reader = data_reader
16
+ @prefix = "-" if number.negative?
16
17
  end
17
18
 
18
19
  def format(precision: nil)
@@ -20,16 +21,15 @@ module Plurimath
20
21
  int, frac, integer_format, fraction_format, signif_format = *partition_tokens(number)
21
22
  result = integer_format.apply(int, data_reader)
22
23
  result << fraction_format.apply(frac, data_reader, int) if frac
23
-
24
24
  result = signif_format.apply(result, integer_format, fraction_format)
25
-
26
- result
25
+ result = "+#{result}" if number.positive? && data_reader[:number_sign] == :plus
26
+ "#{prefix}#{result}"
27
27
  end
28
28
 
29
29
  private
30
30
 
31
31
  def partition_tokens(number)
32
- int, fraction = parse_number(number, data_reader)
32
+ int, fraction = parse_number(number)
33
33
  [
34
34
  int,
35
35
  fraction,
@@ -46,7 +46,7 @@ module Plurimath
46
46
  parts.size == 2 ? parts[1].size : 0
47
47
  end
48
48
 
49
- def parse_number(number, options = {})
49
+ def parse_number(number, options = data_reader)
50
50
  precision = options[:precision] || precision_from(number)
51
51
 
52
52
  num = if precision == 0
@@ -1,9 +1,4 @@
1
- require_relative "supported_locales"
2
- require_relative "numbers/base"
3
- require_relative "numbers/integer"
4
- require_relative "numbers/fraction"
5
- require_relative "numbers/significant"
6
- require_relative "number_formatter"
1
+ # frozen_string_literal: true
7
2
 
8
3
  module Plurimath
9
4
  module Formatter
@@ -77,7 +72,9 @@ module Plurimath
77
72
 
78
73
  def update_exponent_value(number_str)
79
74
  exponent_number = BigDecimal(number_str) - 1
80
- "#{"+" if @exponent_sign == :plus}#{exponent_number.to_i}"
75
+ return exponent_number.to_i if exponent_number.negative? || @exponent_sign != :plus
76
+
77
+ "+#{exponent_number.to_i}"
81
78
  end
82
79
 
83
80
  def notation_chars(num_str)
@@ -117,7 +114,8 @@ module Plurimath
117
114
 
118
115
  chars.first.delete!(".")
119
116
  chars.first.insert(index + 1, ".") unless chars.first[index + 2].nil?
120
- chars[-1] = (chars[-1].to_i - index).to_s
117
+ exponent = chars[-1]
118
+ chars[-1] = "#{"+" if exponent.to_s.start_with?("+")}#{exponent.to_i - index}"
121
119
  end
122
120
  end
123
121
  end
@@ -10,10 +10,12 @@ module Plurimath
10
10
  fraction_group_digits: 3,
11
11
  exponent_sign: "plus",
12
12
  fraction_group: "'",
13
+ number_sign: "plus",
13
14
  notation: :basic,
14
15
  group_digits: 3,
15
16
  significant: 0,
16
17
  digit_count: 0,
18
+ precision: 0,
17
19
  decimal: ".",
18
20
  group: ",",
19
21
  times: "x",
@@ -21,21 +23,23 @@ module Plurimath
21
23
  }.freeze
22
24
 
23
25
  def initialize(locale: "en", string_format: nil, options: {}, precision: nil)
24
- @precision = precision
25
26
  super(
26
27
  locale,
27
28
  localize_number: string_format,
28
29
  localizer_symbols: set_default_options(options),
30
+ precision: precision,
29
31
  )
30
32
  end
31
33
 
32
34
  def set_default_options(options)
33
35
  default_options = self.class::DEFAULT_OPTIONS
36
+ self.precision ||= default_options[:precision]
34
37
  options ||= default_options
35
38
  options[:fraction_group_digits] ||= default_options[:fraction_group_digits]
36
39
  options[:fraction_group] ||= default_options[:fraction_group]
37
40
  options[:exponent_sign] ||= default_options[:exponent_sign]
38
41
  options[:group_digits] ||= default_options[:group_digits]
42
+ options[:number_sign] ||= default_options[:number_sign]
39
43
  options[:significant] ||= default_options[:significant]
40
44
  options[:notation] ||= default_options[:notation]
41
45
  options[:decimal] ||= default_options[:decimal]
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "formatter/numeric_formatter"
4
+ require_relative "formatter/supported_locales"
5
+ require_relative "formatter/numbers/base"
6
+ require_relative "formatter/numbers/integer"
7
+ require_relative "formatter/numbers/fraction"
8
+ require_relative "formatter/numbers/significant"
9
+ require_relative "formatter/number_formatter"
10
+
11
+ module Plurimath
12
+ module Formatter
13
+ end
14
+ end
@@ -97,7 +97,8 @@ module Plurimath
97
97
  rparen.absent? >> symbol_class_commands |
98
98
  (slash >> math_operators_classes) |
99
99
  match["a-zA-Z"].as(:symbols) |
100
- match(/\d+(\.[0-9]+)|\d/).repeat(1).as(:number) |
100
+ (match["0-9"].repeat(0) >> str(".").maybe >> match["0-9"].repeat(1)).as(:number) |
101
+ match["0-9"].repeat(1).as(:number) |
101
102
  (str("\\\\").as("\\\\") >> match(/\s/).repeat) |
102
103
  str("\\ ").as(:space) |
103
104
  (str("\\operatorname{") >> match("[^}]").repeat.as(:symbols) >> str("}"))
@@ -344,10 +344,10 @@ module Plurimath
344
344
  ox_element("mrow") << xml_engine_node
345
345
  end
346
346
 
347
- def intentify(tag, intent, func_name:, intent_name: nil)
347
+ def intentify(tag, intent, func_name:, intent_name: nil, options: {})
348
348
  return tag unless intent
349
349
 
350
- Utility::IntentEncoding.send("#{func_name}_intent", tag, intent_name)
350
+ Utility::IntentEncoding.send("#{func_name}_intent", tag, intent_name, options)
351
351
  end
352
352
 
353
353
  def masked_tag(tag)
@@ -3,7 +3,7 @@
3
3
  module Plurimath
4
4
  module Math
5
5
  class Formula < Core
6
- attr_accessor :value, :left_right_wrapper, :displaystyle, :input_string, :unitsml
6
+ attr_accessor :value, :left_right_wrapper, :displaystyle, :input_string, :unitsml, :unitsml_xml
7
7
 
8
8
  MATH_ZONE_TYPES = %i[
9
9
  omml
@@ -48,8 +48,14 @@ module Plurimath
48
48
  parse_error!(:asciimath)
49
49
  end
50
50
 
51
- def to_mathml(display_style: displaystyle, split_on_linebreak: false, intent: false, formatter: nil)
52
- options = { formatter: formatter }
51
+ def to_mathml(
52
+ intent: false,
53
+ formatter: nil,
54
+ unitsml_xml: nil,
55
+ split_on_linebreak: false,
56
+ display_style: displaystyle
57
+ )
58
+ options = { formatter: formatter, unitsml_xml: unitsml_xml }
53
59
  return line_breaked_mathml(display_style, intent, options: options) if split_on_linebreak
54
60
 
55
61
  math_attrs = {
@@ -80,6 +86,7 @@ module Plurimath
80
86
  attributes = intent_attribute(mathml_value) if intent
81
87
  mrow = ox_element("mrow", attributes: attributes)
82
88
  mrow[:unitsml] = true if unitsml
89
+ mathml_value += wrapped_unitsml_xml(mrow) if unitsml_xml && options[:unitsml_xml]
83
90
  Utility.update_nodes(mrow, mathml_value)
84
91
  end
85
92
 
@@ -290,6 +297,13 @@ module Plurimath
290
297
  true if value&.first&.mini_sized?
291
298
  end
292
299
 
300
+ def intent_names
301
+ {
302
+ partial_derivative: ":partial-derivative",
303
+ derivative: ":derivative",
304
+ }
305
+ end
306
+
293
307
  protected
294
308
 
295
309
  def boolean_display_style(display_style = displaystyle)
@@ -329,6 +343,12 @@ module Plurimath
329
343
  end
330
344
  end
331
345
 
346
+ def wrapped_unitsml_xml(mrow)
347
+ node = Plurimath.xml_engine.load("<mrow>#{unitsml_xml}</mrow>")
348
+ mrow.attributes[:xref] = node.locate("*/@id").first if node.locate("*/@id").any?
349
+ node.nodes
350
+ end
351
+
332
352
  def space_element(node)
333
353
  element = (ox_element("mo") << "&#x2062;")
334
354
  element[:rspace] = "thickmathspace" if text_in_tag?(node.xml_nodes.nodes)
@@ -476,7 +496,7 @@ module Plurimath
476
496
  prime_str = encode(nodes.last.nodes.first) if valid_prime?(nodes.last)
477
497
  second_arg.insert(-1, prime_str) unless second_arg.match?(/[0-9]$/)
478
498
  end
479
- ":partial-derivative(#{first_arg},$f,#{second_arg})"
499
+ "#{intent_names[:partial_derivative]}(#{first_arg},$f,#{second_arg})"
480
500
  end
481
501
 
482
502
  def f_arg(tag_nodes, index)
@@ -548,7 +568,7 @@ module Plurimath
548
568
  end
549
569
  break
550
570
  end
551
- intent_name = ":derivative(1,#{second_arg},#{third_arg})"
571
+ intent_name = "#{intent_names[:derivative]}(1,#{second_arg},#{third_arg})"
552
572
  mrow = ox_element("mrow", attributes: { intent: intent_name })
553
573
  nodes.insert(0, Utility.update_nodes(mrow, mrow_nodes))
554
574
  end
@@ -563,7 +583,7 @@ module Plurimath
563
583
 
564
584
  if DERIVATIVE_CONSTS.include?(node.nodes[0]&.nodes&.first)
565
585
  iteration += 1
566
- node["intent"] = ":derivative#{derivative_intent_name(node.nodes[1], nodes[iteration..-1], type: node.name)}"
586
+ node["intent"] = "#{intent_names[:derivative]}#{derivative_intent_name(node.nodes[1], nodes[iteration..-1], type: node.name)}"
567
587
  next_node = nodes[iteration]
568
588
  case next_node.name
569
589
  when "mi", "mrow"
@@ -14,7 +14,7 @@ module Plurimath
14
14
  first_value = first_value&.insert(0, symbol) unless open_paren
15
15
  first_value << symbol unless close_paren
16
16
  mrow = Utility.update_nodes(ox_element("mrow"), first_value)
17
- intentify(mrow, intent, func_name: :abs, intent_name: :"absolute-value")
17
+ intentify(mrow, intent, func_name: :abs, intent_name: intent_names[:name])
18
18
  end
19
19
 
20
20
  def to_omml_without_math_tag(display_style, options:)
@@ -39,6 +39,10 @@ module Plurimath
39
39
  "⒜#{unicodemath_parens(parameter_one, options: options)}"
40
40
  end
41
41
 
42
+ def intent_names
43
+ { name: "absolute-value" }
44
+ end
45
+
42
46
  protected
43
47
 
44
48
  def md_tag
@@ -39,6 +39,7 @@ module Plurimath
39
39
  intent,
40
40
  func_name: :interval_fence,
41
41
  intent_name: intent_value(mrow_value, options: options),
42
+ options: intent_names,
42
43
  )
43
44
  end
44
45
 
@@ -145,6 +146,17 @@ module Plurimath
145
146
  "#{parameter_one.to_unicodemath(options: options)}#{fenced_value}#{parameter_three.to_unicodemath(options: options)}"
146
147
  end
147
148
 
149
+ def intent_names
150
+ {
151
+ open_closed_interval: "open-closed-interval",
152
+ closed_open_interval: "closed-open-interval",
153
+ binomial_coefficient: "binomial-coefficient",
154
+ closed_interval: "closed-interval",
155
+ open_interval: "open-interval",
156
+ fenced: ":fenced",
157
+ }
158
+ end
159
+
148
160
  protected
149
161
 
150
162
  def open_paren(dpr, options:)
@@ -253,11 +265,11 @@ module Plurimath
253
265
  end
254
266
 
255
267
  def intent_value(value, options:)
256
- return "binomial-coefficient" if binomial_coefficient?(value)
268
+ return :binomial_coefficient if binomial_coefficient?(value)
257
269
 
258
270
  open_paren = symbol_or_paren(parameter_one, lang: :latex, options: options)
259
271
  close_paren = symbol_or_paren(parameter_three, lang: :latex, options: options)
260
- return "fenced" unless interval_intent?(value, open_paren, close_paren)
272
+ return :fenced unless interval_intent?(value, open_paren, close_paren)
261
273
 
262
274
  interval_intent(value, open_paren, close_paren)
263
275
  end
@@ -270,15 +282,15 @@ module Plurimath
270
282
  def interval_intent(value, open_paren, close_paren)
271
283
  case open_paren
272
284
  when "("
273
- 'open-closed-interval' if close_paren == ']'
285
+ :open_closed_interval if close_paren == ']'
274
286
  when "["
275
- return 'closed-interval' if close_paren == ']'
287
+ return :closed_interval if close_paren == ']'
276
288
 
277
- 'closed-open-interval' if (close_paren == '[' || close_paren == ')')
289
+ :closed_open_interval if (close_paren == '[' || close_paren == ')')
278
290
  when "]"
279
- return 'open-closed-interval' if close_paren == ']'
291
+ return :open_closed_interval if close_paren == ']'
280
292
 
281
- 'open-interval' if close_paren == '['
293
+ :open_interval if close_paren == '['
282
294
  end
283
295
  end
284
296
 
@@ -41,7 +41,7 @@ module Plurimath
41
41
  frac_tag.set_attr(self.options.reject { |opt| opt == :choose }) if tag_name == "mfrac" && self.options
42
42
  Utility.update_nodes(frac_tag, mathml_value)
43
43
  update_derivative(frac_tag, mathml_value[0], mathml_value[1]) if intent
44
- intentify(frac_tag, intent, func_name: :frac)
44
+ intentify(frac_tag, intent, func_name: :frac, options: intent_names)
45
45
  end
46
46
 
47
47
  def to_latex(options:)
@@ -98,6 +98,13 @@ module Plurimath
98
98
  "#{first_value}⒞#{second_value}"
99
99
  end
100
100
 
101
+ def intent_names
102
+ {
103
+ derivative: ":derivative",
104
+ partial_derivative: ":partial-derivative",
105
+ }
106
+ end
107
+
101
108
  protected
102
109
 
103
110
  def fpr_element
@@ -36,7 +36,7 @@ module Plurimath
36
36
  parameter_two&.to_mathml_without_math_tag(intent, options: options),
37
37
  ],
38
38
  )
39
- intentify(inf_tag, intent, func_name: :function, intent_name: :function)
39
+ intentify(inf_tag, intent, func_name: :function, intent_name: intent_names[:name])
40
40
  end
41
41
 
42
42
  def to_omml_without_math_tag(display_style, options:)
@@ -57,6 +57,10 @@ module Plurimath
57
57
  "inf#{sub_value(options: options)}#{sup_value(options: options)}"
58
58
  end
59
59
 
60
+ def intent_names
61
+ { name: ":function" }
62
+ end
63
+
60
64
  protected
61
65
 
62
66
  def sup_value(options:)
@@ -62,7 +62,7 @@ module Plurimath
62
62
  wrap_mrow(parameter_three&.to_mathml_without_math_tag(intent, options: options), intent),
63
63
  ].flatten.compact,
64
64
  )
65
- intentify(mrow, intent, func_name: :naryand, intent_name: :integral)
65
+ intentify(mrow, intent, func_name: :naryand, intent_name: intent_names[:name])
66
66
  end
67
67
 
68
68
  def to_omml_without_math_tag(display_style, options:)
@@ -116,6 +116,10 @@ module Plurimath
116
116
  true
117
117
  end
118
118
 
119
+ def intent_names
120
+ { name: ":integral" }
121
+ end
122
+
119
123
  protected
120
124
 
121
125
  def sup_value(options:)
@@ -17,15 +17,19 @@ module Plurimath
17
17
  "ⓘ#{first_value}"
18
18
  end
19
19
 
20
+ def intent_names
21
+ { name: ":derivative" }
22
+ end
23
+
20
24
  private
21
25
 
22
26
  def encoded_intent(tag)
23
- if parameter_two.value == ":derivative" && encodable?
27
+ if parameter_two.value == intent_names[:name] && encodable?
24
28
  field = parameter_one.value
25
29
  unicode = encode(field[0].parameter_one.value)
26
30
  unfenced_str = fence_value(tag.nodes[1].nodes[1..-2]) if tag.nodes[1]["intent"] == ":fenced"
27
31
  fenced_str = "(#{unfenced_str})" unless unfenced_str.empty?
28
- ":derivative(1,#{unicode}#{fenced_str},#{unfenced_str})"
32
+ "#{intent_names[:name]}(1,#{unicode}#{fenced_str},#{unfenced_str})"
29
33
  else
30
34
  Utility.html_entity_to_unicode(parameter_two.value)
31
35
  end
@@ -42,7 +42,7 @@ module Plurimath
42
42
  parameter_two&.to_mathml_without_math_tag(intent, options: options),
43
43
  ],
44
44
  )
45
- intentify(lim_tag, intent, func_name: :function, intent_name: :function)
45
+ intentify(lim_tag, intent, func_name: :function, intent_name: intent_names[:name])
46
46
  end
47
47
 
48
48
  def to_omml_without_math_tag(display_style, options:)
@@ -64,6 +64,10 @@ module Plurimath
64
64
  self.parameter_two = nil
65
65
  end
66
66
  end
67
+
68
+ def intent_names
69
+ { name: ":function" }
70
+ end
67
71
  end
68
72
  end
69
73
  end