module MiniSyntax
module Highlighter
module Bash
def self.highlight(code)
code.gsub! /\$[a-z\-_]+/, "\\0"
code.gsub! /("(.*?)"|'.*?')/ do |text|
%Q(#{text})
end
code.gsub! %r((\#.*?)$) do |comment|
if comment.gsub(%r((.*?)), "\\1") =~ %r()
comment
else
comment.gsub! %r(?(b|i|em|var|code)>), ""
%Q(#{comment})
end
end
code
end
end
end
end
MiniSyntax.register(:bash, MiniSyntax::Highlighter::Bash)