class Kramdown::Parser::Kramdown

def replace_abbreviations(el, regexps = nil)

Replace the abbreviation text with elements.
def replace_abbreviations(el, regexps = nil)
  return if @doc.parse_infos[:abbrev_defs].empty?
  if !regexps
    regexps = [Regexp.union(*@doc.parse_infos[:abbrev_defs].keys.map {|k| /#{Regexp.escape(k)}/})]
    regexps << /(?=(?:\W|^)#{regexps.first}(?!\w))/ # regexp should only match on word boundaries
  end
  el.children.map! do |child|
    if child.type == :text
      result = []
      strscan = StringScanner.new(child.value)
      while temp = strscan.scan_until(regexps.last)
        temp += strscan.scan(/\W|^/)
        abbr = strscan.scan(regexps.first)
        result += [Element.new(:text, temp), Element.new(:abbreviation, abbr)]
      end
      result + [Element.new(:text, extract_string(strscan.pos..-1, strscan))]
    else
      replace_abbreviations(child, regexps)
      child
    end
  end.flatten!
end