lib/plurimath/math/formula.rb in plurimath-0.8.16 vs lib/plurimath/math/formula.rb in plurimath-0.8.17

- old
+ new

@@ -295,10 +295,17 @@ def mini_sized? true if value&.first&.mini_sized? end + def intent_names + { + partial_derivative: ":partial-derivative", + derivative: ":derivative", + } + end + protected def boolean_display_style(display_style = displaystyle) YAML.safe_load(display_style.to_s) end @@ -487,11 +494,11 @@ first_arg = str.include?(",") ? str.split(",").length : str.length second_arg = str.include?(",") ? str : str.split("").join(",") prime_str = encode(nodes.last.nodes.first) if valid_prime?(nodes.last) second_arg.insert(-1, prime_str) unless second_arg.match?(/[0-9]$/) end - ":partial-derivative(#{first_arg},$f,#{second_arg})" + "#{intent_names[:partial_derivative]}(#{first_arg},$f,#{second_arg})" end def f_arg(tag_nodes, index) nodes = [] while index <= tag_nodes.length @@ -559,11 +566,11 @@ mrow_nodes << nodes.delete_at(1) break end break end - intent_name = ":derivative(1,#{second_arg},#{third_arg})" + intent_name = "#{intent_names[:derivative]}(1,#{second_arg},#{third_arg})" mrow = ox_element("mrow", attributes: { intent: intent_name }) nodes.insert(0, Utility.update_nodes(mrow, mrow_nodes)) end def subsup_dd_derivative(nodes) @@ -574,10 +581,10 @@ node = nodes[iteration] next iteration += 1 unless node.nodes[0].is_a?(Plurimath::XmlEngine::Ox::Element) if DERIVATIVE_CONSTS.include?(node.nodes[0]&.nodes&.first) iteration += 1 - node["intent"] = ":derivative#{derivative_intent_name(node.nodes[1], nodes[iteration..-1], type: node.name)}" + node["intent"] = "#{intent_names[:derivative]}#{derivative_intent_name(node.nodes[1], nodes[iteration..-1], type: node.name)}" next_node = nodes[iteration] case next_node.name when "mi", "mrow" if ["mi", "mrow"].include?(nodes[iteration + 1].name) wrap_in_mrow(nodes[iteration..-1])