Permalink
Browse files

added xml comment support

  • Loading branch information...
1 parent d495074 commit 6c96fcb681176afb0f7cf571730a609e2970923b @hyperbolist hyperbolist committed Mar 31, 2011
Showing with 8 additions and 4 deletions.
  1. +8 −4 lib/rocco.rb
View
12 lib/rocco.rb
@@ -171,7 +171,7 @@ def pygmentize?
def detect_language
@_language ||=
if pygmentize?
- %x[pygmentize -N #{@file}].strip!
+ %x[pygmentize -N #{@file}].strip.split('+').first
else
"text"
end
@@ -247,6 +247,10 @@ def detect_language
:multi => { :start => '=begin', :middle => nil, :end => '=end' }
},
"scheme" => { :single => ";;", :multi => nil },
+ "xml" => {
+ :single => nil,
+ :multi => { :start => '<!--', :middle => nil, :end => '-->' }
+ },
}
def generate_comment_chars
@@ -390,7 +394,7 @@ def highlight(blocks)
divider_output = Regexp.new(
[ "\\n*",
span,
- Regexp.escape(front),
+ Regexp.escape(CGI.escapeHTML(front)),
' DIVIDER',
espan,
"\\n*"
@@ -402,11 +406,11 @@ def highlight(blocks)
divider_input = "\n\n#{front}\nDIVIDER\n#{back}\n\n"
divider_output = Regexp.new(
[ "\\n*",
- span, Regexp.escape(front), espan,
+ span, Regexp.escape(CGI.escapeHTML(front)), espan,
"\\n",
span, "DIVIDER", espan,
"\\n",
- span, Regexp.escape(back), espan,
+ span, Regexp.escape(CGI.escapeHTML(back)), espan,
"\\n*"
].join, Regexp::MULTILINE
)

0 comments on commit 6c96fcb

Please sign in to comment.