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