class Kramdown::Converter::Kramdown

def convert_p(el, opts)

def convert_p(el, opts)
  w = @options[:line_width] - opts[:indent].to_s.to_i
  first, second, *rest = inner(el, opts).strip.gsub(/(.{1,#{w}})( +|$\n?)/, "\\1\n").split(/\n/)
  first&.gsub!(/^(?:(#|>)|(\d+)\.(\s)|([+-]\s))/) { $1 || $4 ? "\\#{$1 || $4}" : "#{$2}\\.#{$3}" }
  second&.gsub!(/^([=-]+\s*?)$/, "\\\1")
  res = [first, second, *rest].compact.join("\n") + "\n"
  res.gsub!(/^ {0,3}:/, "\\:")
  if el.children.length == 1 && el.children.first.type == :math
    res = "\\#{res}"
  elsif res.start_with?('\$$') && res.end_with?("\\$$\n")
    res.sub!(/^\\\$\$/, '\$\$')
  end
  res
end