lib/rabbit/parser/ext/emacs.rb in rabbit-1.0.4 vs lib/rabbit/parser/ext/emacs.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
@@ -10,9 +8,16 @@
include Element
include GetText
module_function
def highlight(text, logger, mode_line=nil)
+ begin
+ require 'nokogiri'
+ rescue
+ logger.warning("Syntax highlight by Emacs requires nokogiri.")
+ return nil
+ end
+
src_file = Tempfile.new("rabbit-emacs")
src_file.open
src_file.print("#{mode_line}\n") if mode_line
src_file.print(text)
src_file.close