xorg.py 902 B

12345678910111213141516171819202122232425262728293031323334353637
  1. """
  2. pygments.lexers.xorg
  3. ~~~~~~~~~~~~~~~~~~~~
  4. Lexers for Xorg configs.
  5. :copyright: Copyright 2006-2023 by the Pygments team, see AUTHORS.
  6. :license: BSD, see LICENSE for details.
  7. """
  8. from pygments.lexer import RegexLexer, bygroups
  9. from pygments.token import Comment, String, Name, Text
  10. __all__ = ['XorgLexer']
  11. class XorgLexer(RegexLexer):
  12. """Lexer for xorg.conf files."""
  13. name = 'Xorg'
  14. url = 'https://www.x.org/wiki/'
  15. aliases = ['xorg.conf']
  16. filenames = ['xorg.conf']
  17. mimetypes = []
  18. tokens = {
  19. 'root': [
  20. (r'\s+', Text),
  21. (r'#.*$', Comment),
  22. (r'((?:Sub)?Section)(\s+)("\w+")',
  23. bygroups(String.Escape, Text, String.Escape)),
  24. (r'(End(?:Sub)?Section)', String.Escape),
  25. (r'(\w+)(\s+)([^\n#]+)',
  26. bygroups(Name.Builtin, Text, Name.Constant)),
  27. ],
  28. }