aboutsummaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorParker Moore <parkrmoore@gmail.com>2013-03-05 16:03:33 -0800
committerParker Moore <parkrmoore@gmail.com>2013-03-05 16:03:33 -0800
commit392e32bef03698f0bc8593f2eb719664bb139d82 (patch)
treeb6c5e314e1d8f1f3fca357be56ecd03212bd2c9e /plugins
parent524e337aec17b01d0815d65374ee6697eec0c4d4 (diff)
parent35e23f59ca00a04c1784180b765c3e6cc23f9a40 (diff)
downloadmy_new_personal_website-392e32bef03698f0bc8593f2eb719664bb139d82.tar.xz
my_new_personal_website-392e32bef03698f0bc8593f2eb719664bb139d82.zip
Merge pull request #990 from sjml/patch-1
Generate can fail if Pygments can't parse a code block
Diffstat (limited to 'plugins')
-rw-r--r--plugins/pygments_code.rb6
1 files changed, 5 insertions, 1 deletions
diff --git a/plugins/pygments_code.rb b/plugins/pygments_code.rb
index 1676a3e0..87d3cd6d 100644
--- a/plugins/pygments_code.rb
+++ b/plugins/pygments_code.rb
@@ -21,7 +21,11 @@ module HighlightCode
if File.exist?(path)
highlighted_code = File.read(path)
else
- highlighted_code = Pygments.highlight(code, :lexer => lang, :formatter => 'html', :options => {:encoding => 'utf-8'})
+ begin
+ highlighted_code = Pygments.highlight(code, :lexer => lang, :formatter => 'html', :options => {:encoding => 'utf-8'})
+ rescue MentosError
+ raise "Pygments can't parse unknown language: #{lang}."
+ end
File.open(path, 'w') {|f| f.print(highlighted_code) }
end
else