From 00ee259a28f940503970fb6ba184aa949f2338e6 Mon Sep 17 00:00:00 2001 From: Alex Zinchenko Date: Tue, 10 Jan 2012 04:59:40 +0400 Subject: [PATCH] Proposal to rtomayko/rocco#77 --- lib/rocco.rb | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/rocco.rb b/lib/rocco.rb index 34d2935..914bdc2 100644 --- a/lib/rocco.rb +++ b/lib/rocco.rb @@ -162,10 +162,16 @@ def pygmentize? # We'll also return `text` if `pygmentize` isn't available. # # We'll memoize the result, as we'll call this a few times. + require 'rocco/comment_styles' + include CommentStyles + def detect_language + ext = File.extname(@file).slice(1..-1) @_language ||= if pygmentize? %x[pygmentize -N #{@file}].strip.split('+').first + elsif !COMMENT_STYLES[ext].nil? + ext else "text" end @@ -202,9 +208,6 @@ def detect_language # # At the moment, we're only returning `:single`. Consider this # groundwork for block comment parsing. - require 'rocco/comment_styles' - include CommentStyles - def generate_comment_chars @_commentchar ||= if COMMENT_STYLES[@options[:language]]