Sha256: 405f75ffb3acc9258ce4668507f0947123bc1574bedee0159466afaa2e23aefc

Contents?: true

Size: 750 Bytes

Versions: 1

Compression:

Stored size: 750 Bytes

Contents

# frozen_string_literal: true

require_relative "unary_function"

module Plurimath
  module Math
    module Function
      class Text < UnaryFunction
        def to_asciimath
          "\"#{parameter_one}\""
        end

        def to_mathml_without_math_tag
          regex_exp = %r{unicode\[:(?<unicode>\w{1,})\]}
          parameter_one.gsub!(regex_exp) do |_text|
            symbol_value(Regexp.last_match[:unicode]).to_s
          end
          "<mtext>#{parameter_one}</mtext>"
        end

        def symbol_value(unicode)
          Mathml::Constants::UNICODE_SYMBOLS.invert[unicode] ||
            Mathml::Constants::SYMBOLS.invert[unicode]
        end

        def to_latex
          parameter_one
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
plurimath-0.2.0 lib/plurimath/math/function/text.rb