Skip to content

Instantly share code, notes, and snippets.

View rke's full-sized avatar

Rainer Keller rke

  • driverwriter.com
  • Sacramento, CA
View GitHub Profile
require 'digest/md5'
def gfm(text)
# Extract pre blocks
extractions = {}
text.gsub!(%r{<pre>.*?</pre>}m) do |match|
md5 = Digest::MD5.hexdigest(match)
extractions[md5] = match
"{gfm-extraction-#{md5}}"
end