mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Patch `pygments.Formatter.__class_getitem__` in Pygments 2.17
This commit is contained in:
@@ -4,6 +4,8 @@ Release 8.0.1 (in development)
|
||||
Bugs fixed
|
||||
----------
|
||||
|
||||
* Patch ``pygments.Formatter.__class_getitem__`` in Pygments 2.17.
|
||||
Patch by Adam Turner.
|
||||
|
||||
Release 8.0.0 (released Jul 29, 2024)
|
||||
=====================================
|
||||
|
||||
@@ -6,6 +6,7 @@ from functools import partial
|
||||
from importlib import import_module
|
||||
from typing import TYPE_CHECKING, Any
|
||||
|
||||
import pygments
|
||||
from pygments import highlight
|
||||
from pygments.filters import ErrorToken
|
||||
from pygments.formatters import HtmlFormatter, LatexFormatter
|
||||
@@ -30,6 +31,11 @@ if TYPE_CHECKING:
|
||||
from pygments.lexer import Lexer
|
||||
from pygments.style import Style
|
||||
|
||||
if tuple(map(int, pygments.__version__.split('.')))[:2] < (2, 18):
|
||||
from pygments.formatter import Formatter
|
||||
|
||||
Formatter.__class_getitem__ = lambda cls, name: cls
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
lexers: dict[str, Lexer] = {}
|
||||
|
||||
@@ -2,12 +2,17 @@
|
||||
|
||||
from unittest import mock
|
||||
|
||||
import pygments
|
||||
from pygments.formatters.html import HtmlFormatter
|
||||
from pygments.lexer import RegexLexer
|
||||
from pygments.token import Name, Text
|
||||
|
||||
from sphinx.highlighting import PygmentsBridge
|
||||
|
||||
if tuple(map(int, pygments.__version__.split('.')))[:2] < (2, 18):
|
||||
from pygments.formatter import Formatter
|
||||
Formatter.__class_getitem__ = lambda cls, name: cls
|
||||
|
||||
|
||||
class MyLexer(RegexLexer):
|
||||
name = 'testlexer'
|
||||
|
||||
Reference in New Issue
Block a user