lib/rabbit/parser/ext/enscript.rb in rabbit-1.0.4 vs lib/rabbit/parser/ext/enscript.rb in rabbit-1.0.5
- old
+ new
@@ -1,7 +1,5 @@
-require 'nokogiri'
-
require 'rabbit/utils'
require 'rabbit/parser/ext/escape'
module Rabbit
module Parser
@@ -33,9 +31,16 @@
false
end
end
def highlight(lang, text, logger)
+ begin
+ require 'nokogiri'
+ rescue
+ logger.warning("Syntax highlight by enscript requires nokogiri.")
+ return nil
+ end
+
src_file = Tempfile.new("rabbit-enscript")
src_file.open
src_file.print(text)
src_file.close
html_file = Tempfile.new("rabbit-enscript-html")