Sha256: 9572e0b41027ff9da8aa8957d5e2294c9677302023f69bd8e43c570e9e483bdd

Contents?: true

Size: 1.78 KB

Versions: 4

Compression:

Stored size: 1.78 KB

Contents

# frozen_string_literal: true

require_relative "unary_function"

module Plurimath
  module Math
    module Function
      class Phantom < UnaryFunction
        def to_asciimath
          "#{Array.new(asciimath_value&.length, '\ ').join}"
        end

        def to_html
          "<i style='visibility: hidden;'>#{parameter_one&.to_html}</i>"
        end

        def to_latex
          "\\#{class_name}{#{latex_value}}"
        end

        def to_mathml_without_math_tag(intent)
          Utility.update_nodes(
            Utility.ox_element("mphantom"),
            Array(mathml_value(intent)),
          )
        end

        def to_omml_without_math_tag(display_style)
          phant = Utility.ox_element("phant", namespace: "m")
          e_tag = Utility.ox_element("e", namespace: "m")
          Utility.update_nodes(e_tag, Array(omml_value(display_style)))
          Utility.update_nodes(phant, [phant_pr, e_tag])
        end

        def to_unicodemath
          if parameter_one.is_a?(Math::Function::Mpadded) && parameter_one&.options&.dig(:phantom)
            "#{phantom_unicode}#{unicodemath_parens(parameter_one.parameter_one)}"
          else
            "⟡#{unicodemath_parens(parameter_one)}"
          end
        end

        def line_breaking(obj)
          custom_array_line_breaking(obj)
        end

        protected

        def phant_pr
          attributes = { "m:val": "off" }
          phant = Utility.ox_element("phantPr", namespace: "m")
          phant << Utility.ox_element("show", namespace: "m", attributes: attributes)
        end

        def phantom_symbol
          UnicodeMath::Constants::PHANTOM_SYMBOLS.key(parameter_one.options)
        end

        def phantom_unicode
          UnicodeMath::Constants::UNARY_SYMBOLS[phantom_symbol]
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
plurimath-0.8.14 lib/plurimath/math/function/phantom.rb
plurimath-0.8.13 lib/plurimath/math/function/phantom.rb
plurimath-0.8.12 lib/plurimath/math/function/phantom.rb
plurimath-0.8.11 lib/plurimath/math/function/phantom.rb