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(), "" %Q(#{comment}) end end code end end end end MiniSyntax.register(:bash, MiniSyntax::Highlighter::Bash)