From 2a605ecc000297ca5667813f82cc78706c86c741 Mon Sep 17 00:00:00 2001 From: Danijel J Date: Fri, 18 Mar 2016 21:02:12 +1030 Subject: [PATCH] Show where pygments can't parse code Sometimes I make multiple edits to files and then when I try to `rake generate` my site I get a pygments parse error but I don't know where the file is. This will dump the code from the page that is causing the error to the stdout so the user can see which file is causing the problem and go into the file to find where the error is and repair it. I have scraped many websites using Jekyll because it's too cumbersome for me to back over many many posts looking for an error and moved back and forth to Wordpress because of this. Now that I know how to resolve this, I will no longer have to scrap whole posts and move from Markdown back to HTML. This will help future users too. --- plugins/pygments_code.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/pygments_code.rb b/plugins/pygments_code.rb index c0f4de9220f..9a7d9d20f32 100644 --- a/plugins/pygments_code.rb +++ b/plugins/pygments_code.rb @@ -24,7 +24,7 @@ def self.pygments(code, lang) begin highlighted_code = Pygments.highlight(code, :lexer => lang, :formatter => 'html', :options => {:encoding => 'utf-8', :startinline => true}) rescue MentosError - raise "Pygments can't parse unknown language: #{lang}." + raise "Pygments can't parse unknown language: #{lang}#{code}." end File.open(path, 'w') {|f| f.print(highlighted_code) } end