rouge-ruby / rouge

A pure Ruby code highlighter that is compatible with Pygments
https://rouge.jneen.net/
Other
3.3k stars 732 forks source link

Support Angular template syntax in html lexer #1940

Open eiswind opened 1 year ago

eiswind commented 1 year ago

Name of the lexer html

Code sample angular html templates may show the following attribute syntax:

#usernameFormControl="ngModel"

Additional context I could workaround by providing my own lexer with a one char change: (the hash is originally not included in the first of the two attribute rules)

state :tag do
    rule %r/\s+/m, Text
    rule %r/[\p{L}:_\[\]()*#.-][\p{Word}\p{Cf}:.·\[\]()*-]*\s*=\s*/m, Name::Attribute, :attr
    rule %r/[\p{L}:_*#-][\p{Word}\p{Cf}:.·*#-]*/, Name::Attribute
    rule %r(/?\s*>)m, Name::Tag, :pop!
  end

I know this is not plain html, but maybe this little change can be included in the html lexer.