Sha256: 0a77385391ae3fb04271e7b1adb441bf83ff57c5e2d6d1988bccba108724304a

Contents?: true

Size: 858 Bytes

Versions: 1

Compression:

Stored size: 858 Bytes

Contents

# -*- coding: utf-8 -*-
#
#--
# Copyright (C) 2009-2014 Thomas Leitner <t_leitner@gmx.at>
#
# This file is part of kramdown which is licensed under the MIT.
#++
#

module Kramdown::Converter::MathEngine

  # Uses the Ritex library for converting math formulas to MathML.
  module Ritex

    begin
      require 'ritex'

      # Ritex is available if this constant is +true+.
      AVAILABLE = true
    rescue LoadError
      AVAILABLE = false  # :nodoc:
    end

    def self.call(converter, el, opts)
      type = el.options[:category]
      result = ::Ritex::Parser.new.parse(el.value, :display => (type == :block))

      attr = el.attr.dup
      attr.delete('xmlns')
      attr.delete('display')
      result.insert("<math".length, converter.html_attributes(attr))

      (type == :block ? "#{' '*opts[:indent]}#{result}\n" : result)
    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
kramdown-1.5.0 lib/kramdown/converter/math_engine/ritex.rb