Sha256: 035e0063c4d8eacce8f3a4099579efa1fdfaf97e068b4248406834ed198c8859
Contents?: true
Size: 1.03 KB
Versions: 1
Compression:
Stored size: 1.03 KB
Contents
module MiniSyntax module Highlighter module HTML def self.highlight(code) code.gsub! %r((<script( [a-z\-]+(=("|'|\w).*?\4)?)*>)(.*?)(</script>))m do %Q(#{$1}#{MiniSyntax.highlight($5, :javascript)}#{$6}) end code.gsub! %r(<([a-z\-]+[1-6]?)(( [a-z\-]+(=".*?")?)*)( /)?>)m do tag = $1 xml_close_tag = $5 attributes = $2.gsub %r( ([a-z\-]+)(=(")(.*?)("))?)m do if %(onload onclick onmouseover onmousemove onmouseout onfocus onblur onkeyup onkeydown onkeypress).include?($1) %Q( <b>#{$1}</b>=#{$3}#{MiniSyntax.highlight($4, :javascript)}#{$3}) else %Q( <b>#{$1}</b>#{$2}) end end if $2 %Q(<b><<em>#{tag}</em></b>#{attributes}<b>#{xml_close_tag}></b>) end code.gsub! %r(</([a-z\-]+[1-6]?)>) do %Q(<b></<em>#{$1}</em>></b>) end code end end end end MiniSyntax.register(:html, MiniSyntax::Highlighter::HTML)
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
minisyntax-0.2.4 | lib/minisyntax/highlighter/html.rb |