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.

apache.go 1.2KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. package a
  2. import (
  3. . "github.com/alecthomas/chroma" // nolint
  4. "github.com/alecthomas/chroma/lexers/internal"
  5. )
  6. // Apacheconf lexer.
  7. var Apacheconf = internal.Register(MustNewLexer(
  8. &Config{
  9. Name: "ApacheConf",
  10. Aliases: []string{"apacheconf", "aconf", "apache"},
  11. Filenames: []string{".htaccess", "apache.conf", "apache2.conf"},
  12. MimeTypes: []string{"text/x-apacheconf"},
  13. CaseInsensitive: true,
  14. },
  15. Rules{
  16. "root": {
  17. {`\s+`, Text, nil},
  18. {`(#.*?)$`, Comment, nil},
  19. {`(<[^\s>]+)(?:(\s+)(.*?))?(>)`, ByGroups(NameTag, Text, LiteralString, NameTag), nil},
  20. {`([a-z]\w*)(\s+)`, ByGroups(NameBuiltin, Text), Push("value")},
  21. {`\.+`, Text, nil},
  22. },
  23. "value": {
  24. {`\\\n`, Text, nil},
  25. {`$`, Text, Pop(1)},
  26. {`\\`, Text, nil},
  27. {`[^\S\n]+`, Text, nil},
  28. {`\d+\.\d+\.\d+\.\d+(?:/\d+)?`, LiteralNumber, nil},
  29. {`\d+`, LiteralNumber, nil},
  30. {`/([a-z0-9][\w./-]+)`, LiteralStringOther, nil},
  31. {`(on|off|none|any|all|double|email|dns|min|minimal|os|productonly|full|emerg|alert|crit|error|warn|notice|info|debug|registry|script|inetd|standalone|user|group)\b`, Keyword, nil},
  32. {`"([^"\\]*(?:\\.[^"\\]*)*)"`, LiteralStringDouble, nil},
  33. {`[^\s"\\]+`, Text, nil},
  34. },
  35. },
  36. ))