diff --git a/lib/jekyll/tags/highlight.rb b/lib/jekyll/tags/highlight.rb index f07e98b1..eb128d32 100644 --- a/lib/jekyll/tags/highlight.rb +++ b/lib/jekyll/tags/highlight.rb @@ -56,10 +56,20 @@ eos @options[:encoding] = 'utf-8' - output = add_code_tags( - Pygments.highlight(code, :lexer => @lang, :options => @options), - @lang.to_s.gsub("+", "-") - ) + highlighted_code = Pygments.highlight(code, :lexer => @lang, :options => @options) + + if highlighted_code.nil? + Jekyll.logger.error "There was an error highlighting your code:" + puts + Jekyll.logger.error code + puts + Jekyll.logger.error "While attempting to convert the above code, Pygments.rb" + + " returned an unacceptable value." + Jekyll.logger.error "This is usually a timeout problem solved by running `jekyll build` again." + raise ArgumentError.new("Pygments.rb returned an unacceptable value when attempting to highlight some code.") + end + + output = add_code_tags(highlighted_code, @lang) output = context["highlighter_prefix"] + output if context["highlighter_prefix"] output << context["highlighter_suffix"] if context["highlighter_suffix"] @@ -89,14 +99,14 @@ eos #The div is required because RDiscount blows ass <<-HTML
#{h(code).strip}
+ #{h(code).strip}
tags to code blocks
- code = code.sub(//,'')
+ code = code.sub(//,'')
code = code.sub(/<\/pre>/,"
")
end