Sha256: 8536126cbf9b7e54bf1cfbf778eb3e5e8c3b50b56c487c660dc1d464cd417420
Contents?: true
Size: 1.67 KB
Versions: 4
Compression:
Stored size: 1.67 KB
Contents
module Rouge module Lexers class HTML < RegexLexer tag 'html' extensions 'htm', 'html' state :root do rule /[^<&]+/m, 'Text' rule /&\S*?;/, 'Name.Entity' rule /<!\[CDATA\[.*?\]\]>/m, 'Comment.Preproc' rule /<!--/, 'Comment', :comment rule /<\?.*?\?>/m, 'Comment.Preproc' # php? really? rule /<\s*script\s*/m do token 'Name.Tag' push :script_content push :tag end rule /<\s*style\s*/m do token 'Name.Tag' push :style_content push :tag end rule %r(<\s*[a-zA-Z0-9:]+), 'Name.Tag', :tag # opening tags rule %r(<\s*/\s*[a-zA-Z0-9:]+\s*>), 'Name.Tag' # closing tags end state :comment do rule /[^-]+/, 'Comment' rule /-->/, 'Comment', :pop! rule /-/, 'Comment' end state :tag do rule /\s+/m, 'Text' rule /[a-zA-Z0-9_:-]+\s*=/m, 'Name.Attribute', :attr rule /[a-zA-Z0-9_:-]+/, 'Name.Attribute' rule %r(/?\s*>)m, 'Name.Tag', :pop! end state :attr do # TODO: are backslash escapes valid here? rule /".*?"/, 'Literal.String', :pop! rule /'.*?'/, 'Literal.String', :pop! rule /[^\s>]+/, 'Literal.String', :pop! end state :script_content do rule %r(<\s*/\s*script\s*>)m, 'Name.Tag', :pop! rule %r(.*?(?=<\s*/\s*script\s*>))m do delegate JavascriptLexer end end state :style_content do rule %r(<\s*/\s*style\s*>)m, 'Name.Tag', :pop! rule %r(.*(?=<\s*/\s*style\s*>))m do delegate CSSLexer end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
rouge-0.0.6 | lib/rouge/lexers/html.rb |
rouge-0.0.5 | lib/rouge/lexers/html.rb |
rouge-0.0.4 | lib/rouge/lexers/html.rb |
rouge-0.0.3 | lib/rouge/lexers/html.rb |