diff options
author | Anteru <bitbucket@ca.sh13.net> | 2018-12-16 16:37:33 +0000 |
---|---|---|
committer | Anteru <bitbucket@ca.sh13.net> | 2018-12-16 16:37:33 +0000 |
commit | 7b32e7ccb5ade830289b0c259df83eab191b0944 (patch) | |
tree | 8e1e2e23acf64bcf8d1f7827c56370f5c58f8e9c /doc | |
parent | 59872dafd45ca9e25bd7b61afe31ca6d71aa5cd0 (diff) | |
parent | d564ab9227416838ffb0363a716fa86f20025a4d (diff) | |
download | pygments-7b32e7ccb5ade830289b0c259df83eab191b0944.tar.gz |
Merged in mortenlund/pygments-main (pull request #777)
Change ansi color names to more saying names
Approved-by: Morten E. Lund <melund@gmail.com>
Approved-by: jonathanslenders <jonathan@slenders.be>
Approved-by: Anteru <bitbucket@ca.sh13.net>
Diffstat (limited to 'doc')
-rw-r--r-- | doc/docs/styles.rst | 49 |
1 files changed, 41 insertions, 8 deletions
diff --git a/doc/docs/styles.rst b/doc/docs/styles.rst index 1094a270..cd0144ab 100644 --- a/doc/docs/styles.rst +++ b/doc/docs/styles.rst @@ -153,17 +153,17 @@ Terminal Styles .. versionadded:: 2.2 Custom styles used with the 256-color terminal formatter can also map colors to -use the 8 default ANSI colors. To do so, use ``#ansigreen``, ``#ansired`` or +use the 8 default ANSI colors. To do so, use ``ansigreen``, ``ansibrightred`` or any other colors defined in :attr:`pygments.style.ansicolors`. Foreground ANSI colors will be mapped to the corresponding `escape codes 30 to 37 <https://en.wikipedia.org/wiki/ANSI_escape_code#Colors>`_ thus respecting any custom color mapping and themes provided by many terminal emulators. Light variants are treated as foreground color with and an added bold flag. -``bg:#ansi<color>`` will also be respected, except the light variant will be the +``bg:ansi<color>`` will also be respected, except the light variant will be the same shade as their dark variant. See the following example where the color of the string ``"hello world"`` is -governed by the escape sequence ``\x1b[34;01m`` (Ansi Blue, Bold, 41 being red +governed by the escape sequence ``\x1b[34;01m`` (Ansi bright blue, Bold, 41 being red background) instead of an extended foreground & background color. .. sourcecode:: pycon @@ -176,7 +176,7 @@ background) instead of an extended foreground & background color. >>> class MyStyle(Style): styles = { - Token.String: '#ansiblue bg:#ansired', + Token.String: 'ansibrightblue bg:ansibrightred', } >>> code = 'print("Hello World")' @@ -184,18 +184,51 @@ background) instead of an extended foreground & background color. >>> print(result.encode()) b'\x1b[34;41;01m"\x1b[39;49;00m\x1b[34;41;01mHello World\x1b[39;49;00m\x1b[34;41;01m"\x1b[39;49;00m' -Colors specified using ``#ansi*`` are converted to a default set of RGB colors +Colors specified using ``ansi*`` are converted to a default set of RGB colors when used with formatters other than the terminal-256 formatter. By definition of ANSI, the following colors are considered "light" colors, and will be rendered by most terminals as bold: -- "darkgray", "red", "green", "yellow", "blue", "fuchsia", "turquoise", "white" +- "brightblack" (darkgrey), "brightred", "brightgreen", "brightyellow", "brightblue", + "brightmagenta", "brightcyan", "white" The following are considered "dark" colors and will be rendered as non-bold: -- "black", "darkred", "darkgreen", "brown", "darkblue", "purple", "teal", - "lightgray" +- "black", "red", "green", "yellow", "blue", "magenta", "cyan", + "gray" Exact behavior might depends on the terminal emulator you are using, and its settings. + +.. _NewAnsiColorNames: + +.. versionchanged:: 2.3 + +The definition of the ansi color names has changed. +New names are easier to understand and align to the colors used in other projects. + + ++-------------------------+--------------------------+ +| New names | Pygments 2.2 | ++=======================+============================+ +| ``ansiblack`` | ``#ansiblack`` | +| ``ansired`` | ``#ansidarkred`` | +| ``ansigreen`` | ``#ansidarkgreen`` | +| ``ansiyellow`` | ``#ansibrown`` | +| ``ansiblue`` | ``#ansidarkblue`` | +| ``ansimagenta`` | ``#ansipurple`` | +| ``ansicyan`` | ``#ansiteal`` | +| ``ansigray`` | ``#ansilightgray`` | +| ``ansibrightblack`` | ``#ansidarkgray`` | +| ``ansibrightred`` | ``#ansired`` | +| ``ansibrightgreen`` | ``#ansigreen`` | +| ``ansibrightyellow`` | ``#ansiyellow`` | +| ``ansibrightblue`` | ``#ansiblue`` | +| ``ansibrightmagenta`` | ``#ansifuchsia`` | +| ``ansibrightcyan`` | ``#ansiturquoise`` | +| ``ansiwhite`` | ``#ansiwhite`` | ++=========================+==========================+ + +Old ansi color names are deprecated but will still work. + |