lib/review/htmlutils.rb in review-1.4.0 vs lib/review/htmlutils.rb in review-1.5.0

- old
+ new

@@ -38,25 +38,30 @@ def escape_comment(str) str.gsub('-', '-') end + def highlight_pygments? + @book.config["pygments"].present? || + @book.config["highlight"] && @book.config["highlight"]["html"] == "pygments" + end + def highlight(ops) body = ops[:body] || '' - lexer = ops[:lexer] || '' + lexer = ops[:lexer].blank? ? 'text' : ops[:lexer] format = ops[:format] || '' + options = {:nowrap => true, :noclasses => true} + if ops[:options] && ops[:options].kind_of?(Hash) + options.merge!(ops[:options]) + end + return body if !highlight_pygments? - return body if @book.config["pygments"].nil? - begin require 'pygments' begin Pygments.highlight( unescape_html(body), - :options => { - :nowrap => true, - :noclasses => true - }, + :options => options, :formatter => format, :lexer => lexer) rescue MentosError body end