Fixing an issue when no language is specified (#707)

parts[0] can lead to a nil class exception. Using the ternary gives the same functionality without causing things to fail
This commit is contained in:
Matt Billock 2017-02-28 20:35:58 +02:00 committed by Robert Lord
parent f7d1bd1da5
commit 599212e0ae

View file

@ -1,7 +1,7 @@
module Multilang
def block_code(code, full_lang_name)
parts = full_lang_name.split('--')
rouge_lang_name = parts[0] || ""
rouge_lang_name = (parts) ? parts[0] : "" # just parts[0] here causes null ref exception when no language specified
super(code, rouge_lang_name).sub("highlight #{rouge_lang_name}") do |match|
match + " tab-" + full_lang_name
end