Method: Kramdown::Parser::Base#extract_string

Defined in:
lib/kramdown/parser/base.rb

#extract_string(range, strscan) ⇒ Object

Extract the part of the StringScanner strscan backed string specified by the range. This method works correctly under Ruby 1.8 and Ruby 1.9.



115
116
117
118
119
120
121
122
123
124
125
# File 'lib/kramdown/parser/base.rb', line 115

def extract_string(range, strscan)
  result = nil
  begin
    enc = strscan.string.encoding
    strscan.string.force_encoding('ASCII-8BIT')
    result = strscan.string[range].force_encoding(enc)
  ensure
    strscan.string.force_encoding(enc)
  end
  result
end