Sha256: f31a45b13d5542196ccd12e973754cb06b71384f5369103723c4e3a102f7addc

Contents?: true

Size: 877 Bytes

Versions: 5

Compression:

Stored size: 877 Bytes

Contents

module MaRuKu::Out::HTML
  def convert_to_mathml_itex2mml(kind, tex)
    return if $already_warned_itex2mml
    begin
      require 'itextomml'
    rescue LoadError => e
      maruku_error "Could not load package 'itex2mml'.\nPlease install it." unless $already_warned_itex2mml
      $already_warned_itex2mml = true
      return nil
    end

    begin
      require 'instiki_stringsupport'
    rescue LoadError
      require 'itex_stringsupport'
    end

    parser = Itex2MML::Parser.new
    mathml =
      case kind
      when :equation
        parser.block_filter(tex)
      when :inline
        parser.inline_filter(tex)
      else
        maruku_error "Unknown itex2mml kind: #{kind}"
        return
      end

    MaRuKu::HTMLFragment.new(mathml.to_utf8)
  rescue => e
    maruku_error "Invalid MathML TeX: \n#{tex.gsub(/^/, 'tex>')}\n\n #{e.inspect}"
    nil
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
maruku-0.7.3 lib/maruku/ext/math/mathml_engines/itex2mml.rb
maruku-0.7.2 lib/maruku/ext/math/mathml_engines/itex2mml.rb
maruku-0.7.1 lib/maruku/ext/math/mathml_engines/itex2mml.rb
maruku-0.7.0 lib/maruku/ext/math/mathml_engines/itex2mml.rb
maruku-0.7.0.beta1 lib/maruku/ext/math/mathml_engines/itex2mml.rb