mirror of
https://github.com/moparisthebest/android.moparisthebest.org
synced 2024-11-16 06:05:00 -05:00
Rescuing errors issued by Pygments and raising our own with helpful info
This commit is contained in:
parent
66e7fb0bfb
commit
6c58529532
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user