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
|
||||
highlight(code, @options)
|
||||
rescue
|
||||
highlight_failed(nil, code, @options[:lang])
|
||||
highlight_failed('backtick_code_block', "``` [lang]\n code\n ```", code, @options[:lang])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -85,7 +85,7 @@ module Jekyll
|
||||
code = code + context['pygments_suffix'] if context['pygments_suffix']
|
||||
code
|
||||
rescue
|
||||
highlight_failed(nil, code, @options[:lang])
|
||||
highlight_failed('code_block', 'codeblock [title] [url] [link text]', code, @options[:lang])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -56,7 +56,7 @@ module Jekyll
|
||||
begin
|
||||
code = highlight(code, @options)
|
||||
rescue
|
||||
highlight_failed(file, code, @options[:lang])
|
||||
highlight_failed('gist', 'gist gist_id [filename]', code, @options[:lang], file)
|
||||
end
|
||||
end
|
||||
code || cache
|
||||
|
@ -88,7 +88,7 @@ module Jekyll
|
||||
begin
|
||||
highlight(code, @options)
|
||||
rescue
|
||||
highlight_failed(@file, code, @options[:lang])
|
||||
highlight_failed('include_code', 'include_code path/to/file [title]', code, @options[:lang], filepath)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -184,13 +184,18 @@ module HighlightCode
|
||||
code
|
||||
end
|
||||
|
||||
def highlight_failed(file, code, lang)
|
||||
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 += "\nFailing code from #{file}:" if file
|
||||
fail_message += "\n\n#{code_snippet}"
|
||||
fail_message += "\n>> ..." if code.split("\n").size > 10
|
||||
$stderr.puts fail_message.red
|
||||
def highlight_failed(tag, syntax, code, lang, file = nil)
|
||||
code_snippet = code.split("\n")[0..9].map{|l| " #{l}" }.join("\n")
|
||||
fail_message = <<-MESSAGE
|
||||
Syntax Error in tag '#{tag}' while parsing the following markup in lang '#{lang}':
|
||||
#{"(Failing code from #{file})" if file}
|
||||
|
||||
#{code_snippet}
|
||||
#{" ..." if code.split("\n").size > 10}
|
||||
|
||||
Valid syntax: #{syntax}
|
||||
MESSAGE
|
||||
$stderr.puts fail_message.chomp.red
|
||||
raise ArgumentError
|
||||
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