module Redcarpet::Render::HTMLAbbreviations
Constants
- REGEXP
Public Instance Methods
acronym_regexp(acronym)
click to toggle source
# File lib/redcarpet/render/html_abbreviations.rb, line 27 def acronym_regexp(acronym) /\b#{acronym}\b/ end
preprocess(document)
click to toggle source
# File lib/redcarpet/render/html_abbreviations.rb, line 7 def preprocess(document) abbreviations = document.scan(REGEXP) abbreviations = Hash[*abbreviations.flatten] if abbreviations.any? document.gsub!(REGEXP, "") document.rstrip! abbreviations.each do |key, value| html = <<-EOS.strip <abbr title="#{value}">#{key}</abbr> EOS document.gsub!(acronym_regexp(key), html) end end document end