<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -1,4 +1,14 @@
+require 'digest/md5'
+
 def gfm(text)
+  # Extract pre blocks
+  extractions = {}
+  text.gsub!(%r{&lt;pre&gt;.*?&lt;/pre&gt;}m) do |match|
+    md5 = Digest::MD5.hexdigest(match)
+    extractions[md5] = match
+    &quot;{gfm-extraction-#{md5}}&quot;
+  end
+
   # prevent foo_bar_baz from ending up with an italic word in the middle
   text.gsub!(/(^(?! {4}|\t)\w+_\w+_\w[\w_]*)/) do |x|
     x.gsub('_', '\_') if x.split('').sort.to_s[0..1] == '__'
@@ -9,6 +19,11 @@ def gfm(text)
     x.gsub(/^(.+)$/, &quot;\\1  &quot;)
   end
 
+  # Insert pre block extractions
+  text.gsub!(/\{gfm-extraction-([0-9a-f]{32})\}/) do
+    extractions[$1]
+  end
+
   text
 end
 
@@ -22,6 +37,14 @@ if $0 == __FILE__
         assert_equal &quot;foo_bar&quot;, gfm(&quot;foo_bar&quot;)
       end
 
+      should &quot;not touch underscores in code blocks&quot; do
+        assert_equal &quot;    foo_bar_baz&quot;, gfm(&quot;    foo_bar_baz&quot;)
+      end
+
+      should &quot;not touch underscores in pre blocks&quot; do
+        assert_equal &quot;&lt;pre&gt;\nfoo_bar_baz\n&lt;/pre&gt;&quot;, gfm(&quot;&lt;pre&gt;\nfoo_bar_baz\n&lt;/pre&gt;&quot;)
+      end
+
       should &quot;escape two or more underscores inside words&quot; do
         assert_equal &quot;foo\\_bar\\_baz&quot;, gfm(&quot;foo_bar_baz&quot;)
       end</diff>
      <filename>code.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>5be9a3e94f39b42a3a8d4a4c7f44c9472a800431</id>
    </parent>
  </parents>
  <author>
    <name>Tom Preston-Werner</name>
    <email>tom@mojombo.com</email>
  </author>
  <url>http://github.com/github/github-flavored-markdown/commit/a28709dfc97cfec9ca7909f014562e644344b167</url>
  <id>a28709dfc97cfec9ca7909f014562e644344b167</id>
  <committed-date>2009-06-08T11:53:40-07:00</committed-date>
  <authored-date>2009-06-08T11:53:40-07:00</authored-date>
  <message>ignore pre blocks</message>
  <tree>cda4b1f339b994be70b55470f119c7bd0ab58307</tree>
  <committer>
    <name>Tom Preston-Werner</name>
    <email>tom@mojombo.com</email>
  </committer>
</commit>
