mirror of
https://github.com/moparisthebest/android.moparisthebest.org
synced 2024-11-16 06:05:00 -05:00
#highlight_failed now accepts tag name, and proper syntax
This commit is contained in:
parent
6c58529532
commit
b456865c8c
@ -41,7 +41,7 @@ module BacktickCodeBlock
|
|||||||
begin
|
begin
|
||||||
highlight(code, @options)
|
highlight(code, @options)
|
||||||
rescue
|
rescue
|
||||||
highlight_failed(nil, code, @options[:lang])
|
highlight_failed('backtick_code_block', "``` [lang]\n code\n ```", code, @options[:lang])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -85,7 +85,7 @@ module Jekyll
|
|||||||
code = code + context['pygments_suffix'] if context['pygments_suffix']
|
code = code + context['pygments_suffix'] if context['pygments_suffix']
|
||||||
code
|
code
|
||||||
rescue
|
rescue
|
||||||
highlight_failed(nil, code, @options[:lang])
|
highlight_failed('code_block', 'codeblock [title] [url] [link text]', code, @options[:lang])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -56,7 +56,7 @@ module Jekyll
|
|||||||
begin
|
begin
|
||||||
code = highlight(code, @options)
|
code = highlight(code, @options)
|
||||||
rescue
|
rescue
|
||||||
highlight_failed(file, code, @options[:lang])
|
highlight_failed('gist', 'gist gist_id [filename]', code, @options[:lang], file)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
code || cache
|
code || cache
|
||||||
|
@ -88,7 +88,7 @@ module Jekyll
|
|||||||
begin
|
begin
|
||||||
highlight(code, @options)
|
highlight(code, @options)
|
||||||
rescue
|
rescue
|
||||||
highlight_failed(@file, code, @options[:lang])
|
highlight_failed('include_code', 'include_code path/to/file [title]', code, @options[:lang], filepath)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -184,13 +184,18 @@ module HighlightCode
|
|||||||
code
|
code
|
||||||
end
|
end
|
||||||
|
|
||||||
def highlight_failed(file, code, lang)
|
def highlight_failed(tag, syntax, code, lang, file = nil)
|
||||||
code_snippet = code.split("\n")[0..9].map{|l| ">> #{l}" }.join("\n")
|
code_snippet = code.split("\n")[0..9].map{|l| " #{l}" }.join("\n")
|
||||||
fail_message = "Pygments doesn't know how to highlight your code in lang '#{lang}'."
|
fail_message = <<-MESSAGE
|
||||||
fail_message += "\nFailing code from #{file}:" if file
|
Syntax Error in tag '#{tag}' while parsing the following markup in lang '#{lang}':
|
||||||
fail_message += "\n\n#{code_snippet}"
|
#{"(Failing code from #{file})" if file}
|
||||||
fail_message += "\n>> ..." if code.split("\n").size > 10
|
|
||||||
$stderr.puts fail_message.red
|
#{code_snippet}
|
||||||
|
#{" ..." if code.split("\n").size > 10}
|
||||||
|
|
||||||
|
Valid syntax: #{syntax}
|
||||||
|
MESSAGE
|
||||||
|
$stderr.puts fail_message.chomp.red
|
||||||
raise ArgumentError
|
raise ArgumentError
|
||||||
end
|
end
|
||||||
|
|
||||||
|
1
source/downloads/code/lolz.fsh
Normal file
1
source/downloads/code/lolz.fsh
Normal file
@ -0,0 +1 @@
|
|||||||
|
Hi hi hi lolz
|
Loading…
Reference in New Issue
Block a user