summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorflywire <flywire0@gmail.com>2022-07-26 18:16:34 +1000
committerGitHub <noreply@github.com>2022-07-26 10:16:34 +0200
commitf162631a2504b63799c9466f12072f9fd14611b1 (patch)
tree8b98619e7b4800a546847dea4e0b437d5cf68e3a
parentc9fb3360ba822bb5b406ba12ab30a30db535c421 (diff)
downloadpygments-git-f162631a2504b63799c9466f12072f9fd14611b1.tar.gz
Register new style (#2183)
* Register new style * Replace default_style with Token #2184 * Remove default_style from styles * Simplify register style code
-rw-r--r--doc/docs/styledevelopment.rst30
-rw-r--r--pygments/styles/abap.py2
-rw-r--r--pygments/styles/algol.py1
-rw-r--r--pygments/styles/algol_nu.py1
-rw-r--r--pygments/styles/arduino.py1
-rw-r--r--pygments/styles/autumn.py2
-rw-r--r--pygments/styles/borland.py2
-rw-r--r--pygments/styles/bw.py1
-rw-r--r--pygments/styles/colorful.py2
-rw-r--r--pygments/styles/default.py1
-rw-r--r--pygments/styles/dracula.py1
-rw-r--r--pygments/styles/emacs.py1
-rw-r--r--pygments/styles/friendly.py1
-rw-r--r--pygments/styles/friendly_grayscale.py1
-rw-r--r--pygments/styles/igor.py1
-rw-r--r--pygments/styles/inkpot.py3
-rw-r--r--pygments/styles/lilypond.py2
-rw-r--r--pygments/styles/lovelace.py2
-rw-r--r--pygments/styles/material.py1
-rw-r--r--pygments/styles/murphy.py2
-rw-r--r--pygments/styles/paraiso_dark.py2
-rw-r--r--pygments/styles/paraiso_light.py2
-rw-r--r--pygments/styles/pastie.py2
-rw-r--r--pygments/styles/perldoc.py1
-rw-r--r--pygments/styles/sas.py2
-rw-r--r--pygments/styles/stata_dark.py2
-rw-r--r--pygments/styles/stata_light.py1
-rw-r--r--pygments/styles/tango.py1
-rw-r--r--pygments/styles/trac.py2
-rw-r--r--pygments/styles/vim.py1
-rw-r--r--pygments/styles/vs.py1
-rw-r--r--pygments/styles/xcode.py2
-rw-r--r--pygments/styles/zenburn.py2
33 files changed, 22 insertions, 57 deletions
diff --git a/doc/docs/styledevelopment.rst b/doc/docs/styledevelopment.rst
index 01838699..b75465bf 100644
--- a/doc/docs/styledevelopment.rst
+++ b/doc/docs/styledevelopment.rst
@@ -11,38 +11,44 @@ define some styles:
.. sourcecode:: python
from pygments.style import Style
- from pygments.token import Keyword, Name, Comment, String, Error, \
- Number, Operator, Generic
+ from pygments.token import Token, Comment, Keyword, Name, String, \
+ Error, Generic, Number, Operator
+
class YourStyle(Style):
- default_style = ""
+
styles = {
+ Token: '',
Comment: 'italic #888',
Keyword: 'bold #005',
Name: '#f00',
- Name.Function: '#0f0',
Name.Class: 'bold #0f0',
+ Name.Function: '#0f0',
String: 'bg:#eee #111'
}
-That's it. There are just a few rules. When you define a style for `Name`
+That's it, save it as ``your.py``. There are just a few rules. When you define a style for `Name`
the style automatically also affects `Name.Function` and so on. If you
defined ``'bold'`` and you don't want boldface for a subtoken use ``'nobold'``.
(Philosophy: the styles aren't written in CSS syntax since this way
they can be used for a variety of formatters.)
-`default_style` is the style inherited by all token types.
+``Token`` is the default style inherited by all token types.
To make the style usable for Pygments, you must
* either register it as a plugin (see :doc:`the plugin docs <plugins>`)
-* or drop it into the `styles` subpackage of your Pygments distribution one style
- class per style, where the file name is the style name and the class name is
- `StylenameClass`. For example, if your style should be called
- ``"mondrian"``, name the class `MondrianStyle`, put it into the file
- ``mondrian.py`` and this file into the ``pygments.styles`` subpackage
- directory.
+* or update the ``pygments.styles`` subpackage directory. For example:
+
+ * add ``your.py`` file
+ * register the new style by adding a line to the ``__init__.py`` file:
+
+ .. sourcecode:: python
+
+ STYLE_MAP = {
+ ...
+ 'your': 'your::YourStyle',
Style Rules
diff --git a/pygments/styles/abap.py b/pygments/styles/abap.py
index 8629e66c..61a84e44 100644
--- a/pygments/styles/abap.py
+++ b/pygments/styles/abap.py
@@ -14,7 +14,7 @@ from pygments.token import Keyword, Name, Comment, String, Error, \
class AbapStyle(Style):
- default_style = ""
+
styles = {
Comment: 'italic #888',
Comment.Special: '#888',
diff --git a/pygments/styles/algol.py b/pygments/styles/algol.py
index d6b4926a..e2d87967 100644
--- a/pygments/styles/algol.py
+++ b/pygments/styles/algol.py
@@ -36,7 +36,6 @@ from pygments.token import Keyword, Name, Comment, String, Error, Operator
class AlgolStyle(Style):
background_color = "#ffffff"
- default_style = ""
styles = {
Comment: "italic #888",
diff --git a/pygments/styles/algol_nu.py b/pygments/styles/algol_nu.py
index 68bdb7ec..f47884db 100644
--- a/pygments/styles/algol_nu.py
+++ b/pygments/styles/algol_nu.py
@@ -36,7 +36,6 @@ from pygments.token import Keyword, Name, Comment, String, Error, Operator
class Algol_NuStyle(Style):
background_color = "#ffffff"
- default_style = ""
styles = {
Comment: "italic #888",
diff --git a/pygments/styles/arduino.py b/pygments/styles/arduino.py
index 08782c73..a86ab05a 100644
--- a/pygments/styles/arduino.py
+++ b/pygments/styles/arduino.py
@@ -20,7 +20,6 @@ class ArduinoStyle(Style):
"""
background_color = "#ffffff"
- default_style = ""
styles = {
Whitespace: "", # class: 'w'
diff --git a/pygments/styles/autumn.py b/pygments/styles/autumn.py
index 878b55d5..7310a114 100644
--- a/pygments/styles/autumn.py
+++ b/pygments/styles/autumn.py
@@ -18,8 +18,6 @@ class AutumnStyle(Style):
A colorful style, inspired by the terminal highlighting style.
"""
- default_style = ""
-
styles = {
Whitespace: '#bbbbbb',
diff --git a/pygments/styles/borland.py b/pygments/styles/borland.py
index ecdff617..84cde2b7 100644
--- a/pygments/styles/borland.py
+++ b/pygments/styles/borland.py
@@ -18,8 +18,6 @@ class BorlandStyle(Style):
Style similar to the style used in the borland IDEs.
"""
- default_style = ''
-
styles = {
Whitespace: '#bbbbbb',
diff --git a/pygments/styles/bw.py b/pygments/styles/bw.py
index 3a92d82c..01e4a9c4 100644
--- a/pygments/styles/bw.py
+++ b/pygments/styles/bw.py
@@ -16,7 +16,6 @@ from pygments.token import Keyword, Name, Comment, String, Error, \
class BlackWhiteStyle(Style):
background_color = "#ffffff"
- default_style = ""
styles = {
Comment: "italic",
diff --git a/pygments/styles/colorful.py b/pygments/styles/colorful.py
index ad7b0828..0ce69e44 100644
--- a/pygments/styles/colorful.py
+++ b/pygments/styles/colorful.py
@@ -18,8 +18,6 @@ class ColorfulStyle(Style):
A colorful style, inspired by CodeRay.
"""
- default_style = ""
-
styles = {
Whitespace: "#bbbbbb",
diff --git a/pygments/styles/default.py b/pygments/styles/default.py
index 531f9565..d51dbe89 100644
--- a/pygments/styles/default.py
+++ b/pygments/styles/default.py
@@ -19,7 +19,6 @@ class DefaultStyle(Style):
"""
background_color = "#f8f8f8"
- default_style = ""
styles = {
Whitespace: "#bbbbbb",
diff --git a/pygments/styles/dracula.py b/pygments/styles/dracula.py
index 0b75efe5..e977bb45 100644
--- a/pygments/styles/dracula.py
+++ b/pygments/styles/dracula.py
@@ -20,7 +20,6 @@ from pygments.token import (
class DraculaStyle(Style):
- default_style = ""
background_color = "#282a36"
highlight_color = "#44475a"
line_number_color = "#f1fa8c"
diff --git a/pygments/styles/emacs.py b/pygments/styles/emacs.py
index d0a8cb67..6f46b47a 100644
--- a/pygments/styles/emacs.py
+++ b/pygments/styles/emacs.py
@@ -19,7 +19,6 @@ class EmacsStyle(Style):
"""
background_color = "#f8f8f8"
- default_style = ""
styles = {
Whitespace: "#bbbbbb",
diff --git a/pygments/styles/friendly.py b/pygments/styles/friendly.py
index c8a94a9e..27a4f6e9 100644
--- a/pygments/styles/friendly.py
+++ b/pygments/styles/friendly.py
@@ -19,7 +19,6 @@ class FriendlyStyle(Style):
"""
background_color = "#f0f0f0"
- default_style = ""
line_number_color = "#666666"
styles = {
diff --git a/pygments/styles/friendly_grayscale.py b/pygments/styles/friendly_grayscale.py
index 58b09c91..76201f25 100644
--- a/pygments/styles/friendly_grayscale.py
+++ b/pygments/styles/friendly_grayscale.py
@@ -24,7 +24,6 @@ class FriendlyGrayscaleStyle(Style):
"""
background_color = "#f0f0f0"
- default_style = ""
styles = {
Whitespace: "#bbbbbb",
diff --git a/pygments/styles/igor.py b/pygments/styles/igor.py
index a38481ba..c5fc490b 100644
--- a/pygments/styles/igor.py
+++ b/pygments/styles/igor.py
@@ -16,7 +16,6 @@ class IgorStyle(Style):
"""
Pygments version of the official colors for Igor Pro procedures.
"""
- default_style = ""
styles = {
Comment: 'italic #FF0000',
diff --git a/pygments/styles/inkpot.py b/pygments/styles/inkpot.py
index 891c7223..cf3769d6 100644
--- a/pygments/styles/inkpot.py
+++ b/pygments/styles/inkpot.py
@@ -14,8 +14,9 @@ from pygments.token import Text, Other, Keyword, Name, Comment, String, \
class InkPotStyle(Style):
+
background_color = "#1e1e27"
- default_style = ""
+
styles = {
Text: "#cfbfad",
Other: "#cfbfad",
diff --git a/pygments/styles/lilypond.py b/pygments/styles/lilypond.py
index 7fce7bea..b8996746 100644
--- a/pygments/styles/lilypond.py
+++ b/pygments/styles/lilypond.py
@@ -22,8 +22,6 @@ class LilyPondStyle(Style):
# input only and doesn't show good output on Python code.
web_style_gallery_exclude = True
- default_style = "#0000ff"
-
styles = {
Token.Text: "",
Token.Keyword: "bold",
diff --git a/pygments/styles/lovelace.py b/pygments/styles/lovelace.py
index ca83135c..6beedc56 100644
--- a/pygments/styles/lovelace.py
+++ b/pygments/styles/lovelace.py
@@ -33,8 +33,6 @@ class LovelaceStyle(Style):
_LABEL_CYAN = '#289870'
_EXCEPT_YELLOW = '#908828'
- default_style = '#222222'
-
styles = {
Whitespace: '#a89028',
Comment: 'italic #888888',
diff --git a/pygments/styles/material.py b/pygments/styles/material.py
index 8acb3bc6..7f4e7500 100644
--- a/pygments/styles/material.py
+++ b/pygments/styles/material.py
@@ -35,7 +35,6 @@ class MaterialStyle(Style):
foreground = '#EEFFFF'
faded = '#546E7A'
- default_style = ""
background_color = dark_teal
highlight_color = '#2C3B41'
line_number_color = '#37474F'
diff --git a/pygments/styles/murphy.py b/pygments/styles/murphy.py
index e07c755b..67f4dda7 100644
--- a/pygments/styles/murphy.py
+++ b/pygments/styles/murphy.py
@@ -18,8 +18,6 @@ class MurphyStyle(Style):
Murphy's style from CodeRay.
"""
- default_style = ""
-
styles = {
Whitespace: "#bbbbbb",
Comment: "#666 italic",
diff --git a/pygments/styles/paraiso_dark.py b/pygments/styles/paraiso_dark.py
index 6f200bf4..06675b73 100644
--- a/pygments/styles/paraiso_dark.py
+++ b/pygments/styles/paraiso_dark.py
@@ -33,8 +33,6 @@ PURPLE = "#815ba4"
class ParaisoDarkStyle(Style):
- default_style = ''
-
background_color = BACKGROUND
highlight_color = SELECTION
diff --git a/pygments/styles/paraiso_light.py b/pygments/styles/paraiso_light.py
index bc164f07..e353daa7 100644
--- a/pygments/styles/paraiso_light.py
+++ b/pygments/styles/paraiso_light.py
@@ -33,8 +33,6 @@ PURPLE = "#815ba4"
class ParaisoLightStyle(Style):
- default_style = ''
-
background_color = BACKGROUND
highlight_color = SELECTION
diff --git a/pygments/styles/pastie.py b/pygments/styles/pastie.py
index 41814e27..de327b34 100644
--- a/pygments/styles/pastie.py
+++ b/pygments/styles/pastie.py
@@ -20,8 +20,6 @@ class PastieStyle(Style):
Style similar to the pastie default style.
"""
- default_style = ''
-
styles = {
Whitespace: '#bbbbbb',
Comment: '#888888',
diff --git a/pygments/styles/perldoc.py b/pygments/styles/perldoc.py
index eaea0abc..6e415de8 100644
--- a/pygments/styles/perldoc.py
+++ b/pygments/styles/perldoc.py
@@ -21,7 +21,6 @@ class PerldocStyle(Style):
"""
background_color = '#eeeedd'
- default_style = ''
styles = {
Whitespace: '#bbbbbb',
diff --git a/pygments/styles/sas.py b/pygments/styles/sas.py
index b64b14b5..0748933a 100644
--- a/pygments/styles/sas.py
+++ b/pygments/styles/sas.py
@@ -22,8 +22,6 @@ class SasStyle(Style):
program editor syntax highlighting.
"""
- default_style = ''
-
styles = {
Whitespace: '#bbbbbb',
Comment: 'italic #008800',
diff --git a/pygments/styles/stata_dark.py b/pygments/styles/stata_dark.py
index c05f962e..29ae051c 100644
--- a/pygments/styles/stata_dark.py
+++ b/pygments/styles/stata_dark.py
@@ -17,8 +17,6 @@ from pygments.token import Token, Keyword, Name, Comment, String, Error, \
class StataDarkStyle(Style):
- default_style = ''
-
background_color = "#232629"
highlight_color = "#49483e"
diff --git a/pygments/styles/stata_light.py b/pygments/styles/stata_light.py
index c97fef12..9e9dae6b 100644
--- a/pygments/styles/stata_light.py
+++ b/pygments/styles/stata_light.py
@@ -20,7 +20,6 @@ class StataLightStyle(Style):
meant to be a complete style, just for use with Stata.
"""
- default_style = ''
styles = {
Text: '#111111',
Whitespace: '#bbbbbb',
diff --git a/pygments/styles/tango.py b/pygments/styles/tango.py
index 7012a341..694e6588 100644
--- a/pygments/styles/tango.py
+++ b/pygments/styles/tango.py
@@ -50,7 +50,6 @@ class TangoStyle(Style):
# work in progress...
background_color = "#f8f8f8"
- default_style = ""
styles = {
# No corresponding class for the following:
diff --git a/pygments/styles/trac.py b/pygments/styles/trac.py
index 0885ced8..3d5e20e5 100644
--- a/pygments/styles/trac.py
+++ b/pygments/styles/trac.py
@@ -18,8 +18,6 @@ class TracStyle(Style):
Port of the default trac highlighter design.
"""
- default_style = ''
-
styles = {
Whitespace: '#bbbbbb',
Comment: 'italic #999988',
diff --git a/pygments/styles/vim.py b/pygments/styles/vim.py
index 074a37bb..ba87c537 100644
--- a/pygments/styles/vim.py
+++ b/pygments/styles/vim.py
@@ -20,7 +20,6 @@ class VimStyle(Style):
background_color = "#000000"
highlight_color = "#222222"
- default_style = "#cccccc"
styles = {
Token: "#cccccc",
diff --git a/pygments/styles/vs.py b/pygments/styles/vs.py
index 01a51c0d..bfc470b4 100644
--- a/pygments/styles/vs.py
+++ b/pygments/styles/vs.py
@@ -16,7 +16,6 @@ from pygments.token import Keyword, Name, Comment, String, Error, \
class VisualStudioStyle(Style):
background_color = "#ffffff"
- default_style = ""
styles = {
Comment: "#008000",
diff --git a/pygments/styles/xcode.py b/pygments/styles/xcode.py
index e1ac936f..13b3d13a 100644
--- a/pygments/styles/xcode.py
+++ b/pygments/styles/xcode.py
@@ -18,8 +18,6 @@ class XcodeStyle(Style):
Style similar to the Xcode default colouring theme.
"""
- default_style = ''
-
styles = {
Comment: '#177500',
Comment.Preproc: '#633820',
diff --git a/pygments/styles/zenburn.py b/pygments/styles/zenburn.py
index 1bebb1d9..016ce0d4 100644
--- a/pygments/styles/zenburn.py
+++ b/pygments/styles/zenburn.py
@@ -23,13 +23,13 @@ class ZenburnStyle(Style):
Low contrast Zenburn style.
"""
- default_style = ""
background_color = '#3f3f3f'
highlight_color = '#484848'
line_number_color = '#5d6262'
line_number_background_color = '#353535'
line_number_special_color = '#7a8080'
line_number_special_background_color = '#353535'
+
styles = {
Token: '#dcdccc',
Error: '#e37170 bold',