module LaTeX::Decode::Base

Public Instance Methods

normalize(string) click to toggle source
   # File lib/latex/decode/base.rb
34 def normalize(string)
35   string.gsub!(/\\(?:i|j)\b/) { |m| m == '\\i' ? 'ı' : 'ȷ' }
36 
37   # \foo\ bar -> \foo{} bar
38   string.gsub!(/(\\[a-zA-Z]+)\\(\s+)/, '\1{}\2')
39 
40   # Aaaa\o, -> Aaaa\o{},
41   string.gsub!(/([^{]\\\w)([;,.:%])/, '\1{}\2')
42 
43   # \c cb -> \c{cb}
44   string.gsub!(/(\\[^\sij&#\$\{\}_~%])\s+([[:alpha:]]+)\b/i, '\1{\2}')
45 
46   # non-breaking spaces
47   string.gsub!(/(\A|[^\\])~/, LaTeX.to_unicode("\\1\u00a0"))
48 
49   string
50 end
strip_braces(string) click to toggle source
   # File lib/latex/decode/base.rb
52 def strip_braces(string)
53   string.gsub!(/(^|[^\\])([\{\}]+)/, '\1')
54   string.gsub!(/\\(\{|\})/, '\1')
55   string
56 end