solarized.py 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. """
  2. pygments.styles.solarized
  3. ~~~~~~~~~~~~~~~~~~~~~~~~~
  4. Solarized by Camil Staps
  5. A Pygments style for the Solarized themes (licensed under MIT).
  6. See: https://github.com/altercation/solarized
  7. :copyright: Copyright 2006-2024 by the Pygments team, see AUTHORS.
  8. :license: BSD, see LICENSE for details.
  9. """
  10. from pygments.style import Style
  11. from pygments.token import Comment, Error, Generic, Keyword, Name, Number, \
  12. Operator, String, Token
  13. __all__ = ['SolarizedLightStyle', 'SolarizedDarkStyle']
  14. def make_style(colors):
  15. return {
  16. Token: colors['base0'],
  17. Comment: 'italic ' + colors['base01'],
  18. Comment.Hashbang: colors['base01'],
  19. Comment.Multiline: colors['base01'],
  20. Comment.Preproc: 'noitalic ' + colors['magenta'],
  21. Comment.PreprocFile: 'noitalic ' + colors['base01'],
  22. Keyword: colors['green'],
  23. Keyword.Constant: colors['cyan'],
  24. Keyword.Declaration: colors['cyan'],
  25. Keyword.Namespace: colors['orange'],
  26. Keyword.Type: colors['yellow'],
  27. Operator: colors['base01'],
  28. Operator.Word: colors['green'],
  29. Name.Builtin: colors['blue'],
  30. Name.Builtin.Pseudo: colors['blue'],
  31. Name.Class: colors['blue'],
  32. Name.Constant: colors['blue'],
  33. Name.Decorator: colors['blue'],
  34. Name.Entity: colors['blue'],
  35. Name.Exception: colors['blue'],
  36. Name.Function: colors['blue'],
  37. Name.Function.Magic: colors['blue'],
  38. Name.Label: colors['blue'],
  39. Name.Namespace: colors['blue'],
  40. Name.Tag: colors['blue'],
  41. Name.Variable: colors['blue'],
  42. Name.Variable.Global:colors['blue'],
  43. Name.Variable.Magic: colors['blue'],
  44. String: colors['cyan'],
  45. String.Doc: colors['base01'],
  46. String.Regex: colors['orange'],
  47. Number: colors['cyan'],
  48. Generic: colors['base0'],
  49. Generic.Deleted: colors['red'],
  50. Generic.Emph: 'italic',
  51. Generic.Error: colors['red'],
  52. Generic.Heading: 'bold',
  53. Generic.Subheading: 'underline',
  54. Generic.Inserted: colors['green'],
  55. Generic.Output: colors['base0'],
  56. Generic.Prompt: 'bold ' + colors['blue'],
  57. Generic.Strong: 'bold',
  58. Generic.EmphStrong: 'bold italic',
  59. Generic.Traceback: colors['blue'],
  60. Error: 'bg:' + colors['red'],
  61. }
  62. DARK_COLORS = {
  63. 'base03': '#002b36',
  64. 'base02': '#073642',
  65. 'base01': '#586e75',
  66. 'base00': '#657b83',
  67. 'base0': '#839496',
  68. 'base1': '#93a1a1',
  69. 'base2': '#eee8d5',
  70. 'base3': '#fdf6e3',
  71. 'yellow': '#b58900',
  72. 'orange': '#cb4b16',
  73. 'red': '#dc322f',
  74. 'magenta': '#d33682',
  75. 'violet': '#6c71c4',
  76. 'blue': '#268bd2',
  77. 'cyan': '#2aa198',
  78. 'green': '#859900',
  79. }
  80. LIGHT_COLORS = {
  81. 'base3': '#002b36',
  82. 'base2': '#073642',
  83. 'base1': '#586e75',
  84. 'base0': '#657b83',
  85. 'base00': '#839496',
  86. 'base01': '#93a1a1',
  87. 'base02': '#eee8d5',
  88. 'base03': '#fdf6e3',
  89. 'yellow': '#b58900',
  90. 'orange': '#cb4b16',
  91. 'red': '#dc322f',
  92. 'magenta': '#d33682',
  93. 'violet': '#6c71c4',
  94. 'blue': '#268bd2',
  95. 'cyan': '#2aa198',
  96. 'green': '#859900',
  97. }
  98. class SolarizedDarkStyle(Style):
  99. """
  100. The solarized style, dark.
  101. """
  102. name = 'solarized-dark'
  103. styles = make_style(DARK_COLORS)
  104. background_color = DARK_COLORS['base03']
  105. highlight_color = DARK_COLORS['base02']
  106. line_number_color = DARK_COLORS['base01']
  107. line_number_background_color = DARK_COLORS['base02']
  108. class SolarizedLightStyle(SolarizedDarkStyle):
  109. """
  110. The solarized style, light.
  111. """
  112. name = 'solarized-light'
  113. styles = make_style(LIGHT_COLORS)
  114. background_color = LIGHT_COLORS['base03']
  115. highlight_color = LIGHT_COLORS['base02']
  116. line_number_color = LIGHT_COLORS['base01']
  117. line_number_background_color = LIGHT_COLORS['base02']