Browse code

Fixes HTML validation issues with code highlighting

Frederic Hemberger authored on 18/09/2011 at 11:55:35
Showing 3 changed files
... ...
@@ -201,7 +201,7 @@ pre, .highlight, .gist-highlight {
201 201
 }
202 202
 
203 203
 .highlight code { @extend .pre-code; background: #000;}
204
-figure[role=code] {
204
+figure.code {
205 205
   background: none;
206 206
   padding: 0;
207 207
   border: 0;
... ...
@@ -27,7 +27,7 @@ module BacktickCodeBlock
27 27
       end
28 28
       if @lang.nil? || @lang == 'plain'
29 29
         code = tableize_code(str.gsub('<','&lt;').gsub('>','&gt;'))
30
-        "<figure role=code>#{@caption}#{code}</figure>"
30
+        "<figure class='code'>#{@caption}#{code}</figure>"
31 31
       else
32 32
         if @lang.include? "-raw"
33 33
           raw = "``` #{@options.sub('-raw', '')}\n"
... ...
@@ -35,7 +35,7 @@ module BacktickCodeBlock
35 35
           raw += "\n```\n"
36 36
         else
37 37
           code = highlight(str, @lang)
38
-          "<figure role=code>#{@caption}#{code}</figure>"
38
+          "<figure class='code'>#{@caption}#{code}</figure>"
39 39
         end
40 40
       end
41 41
     end
... ...
@@ -30,12 +30,12 @@ module HighlightCode
30 30
     highlighted_code
31 31
   end
32 32
   def tableize_code (str, lang = '')
33
-    table = '<div class="highlight"><table cellpadding="0" cellspacing="0"><tr><td class="gutter"><pre class="line-numbers">'
33
+    table = '<div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers">'
34 34
     code = ''
35 35
     str.lines.each_with_index do |line,index|
36
-      table += "<span class='line'>#{index+1}</span>\n"
37
-      code  += "<div class='line'>#{line}</div>"
36
+      table += "<span class='line-number'>#{index+1}</span>\n"
37
+      code  += "<span class='line'>#{line}</span>"
38 38
     end
39
-    table += "</pre></td><td class='code' width='100%'><pre><code class='#{lang}'>#{code}</code></pre></td></tr></table></div>"
39
+    table += "</pre></td><td class='code'><pre><code class='#{lang}'>#{code}</code></pre></td></tr></table></div>"
40 40
   end
41 41
 end