Sha256: bd0f37c50225391223898918aa2a93ff978caefc0212b3c86afdc29bb8c6436f

Contents?: true

Size: 638 Bytes

Versions: 8

Compression:

Stored size: 638 Bytes

Contents

# Unless run with ReverseAsciidoctor.config.mathml2asciimath,
# this is cheating: we're injecting MathML into Asciidoctor, but
# Asciidoctor only understands AsciiMath or LaTeX

require "mathml2asciimath"

module ReverseAsciidoctor
  module Converters
    class Math < Base
      def convert(node, state = {})
        stem = node.to_s.gsub(/\n/, " ")
        stem = MathML2AsciiMath.m2a(stem) if ReverseAsciidoctor.config.mathml2asciimath
        stem = stem.gsub(/\[/, "\\[").gsub(/\]/, "\\]").gsub(/\(\(([^\)]+)\)\)/, "(\\1)") unless stem.nil?
        " stem:[" << stem << "] "
      end
    end

    register :math, Math.new
  end
end

Version data entries

8 entries across 8 versions & 2 rubygems

Version Path
reverse_adoc-0.2.8 lib/reverse_asciidoctor/converters/math.rb
reverse_adoc-0.2.7 lib/reverse_asciidoctor/converters/math.rb
reverse_adoc-0.2.6 lib/reverse_asciidoctor/converters/math.rb
reverse_adoc-0.2.5 lib/reverse_asciidoctor/converters/math.rb
reverse_adoc-0.2.4 lib/reverse_asciidoctor/converters/math.rb
reverse_adoc-0.2.3 lib/reverse_asciidoctor/converters/math.rb
reverse_asciidoctor-0.2.2 lib/reverse_asciidoctor/converters/math.rb
reverse_asciidoctor-0.2.1 lib/reverse_asciidoctor/converters/math.rb