Remove Pygments compatability code (#10812)

This commit is contained in:
Adam Turner
2022-09-09 05:08:48 +01:00
committed by GitHub
parent ff01427a0e
commit f35d2a6cc7
5 changed files with 21 additions and 71 deletions

View File

@@ -6,10 +6,8 @@ from itertools import chain, cycle
from unittest.mock import ANY, call, patch
import docutils
import pygments
import pytest
from html5lib import HTMLParser
from packaging import version
from sphinx.builders.html import validate_html_extra_path, validate_html_static_path
from sphinx.errors import ConfigError
@@ -23,9 +21,6 @@ else:
FIGURE_CAPTION = ".//figure/figcaption/p"
PYGMENTS_VERSION = version.parse(pygments.__version__).release
ENV_WARNINGS = """\
%(root)s/autodoc_fodder.py:docstring of autodoc_fodder.MarkupError:\\d+: \
WARNING: Explicit markup ends without a blank line; unexpected unindent.
@@ -1631,13 +1626,10 @@ def test_html_codeblock_linenos_style_table(app):
app.build()
content = (app.outdir / 'index.html').read_text(encoding='utf8')
if PYGMENTS_VERSION >= (2, 8):
assert ('<div class="linenodiv"><pre><span class="normal">1</span>\n'
'<span class="normal">2</span>\n'
'<span class="normal">3</span>\n'
'<span class="normal">4</span></pre></div>') in content
else:
assert '<div class="linenodiv"><pre>1\n2\n3\n4</pre></div>' in content
assert ('<div class="linenodiv"><pre><span class="normal">1</span>\n'
'<span class="normal">2</span>\n'
'<span class="normal">3</span>\n'
'<span class="normal">4</span></pre></div>') in content
@pytest.mark.sphinx('html', testroot='reST-code-block',
@@ -1646,10 +1638,7 @@ def test_html_codeblock_linenos_style_inline(app):
app.build()
content = (app.outdir / 'index.html').read_text(encoding='utf8')
if PYGMENTS_VERSION > (2, 7):
assert '<span class="linenos">1</span>' in content
else:
assert '<span class="lineno">1 </span>' in content
assert '<span class="linenos">1</span>' in content
@pytest.mark.sphinx('html', testroot='highlight_options')

View File

@@ -7,7 +7,6 @@ import os
import re
import docutils
import pygments
import pytest
from babel.messages import mofile, pofile
from babel.messages.catalog import Catalog
@@ -25,8 +24,6 @@ sphinx_intl = pytest.mark.sphinx(
},
)
pygments_version = tuple(int(v) for v in pygments.__version__.split('.'))
def read_po(pathname):
with pathname.open(encoding='utf-8') as f:
@@ -1099,13 +1096,9 @@ def test_additional_targets_should_not_be_translated(app):
assert_count(expected_expr, result, 1)
# C code block with lang should not be translated but be *C* highlighted
if pygments_version < (2, 10, 0):
expected_expr = ("""<span class="cp">#include</span> """
"""<span class="cpf">&lt;stdio.h&gt;</span>""")
else:
expected_expr = ("""<span class="cp">#include</span>"""
"""<span class="w"> </span>"""
"""<span class="cpf">&lt;stdio.h&gt;</span>""")
expected_expr = ("""<span class="cp">#include</span>"""
"""<span class="w"> </span>"""
"""<span class="cpf">&lt;stdio.h&gt;</span>""")
assert_count(expected_expr, result, 1)
# literal block in list item should not be translated
@@ -1182,13 +1175,9 @@ def test_additional_targets_should_be_translated(app):
assert_count(expected_expr, result, 1)
# C code block with lang should be translated and be *C* highlighted
if pygments_version < (2, 10, 0):
expected_expr = ("""<span class="cp">#include</span> """
"""<span class="cpf">&lt;STDIO.H&gt;</span>""")
else:
expected_expr = ("""<span class="cp">#include</span>"""
"""<span class="w"> </span>"""
"""<span class="cpf">&lt;STDIO.H&gt;</span>""")
expected_expr = ("""<span class="cp">#include</span>"""
"""<span class="w"> </span>"""
"""<span class="cpf">&lt;STDIO.H&gt;</span>""")
assert_count(expected_expr, result, 1)
# literal block in list item should be translated