Class: Mathml2latex::XsltFunctions

Inherits:
Object
  • Object
show all
Defined in:
lib/mathml2latex/xslt_functions.rb

Instance Method Summary collapse

Instance Method Details

#fetch_symbols(str) ⇒ Object



20
21
22
23
24
25
26
27
28
29
# File 'lib/mathml2latex/xslt_functions.rb', line 20

def fetch_symbols(str)
  ret_str = ''.dup
  str.each_char do |character|
    key = character.chr.ord
    val = Mathml2latex::SYMBOLS[key]
    val = character if val.nil?
    ret_str << val
  end
  ret_str
end

#matches(str, regex_str, flag = '') ⇒ Object



14
15
16
17
18
# File 'lib/mathml2latex/xslt_functions.rb', line 14

def matches(str, regex_str, flag = '')
  str.downcase! if flag == 'i'
  regex = Regexp.new(regex_str)
  !(str =~ regex).nil?
end

#replace(str, regex_str, replacement) ⇒ Object



9
10
11
12
# File 'lib/mathml2latex/xslt_functions.rb', line 9

def replace(str, regex_str, replacement)
  regex = Regexp.new(regex_str)
  str.gsub(regex, replacement)
end