Method: Kramdown::Parser::Base#adapt_source
- Defined in:
- lib/kramdown/parser/base.rb
#adapt_source(source) ⇒ Object
Modify the string source to be usable by the parser (unifies line ending characters to \n and makes sure source ends with a new line character).
91 92 93 94 95 96 97 98 99 |
# File 'lib/kramdown/parser/base.rb', line 91 def adapt_source(source) unless source.valid_encoding? raise "The source text contains invalid characters for the used encoding #{source.encoding}" end source = source.encode('UTF-8') source.gsub!(/\r\n?/, "\n") source.chomp! source << "\n" end |