class Kramdown::Utils::StringScanner

start_line_number override for nested StringScanners.
This patched StringScanner adds line number information for current scan position and a

def best_pos

def best_pos
  charpos
end

def best_pos

def best_pos
  pos
end

def current_line_number

However we add the one indirectly by using a one-based start_line_number.
NOTE: Normally we'd have to add one to the count of newlines to get the correct line number.

NOTE: Requires that all line endings are normalized to '\n'

Returns the line number for current charpos.
def current_line_number
  string[0..best_pos].count("\n") + start_line_number
end

def initialize(string, start_line_number = 1)

Note: The original second argument is no longer used so this should be safe.

Takes the start line number as optional second argument.
def initialize(string, start_line_number = 1)
  super(string)
  @start_line_number = start_line_number || 1
end