Last active
December 15, 2015 17:59
-
-
Save deriamis/5300533 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/plugins/pygments_code.rb b/plugins/pygments_code.rb | |
index 87d3cd6..3f2d489 100644 | |
--- a/plugins/pygments_code.rb | |
+++ b/plugins/pygments_code.rb | |
@@ -11,7 +11,9 @@ module HighlightCode | |
lang = 'objc' if lang == 'm' | |
lang = 'perl' if lang == 'pl' | |
lang = 'yaml' if lang == 'yml' | |
- str = pygments(str, lang).match(/<pre>(.+)<\/pre>/m)[1].to_s.gsub(/ *$/, '') #strip out divs <div class="highlight"> | |
+ if pygments(str, lang).match(/<pre>(.+)<\/pre>/m) != nil | |
+ str = pygments(str, lang).match(/<pre>(.+)<\/pre>/m)[1].to_s.gsub(/ *$/, '') #strip out divs <div class="highlight"> | |
+ end | |
tableize_code(str, lang) | |
end | |
@@ -22,7 +24,11 @@ module HighlightCode | |
highlighted_code = File.read(path) | |
else | |
begin | |
- highlighted_code = Pygments.highlight(code, :lexer => lang, :formatter => 'html', :options => {:encoding => 'utf-8'}) | |
+ if defined?lang && lang == 'text' | |
+ highlighted_code = code | |
+ else | |
+ highlighted_code = Pygments.highlight(code, :lexer => lang, :formatter => 'html', :options => {:encoding => 'utf-8'}) | |
+ end | |
rescue MentosError | |
raise "Pygments can't parse unknown language: #{lang}." | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment