module LaTeX

Use the Java native Unicode normalizer

Use the Unicode gem

Use ActiveSupport's normalizer

Public Class Methods

decode(string) click to toggle source
# File lib/latex/decode.rb, line 34
def decode(string)
  return string unless string.respond_to?(:to_s)

  string = string.is_a?(String) ? string.dup : string.to_s

  Decode::Base.normalize(string)

  Decode::Maths.decode!(string)

  Decode::Accents.decode!(string)
  Decode::Diacritics.decode!(string)
  Decode::Punctuation.decode!(string)
  Decode::Symbols.decode!(string)
  Decode::Greek.decode!(string)

  Decode::Base.strip_braces(string)

  LaTeX.normalize_C(string)
end
normalize_C(string) click to toggle source
# File lib/latex/decode/compatibility.rb, line 30
def self.normalize_C(string)
  java.text.Normalizer.normalize(string, java.text.Normalizer::Form::NFC).to_s
end
ritex() click to toggle source
# File lib/latex/decode/compatibility.rb, line 73
def self.ritex
  Ritex::Parser.new(:mathml)
end
to_math_ml(string) click to toggle source
# File lib/latex/decode/compatibility.rb, line 77
def self.to_math_ml(string)
  ritex.parse string, :nowrap => true, :display => false
end
to_unicode(string) click to toggle source
# File lib/latex/decode/compatibility.rb, line 6
def self.to_unicode(string)
  string.gsub(/\\?u([\da-f]{4})/i) { |m| [$1.to_i(16)].pack('U') }
end