Sha256: 9b5840daebb966205a4df364b5bfe2093a202e14ad59dd0aa51c043ed7c5f171

Contents?: true

Size: 1.77 KB

Versions: 10

Compression:

Stored size: 1.77 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
          Utility.update_nodes(
            Utility.ox_element("mphantom"),
            Array(mathml_value),
          )
        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

10 entries across 10 versions & 1 rubygems

Version Path
plurimath-0.8.10 lib/plurimath/math/function/phantom.rb
plurimath-0.8.9 lib/plurimath/math/function/phantom.rb
plurimath-0.8.8 lib/plurimath/math/function/phantom.rb
plurimath-0.8.7 lib/plurimath/math/function/phantom.rb
plurimath-0.8.6 lib/plurimath/math/function/phantom.rb
plurimath-0.8.5 lib/plurimath/math/function/phantom.rb
plurimath-0.8.4 lib/plurimath/math/function/phantom.rb
plurimath-0.8.2 lib/plurimath/math/function/phantom.rb
plurimath-0.8.1 lib/plurimath/math/function/phantom.rb
plurimath-0.8.0 lib/plurimath/math/function/phantom.rb