class Kramdown::Utils::StringScanner

def pos=(pos)

and don't use any other method for that!
Note: This also resets some internal variables, so always use pos= when setting the position

Sets the byte position of the scan pointer.
def pos=(pos)
  if self.pos > pos
    @previous_line_number = @start_line_number
    @previous_pos = 0
  end
  super
end