diff --git a/plugins/backtick_code_block.rb b/plugins/backtick_code_block.rb index 301d573..957ca8a 100644 --- a/plugins/backtick_code_block.rb +++ b/plugins/backtick_code_block.rb @@ -37,7 +37,12 @@ module BacktickCodeBlock else @options[:lang] ||= 'plain' end - highlight(code, @options) + + begin + highlight(code, @options) + rescue + highlight_failed(nil, code, @options[:lang]) + end end end end diff --git a/plugins/code_block.rb b/plugins/code_block.rb index 4ac596d..94feba2 100644 --- a/plugins/code_block.rb +++ b/plugins/code_block.rb @@ -78,11 +78,15 @@ module Jekyll end def render(context) - code = super.strip - code = highlight(code, @options) - code = context['pygments_prefix'] + code if context['pygments_prefix'] - code = code + context['pygments_suffix'] if context['pygments_suffix'] - code + begin + code = super.strip + code = highlight(code, @options) + code = context['pygments_prefix'] + code if context['pygments_prefix'] + code = code + context['pygments_suffix'] if context['pygments_suffix'] + code + rescue + highlight_failed(nil, code, @options[:lang]) + end end end end diff --git a/plugins/gist_tag.rb b/plugins/gist_tag.rb index 483d1c8..50e9b17 100644 --- a/plugins/gist_tag.rb +++ b/plugins/gist_tag.rb @@ -53,7 +53,11 @@ module Jekyll unless cache code = get_gist_from_web(gist, file) code = get_range(code, @options[:start], @options[:end]) - code = highlight(code, @options) + begin + code = highlight(code, @options) + rescue + highlight_failed(file, code, @options[:lang]) + end end code || cache else diff --git a/plugins/include_code.rb b/plugins/include_code.rb index 9ac2104..39b51e0 100644 --- a/plugins/include_code.rb +++ b/plugins/include_code.rb @@ -85,7 +85,11 @@ module Jekyll code = filepath.read code = get_range(code, @options[:start], @options[:end]) - highlight(code, @options) + begin + highlight(code, @options) + rescue + highlight_failed(@file, code, @options[:lang]) + end end end end