Fixes HTML validation issues with code highlighting
This commit is contained in:
parent
9e5e3c5d2f
commit
347e855ddc
@ -201,7 +201,7 @@ pre, .highlight, .gist-highlight {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.highlight code { @extend .pre-code; background: #000;}
|
.highlight code { @extend .pre-code; background: #000;}
|
||||||
figure[role=code] {
|
figure.code {
|
||||||
background: none;
|
background: none;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
border: 0;
|
border: 0;
|
||||||
|
@ -27,7 +27,7 @@ module BacktickCodeBlock
|
|||||||
end
|
end
|
||||||
if @lang.nil? || @lang == 'plain'
|
if @lang.nil? || @lang == 'plain'
|
||||||
code = tableize_code(str.gsub('<','<').gsub('>','>'))
|
code = tableize_code(str.gsub('<','<').gsub('>','>'))
|
||||||
"<figure role=code>#{@caption}#{code}</figure>"
|
"<figure class='code'>#{@caption}#{code}</figure>"
|
||||||
else
|
else
|
||||||
if @lang.include? "-raw"
|
if @lang.include? "-raw"
|
||||||
raw = "``` #{@options.sub('-raw', '')}\n"
|
raw = "``` #{@options.sub('-raw', '')}\n"
|
||||||
@ -35,7 +35,7 @@ module BacktickCodeBlock
|
|||||||
raw += "\n```\n"
|
raw += "\n```\n"
|
||||||
else
|
else
|
||||||
code = highlight(str, @lang)
|
code = highlight(str, @lang)
|
||||||
"<figure role=code>#{@caption}#{code}</figure>"
|
"<figure class='code'>#{@caption}#{code}</figure>"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -30,12 +30,12 @@ module HighlightCode
|
|||||||
highlighted_code
|
highlighted_code
|
||||||
end
|
end
|
||||||
def tableize_code (str, lang = '')
|
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 = ''
|
code = ''
|
||||||
str.lines.each_with_index do |line,index|
|
str.lines.each_with_index do |line,index|
|
||||||
table += "<span class='line'>#{index+1}</span>\n"
|
table += "<span class='line-number'>#{index+1}</span>\n"
|
||||||
code += "<div class='line'>#{line}</div>"
|
code += "<span class='line'>#{line}</span>"
|
||||||
end
|
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
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user