xorg.py 925 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. """
  2. pygments.lexers.xorg
  3. ~~~~~~~~~~~~~~~~~~~~
  4. Lexers for Xorg configs.
  5. :copyright: Copyright 2006-2024 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. version_added = ''
  19. tokens = {
  20. 'root': [
  21. (r'\s+', Text),
  22. (r'#.*$', Comment),
  23. (r'((?:Sub)?Section)(\s+)("\w+")',
  24. bygroups(String.Escape, Text, String.Escape)),
  25. (r'(End(?:Sub)?Section)', String.Escape),
  26. (r'(\w+)(\s+)([^\n#]+)',
  27. bygroups(Name.Builtin, Text, Name.Constant)),
  28. ],
  29. }