From 599212e0aee7d6ce896088d2044b36471362d110 Mon Sep 17 00:00:00 2001 From: Matt Billock Date: Tue, 28 Feb 2017 20:35:58 +0200 Subject: [PATCH] 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 --- lib/multilang.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/multilang.rb b/lib/multilang.rb index 624c6e4..2eaae43 100644 --- a/lib/multilang.rb +++ b/lib/multilang.rb @@ -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