File: string.rb

package info (click to toggle)
ruby-mathml 1.0.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 516 kB
  • sloc: ruby: 10,090; makefile: 10
file content (33 lines) | stat: -rwxr-xr-x 718 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/ruby
#
# Extension of String class by MathML Library
#
# Copyright (C) 2007, KURODA Hiraku <hiraku@hinet.mydns.jp>
# You can redistribute it and/or modify it under GPL2.
#

require 'math_ml'

module MathML
  module String
    @@mathml_latex_parser = nil
    def self.mathml_latex_parser
      @@mathml_latex_parser ||= MathML::LaTeX::Parser.new
      @@mathml_latex_parser
    end

    def self.mathml_latex_parser=(mlp)
      raise TypeError unless mlp.is_a?(MathML::LaTeX::Parser) || mlp.nil?

      @@mathml_latex_parser = mlp
    end

    def to_mathml(displaystyle = false)
      MathML::String.mathml_latex_parser.parse(self, displaystyle)
    end
  end
end

class String
  include MathML::String
end