class Kramdown::Parser::GFM

def add_hard_line_breaks(element)

def add_hard_line_breaks(element)
  element.children.map! do |child|
    if child.type == :text && child.value =~ /\n/
      children = []
      lines = child.value.split(/\n(?=.)/)
      lines.each_with_index do |line, index|
        children << Element.new(:text, (index > 0 ? "\n#{line}" : line))
        children << Element.new(:br) if index < lines.size - 1
      end
      children
    elsif child.type == :html_element
      child
    else
      add_hard_line_breaks(child)
      child
    end
  end.flatten!
end

def initialize(source, options)

def initialize(source, options)
  super
  @span_parsers.delete(:line_break)
  i = @block_parsers.index(:codeblock_fenced)
  @block_parsers.delete(:codeblock_fenced)
  @block_parsers.insert(i, :codeblock_fenced_gfm)
end

def parse

def parse
  super
  add_hard_line_breaks(@root) if @options[:hard_wrap]
end