You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

angular2.go 1.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. package a
  2. import (
  3. . "github.com/alecthomas/chroma" // nolint
  4. "github.com/alecthomas/chroma/lexers/internal"
  5. )
  6. // Angular2 lexer.
  7. var Angular2 = internal.Register(MustNewLexer(
  8. &Config{
  9. Name: "Angular2",
  10. Aliases: []string{"ng2"},
  11. Filenames: []string{},
  12. MimeTypes: []string{},
  13. },
  14. Rules{
  15. "root": {
  16. {`[^{([*#]+`, Other, nil},
  17. {`(\{\{)(\s*)`, ByGroups(CommentPreproc, Text), Push("ngExpression")},
  18. {`([([]+)([\w:.-]+)([\])]+)(\s*)(=)(\s*)`, ByGroups(Punctuation, NameAttribute, Punctuation, Text, Operator, Text), Push("attr")},
  19. {`([([]+)([\w:.-]+)([\])]+)(\s*)`, ByGroups(Punctuation, NameAttribute, Punctuation, Text), nil},
  20. {`([*#])([\w:.-]+)(\s*)(=)(\s*)`, ByGroups(Punctuation, NameAttribute, Punctuation, Operator), Push("attr")},
  21. {`([*#])([\w:.-]+)(\s*)`, ByGroups(Punctuation, NameAttribute, Punctuation), nil},
  22. },
  23. "ngExpression": {
  24. {`\s+(\|\s+)?`, Text, nil},
  25. {`\}\}`, CommentPreproc, Pop(1)},
  26. {`:?(true|false)`, LiteralStringBoolean, nil},
  27. {`:?"(\\\\|\\"|[^"])*"`, LiteralStringDouble, nil},
  28. {`:?'(\\\\|\\'|[^'])*'`, LiteralStringSingle, nil},
  29. {`[0-9](\.[0-9]*)?(eE[+-][0-9])?[flFLdD]?|0[xX][0-9a-fA-F]+[Ll]?`, LiteralNumber, nil},
  30. {`[a-zA-Z][\w-]*(\(.*\))?`, NameVariable, nil},
  31. {`\.[\w-]+(\(.*\))?`, NameVariable, nil},
  32. {`(\?)(\s*)([^}\s]+)(\s*)(:)(\s*)([^}\s]+)(\s*)`, ByGroups(Operator, Text, LiteralString, Text, Operator, Text, LiteralString, Text), nil},
  33. },
  34. "attr": {
  35. {`".*?"`, LiteralString, Pop(1)},
  36. {`'.*?'`, LiteralString, Pop(1)},
  37. {`[^\s>]+`, LiteralString, Pop(1)},
  38. },
  39. },
  40. ))