Module: LaTeX
- Defined in:
- lib/latex/decode/compatibility.rb,
lib/latex/decode.rb,
lib/latex/decode/base.rb,
lib/latex/decode/greek.rb,
lib/latex/decode/maths.rb,
lib/latex/decode/accents.rb,
lib/latex/decode/symbols.rb,
lib/latex/decode/version.rb,
lib/latex/decode/diacritics.rb,
lib/latex/decode/punctuation.rb,
lib/latex/decode/compatibility.rb,
lib/latex/decode/compatibility.rb,
lib/latex/decode/compatibility.rb,
lib/latex/decode/compatibility.rb
Overview
Use the Java native Unicode normalizer
Defined Under Namespace
Modules: Decode
Class Method Summary collapse
Class Method Details
.decode(string) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# 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) ⇒ Object
30 31 32 |
# 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 |
.to_unicode(string) ⇒ Object
6 7 8 |
# 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 |