aboutsummaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorFrederic Hemberger <mail@frederic-hemberger.de>2011-09-18 13:55:35 +0200
committerFrederic Hemberger <mail@frederic-hemberger.de>2011-09-18 13:55:35 +0200
commit347e855ddc05c4da2f0530db436a9097d8ddbaea (patch)
treed86b0c1bc56ec36a0ebb8bc263da1101d66739f0 /plugins
parent9e5e3c5d2f52b4e67d599717ab4bacc7b6fb73a6 (diff)
downloadmy_new_personal_website-347e855ddc05c4da2f0530db436a9097d8ddbaea.tar.xz
my_new_personal_website-347e855ddc05c4da2f0530db436a9097d8ddbaea.zip
Fixes HTML validation issues with code highlighting
Diffstat (limited to 'plugins')
-rw-r--r--plugins/backtick_code_block.rb4
-rw-r--r--plugins/pygments_code.rb8
2 files changed, 6 insertions, 6 deletions
diff --git a/plugins/backtick_code_block.rb b/plugins/backtick_code_block.rb
index 7f5076df..6243de6f 100644
--- a/plugins/backtick_code_block.rb
+++ b/plugins/backtick_code_block.rb
@@ -27,7 +27,7 @@ module BacktickCodeBlock
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"
@@ -35,7 +35,7 @@ module BacktickCodeBlock
raw += "\n```\n"
else
code = highlight(str, @lang)
- "<figure role=code>#{@caption}#{code}</figure>"
+ "<figure class='code'>#{@caption}#{code}</figure>"
end
end
end
diff --git a/plugins/pygments_code.rb b/plugins/pygments_code.rb
index b87413f5..c009df9f 100644
--- a/plugins/pygments_code.rb
+++ b/plugins/pygments_code.rb
@@ -30,12 +30,12 @@ module HighlightCode
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