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
34 def decode(string)
35   return string unless string.respond_to?(:to_s)
36 
37   string = string.is_a?(String) ? string.dup : string.to_s
38 
39   Decode::Base.normalize(string)
40 
41   Decode::Maths.decode!(string)
42 
43   Decode::Accents.decode!(string)
44   Decode::Diacritics.decode!(string)
45   Decode::Punctuation.decode!(string)
46   Decode::Symbols.decode!(string)
47   Decode::Greek.decode!(string)
48 
49   Decode::Base.strip_braces(string)
50 
51   LaTeX.normalize_C(string)
52 end
normalize_C(string) click to toggle source
   # File lib/latex/decode/compatibility.rb
30 def self.normalize_C(string)
31   java.text.Normalizer.normalize(string, java.text.Normalizer::Form::NFC).to_s
32 end
ritex() click to toggle source
   # File lib/latex/decode/compatibility.rb
73 def self.ritex
74   Ritex::Parser.new(:mathml)
75 end
to_math_ml(string) click to toggle source
   # File lib/latex/decode/compatibility.rb
77 def self.to_math_ml(string)
78   ritex.parse string, :nowrap => true, :display => false
79 end
to_unicode(string) click to toggle source
  # File lib/latex/decode/compatibility.rb
6 def self.to_unicode(string)
7   string.gsub(/\\?u([\da-f]{4})/i) { |m| [$1.to_i(16)].pack('U') }
8 end