Error in documentation for the token Keyword.Constant

Issue #1427 new
created an issue


It seems there's an error in the documentation regarding the builtin tokens. In this page, we can see:


However, Keyword.Constant doesn't seem to affect the keyword None in Python. Name.Builtin does.

Here's an example code:

from pygments import highlight
from pygments.lexers import get_lexer_by_name
from pygments.formatters import ImageFormatter
from io import BytesIO
from PIL import Image
from import Style
from pygments.token import Keyword, Name

class Style1(Style):
    styles = {
        Keyword.Constant: "#ff0000"

class Style2(Style):
    styles = {
        Name.Builtin: "#ff0000"

code = "a = None"

lexer = get_lexer_by_name("python")

formatter_1 = ImageFormatter(style=Style1)
formatter_2 = ImageFormatter(style=Style2)

result_1 = highlight(code, lexer, formatter_1)
result_2 = highlight(code, lexer, formatter_2)

im_1 =
im_2 ="image_1.png")"image_2.png")

Here's image_1.png: image_1.png

Here's image_2.png: image_2.png

Comments (1)

  1. Log in to comment