Permalink
Browse files

Fixes HTML validation issues with code highlighting

  • Loading branch information...
fhemberger committed Sep 18, 2011
1 parent 9e5e3c5 commit 347e855ddc05c4da2f0530db436a9097d8ddbaea
Showing with 7 additions and 7 deletions.
  1. +1 −1 .themes/classic/sass/partials/_syntax.scss
  2. +2 −2 plugins/backtick_code_block.rb
  3. +4 −4 plugins/pygments_code.rb
@@ -201,7 +201,7 @@ pre, .highlight, .gist-highlight {
}
.highlight code { @extend .pre-code; background: #000;}
-figure[role=code] {
+figure.code {
background: none;
padding: 0;
border: 0;
@@ -27,15 +27,15 @@ def render_code_block(input)
end
if @lang.nil? || @lang == 'plain'
code = tableize_code(str.gsub('<','&lt;').gsub('>','&gt;'))
- "<figure role=code>#{@caption}#{code}</figure>"
+ "<figure class='code'>#{@caption}#{code}</figure>"
else
if @lang.include? "-raw"
raw = "``` #{@options.sub('-raw', '')}\n"
raw += str
raw += "\n```\n"
else
code = highlight(str, @lang)
- "<figure role=code>#{@caption}#{code}</figure>"
+ "<figure class='code'>#{@caption}#{code}</figure>"
end
end
end
View
@@ -30,12 +30,12 @@ def pygments(code, lang)
highlighted_code
end
def tableize_code (str, lang = '')
- table = '<div class="highlight"><table cellpadding="0" cellspacing="0"><tr><td class="gutter"><pre class="line-numbers">'
+ table = '<div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers">'
code = ''
str.lines.each_with_index do |line,index|
- table += "<span class='line'>#{index+1}</span>\n"
- code += "<div class='line'>#{line}</div>"
+ table += "<span class='line-number'>#{index+1}</span>\n"
+ code += "<span class='line'>#{line}</span>"
end
- table += "</pre></td><td class='code' width='100%'><pre><code class='#{lang}'>#{code}</code></pre></td></tr></table></div>"
+ table += "</pre></td><td class='code'><pre><code class='#{lang}'>#{code}</code></pre></td></tr></table></div>"
end
end

0 comments on commit 347e855

Please sign in to comment.