Module: MiniSyntax::Highlighter::CommandLine
- Defined in:
- lib/minisyntax/highlighter/command_line.rb
Class Method Summary collapse
Class Method Details
.highlight(code) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/minisyntax/highlighter/command_line.rb', line 4 def self.highlight(code) code = '<kbd>' + code.gsub(/\n/, %Q(</kbd>\n<kbd>)) + '</kbd>' code.gsub! %r((\#.*?)$) do |comment| if comment =~ %r(</q>) comment else comment.gsub! %r(</?(b|i|em|var|code|kbd)>), "" %Q(<i>#{comment}</i>) end end code.gsub! %r(<kbd><i>), "<i>" code end |