Skip to content

Commit

Permalink
Test with latest Pygments and fix related issues (#2558)
Browse files Browse the repository at this point in the history
Fixes #2557
  • Loading branch information
facelessuser authored Jan 6, 2025
1 parent 36858c6 commit 4745949
Show file tree
Hide file tree
Showing 7 changed files with 92 additions and 90 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ allow-direct-references = true

[project.optional-dependencies]
extra = [
"Pygments>=2.12"
"Pygments>=2.19.1"
]

[tool.hatch.build.targets.sdist]
Expand Down
18 changes: 9 additions & 9 deletions tests/extensions/superfences/superfences (normal).html
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@ <h1>Neseted Fences:</h1>
<span class="normal">2</span>
<span class="normal">3</span>
<span class="normal">4</span></pre></div></td><td class="code"><div><pre><span></span><code><span class="sd">&quot;&quot;&quot;Some file.&quot;&quot;&quot;</span>
<span class="kn">import</span> <span class="nn">foo.bar</span>
<span class="kn">import</span> <span class="nn">boo.baz</span>
<span class="kn">import</span> <span class="nn">foo.bar.baz</span>
<span class="kn">import</span><span class="w"> </span><span class="nn">foo.bar</span>
<span class="kn">import</span><span class="w"> </span><span class="nn">boo.baz</span>
<span class="kn">import</span><span class="w"> </span><span class="nn">foo.bar.baz</span>
</code></pre></div></td></tr></table></div>
</li>
<li>
Expand All @@ -97,9 +97,9 @@ <h1>Neseted Fences:</h1>
<span class="normal">2</span>
<span class="normal">3</span>
<span class="normal">4</span></pre></div></td><td class="code"><div><pre><span></span><code><span class="sd">&quot;&quot;&quot;Some file.&quot;&quot;&quot;</span>
<span class="hll"><span class="kn">import</span> <span class="nn">foo.bar</span>
</span><span class="hll"><span class="kn">import</span> <span class="nn">boo.baz</span>
</span><span class="kn">import</span> <span class="nn">foo.bar.baz</span>
<span class="hll"><span class="kn">import</span><span class="w"> </span><span class="nn">foo.bar</span>
</span><span class="hll"><span class="kn">import</span><span class="w"> </span><span class="nn">boo.baz</span>
</span><span class="kn">import</span><span class="w"> </span><span class="nn">foo.bar.baz</span>
</code></pre></div></td></tr></table></div>
</li>
<li>
Expand Down Expand Up @@ -131,7 +131,7 @@ <h1>Attribute List</h1>
<span class="normal">2</span>
<span class="normal">3</span>
<span class="normal">4</span></pre></div></td><td class="code"><div><pre><span></span><code><span class="sd">&quot;&quot;&quot;Some file.&quot;&quot;&quot;</span>
<span class="hll"><span class="kn">import</span> <span class="nn">foo.bar</span>
</span><span class="hll"><span class="kn">import</span> <span class="nn">boo.baz</span>
</span><span class="kn">import</span> <span class="nn">foo.bar.baz</span>
<span class="hll"><span class="kn">import</span><span class="w"> </span><span class="nn">foo.bar</span>
</span><span class="hll"><span class="kn">import</span><span class="w"> </span><span class="nn">boo.baz</span>
</span><span class="kn">import</span><span class="w"> </span><span class="nn">foo.bar.baz</span>
</code></pre></div></td></tr></table></div>
12 changes: 6 additions & 6 deletions tests/extensions/superfences/superfences (preserve tabs).html
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@ <h1>Neseted Fences:</h1>
<span class="normal">2</span>
<span class="normal">3</span>
<span class="normal">4</span></pre></div></td><td class="code"><div><pre><span></span><code><span class="sd">&quot;&quot;&quot;Some file.&quot;&quot;&quot;</span>
<span class="kn">import</span> <span class="nn">foo.bar</span>
<span class="kn">import</span> <span class="nn">boo.baz</span>
<span class="kn">import</span> <span class="nn">foo.bar.baz</span>
<span class="kn">import</span><span class="w"> </span><span class="nn">foo.bar</span>
<span class="kn">import</span><span class="w"> </span><span class="nn">boo.baz</span>
<span class="kn">import</span><span class="w"> </span><span class="nn">foo.bar.baz</span>
</code></pre></div></td></tr></table></div>
</li>
<li>
Expand All @@ -97,9 +97,9 @@ <h1>Neseted Fences:</h1>
<span class="normal">2</span>
<span class="normal">3</span>
<span class="normal">4</span></pre></div></td><td class="code"><div><pre><span></span><code><span class="sd">&quot;&quot;&quot;Some file.&quot;&quot;&quot;</span>
<span class="hll"><span class="kn">import</span> <span class="nn">foo.bar</span>
</span><span class="hll"><span class="kn">import</span> <span class="nn">boo.baz</span>
</span><span class="kn">import</span> <span class="nn">foo.bar.baz</span>
<span class="hll"><span class="kn">import</span><span class="w"> </span><span class="nn">foo.bar</span>
</span><span class="hll"><span class="kn">import</span><span class="w"> </span><span class="nn">boo.baz</span>
</span><span class="kn">import</span><span class="w"> </span><span class="nn">foo.bar.baz</span>
</code></pre></div></td></tr></table></div>
</li>
<li>
Expand Down
4 changes: 2 additions & 2 deletions tests/test_extensions/test_blocks/test_general_blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,10 +309,10 @@ def test_superfence_block(self):
''',
'''
<div>
<div class="highlight"><pre><span></span><code><span class="kn">import</span> <span class="nn">foo</span>
<div class="highlight"><pre><span></span><code><span class="kn">import</span><span class="w"> </span><span class="nn">foo</span>
</code></pre></div>
</div>
''',
''', # noqa: E501
True
)

Expand Down
44 changes: 22 additions & 22 deletions tests/test_extensions/test_highlight.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def test_auto_tile(self):
```
''',
r'''
<div class="highlight"><span class="filename">Python Console Session</span><pre><span></span><code><span class="gp">&gt;&gt;&gt; </span><span class="kn">import</span> <span class="nn">test</span>
<div class="highlight"><span class="filename">Python Console Session</span><pre><span></span><code><span class="gp">&gt;&gt;&gt; </span><span class="kn">import</span><span class="w"> </span><span class="nn">test</span>
</code></pre></div>
''', # noqa: E501
True
Expand Down Expand Up @@ -122,7 +122,7 @@ def test_auto_tile_map(self):
```
''',
r'''
<div class="highlight"><span class="filename">Python</span><pre><span></span><code><span class="gp">&gt;&gt;&gt; </span><span class="kn">import</span> <span class="nn">test</span>
<div class="highlight"><span class="filename">Python</span><pre><span></span><code><span class="gp">&gt;&gt;&gt; </span><span class="kn">import</span><span class="w"> </span><span class="nn">test</span>
</code></pre></div>
''', # noqa: E501
True
Expand Down Expand Up @@ -150,7 +150,7 @@ def test_pymdownx_inline(self):
```
''',
r'''
<div class="highlight"><pre><span></span><code><span class="linenos" data-linenos="1 "></span><span class="kn">import</span> <span class="nn">test</span>
<div class="highlight"><pre><span></span><code><span class="linenos" data-linenos="1 "></span><span class="kn">import</span><span class="w"> </span><span class="nn">test</span>
<span class="linenos" data-linenos="2 "></span><span class="n">test</span><span class="o">.</span><span class="n">test</span><span class="p">()</span>
</code></pre></div>
''', # noqa: E501
Expand Down Expand Up @@ -179,10 +179,10 @@ def test_no_class(self):
```
''',
r'''
<div><pre><span></span><code><span class="kn">import</span> <span class="nn">test</span>
<div><pre><span></span><code><span class="kn">import</span><span class="w"> </span><span class="nn">test</span>
<span class="n">test</span><span class="o">.</span><span class="n">test</span><span class="p">()</span>
</code></pre></div>
''',
''', # noqa: E501
True
)

Expand All @@ -197,10 +197,10 @@ def test_no_class_and_user_class(self):
```
''',
r'''
<div class="more"><pre><span></span><code><span class="kn">import</span> <span class="nn">test</span>
<div class="more"><pre><span></span><code><span class="kn">import</span><span class="w"> </span><span class="nn">test</span>
<span class="n">test</span><span class="o">.</span><span class="n">test</span><span class="p">()</span>
</code></pre></div>
''',
''', # noqa: E501
True
)

Expand All @@ -216,7 +216,7 @@ def test_no_class_and_user_class_linenums(self):
''',
r'''
<div class="more"><table class="table"><tr><td class="linenos"><div class="linenodiv"><pre><span></span><span class="normal">1</span>
<span class="normal">2</span></pre></div></td><td class="code"><div><pre><span></span><code><span class="kn">import</span> <span class="nn">test</span>
<span class="normal">2</span></pre></div></td><td class="code"><div><pre><span></span><code><span class="kn">import</span><span class="w"> </span><span class="nn">test</span>
<span class="n">test</span><span class="o">.</span><span class="n">test</span><span class="p">()</span>
</code></pre></div></td></tr></table></div>
''', # noqa: E501
Expand Down Expand Up @@ -431,7 +431,7 @@ def test_special(self):
```
''',
r'''
<div class="highlight"><pre><span></span><code><span class="linenos" data-linenos="1 "></span><span class="kn">import</span> <span class="nn">test</span>
<div class="highlight"><pre><span></span><code><span class="linenos" data-linenos="1 "></span><span class="kn">import</span><span class="w"> </span><span class="nn">test</span>
<span class="linenos special" data-linenos="2 "></span><span class="n">test</span><span class="o">.</span><span class="n">test</span><span class="p">()</span>
</code></pre></div>
''', # noqa: E501
Expand All @@ -449,7 +449,7 @@ def test_special_override(self):
```
''',
r'''
<div class="highlight"><pre><span></span><code><span class="linenos special" data-linenos="1 "></span><span class="kn">import</span> <span class="nn">test</span>
<div class="highlight"><pre><span></span><code><span class="linenos special" data-linenos="1 "></span><span class="kn">import</span><span class="w"> </span><span class="nn">test</span>
<span class="linenos special" data-linenos="2 "></span><span class="n">test</span><span class="o">.</span><span class="n">test</span><span class="p">()</span>
</code></pre></div>
''', # noqa: E501
Expand Down Expand Up @@ -478,10 +478,10 @@ def test_global_disable(self):
```
''',
r'''
<div class="highlight"><pre><span></span><code><span class="kn">import</span> <span class="nn">test</span>
<div class="highlight"><pre><span></span><code><span class="kn">import</span><span class="w"> </span><span class="nn">test</span>
<span class="n">test</span><span class="o">.</span><span class="n">test</span><span class="p">()</span>
</code></pre></div>
''',
''', # noqa: E501
True
)

Expand Down Expand Up @@ -538,7 +538,7 @@ def test_global_line_numbers(self):
''',
r'''
<div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span></span><span class="normal">1</span>
<span class="normal">2</span></pre></div></td><td class="code"><div><pre><span></span><code><span class="kn">import</span> <span class="nn">test</span>
<span class="normal">2</span></pre></div></td><td class="code"><div><pre><span></span><code><span class="kn">import</span><span class="w"> </span><span class="nn">test</span>
<span class="n">test</span><span class="o">.</span><span class="n">test</span><span class="p">()</span>
</code></pre></div></td></tr></table></div>
''', # noqa: E501
Expand All @@ -556,10 +556,10 @@ def test_global_disabling_of_line_numbers(self):
```
''',
r'''
<div class="highlight"><pre><span></span><code><span class="kn">import</span> <span class="nn">test</span>
<div class="highlight"><pre><span></span><code><span class="kn">import</span><span class="w"> </span><span class="nn">test</span>
<span class="n">test</span><span class="o">.</span><span class="n">test</span><span class="p">()</span>
</code></pre></div>
''',
''', # noqa: E501
True
)

Expand All @@ -584,7 +584,7 @@ def test_superfences(self):
```
''',
r'''
<div class="language-python highlight"><pre><span></span><code><span class="kn">import</span> <span class="nn">test</span>
<div class="language-python highlight"><pre><span></span><code><span class="kn">import</span><span class="w"> </span><span class="nn">test</span>
</code></pre></div>
''', # noqa: E501
True
Expand All @@ -598,7 +598,7 @@ def test_inlinehilite(self):
`#!python import test`
''',
'''
<p><code class="language-python highlight"><span class="kn">import</span> <span class="nn">test</span></code></p>
<p><code class="language-python highlight"><span class="kn">import</span><span class="w"> </span><span class="nn">test</span></code></p>
''', # noqa: E501
True
)
Expand Down Expand Up @@ -687,11 +687,11 @@ def test_default_block(self):
''',
'''
<p><code>import code</code></p>
<div class="highlight"><pre><span></span><code><span class="kn">import</span> <span class="nn">code</span>
<div class="highlight"><pre><span></span><code><span class="kn">import</span><span class="w"> </span><span class="nn">code</span>
</code></pre></div>
<div class="highlight"><pre><span></span><code><span class="kn">import</span> <span class="nn">code</span>
<div class="highlight"><pre><span></span><code><span class="kn">import</span><span class="w"> </span><span class="nn">code</span>
</code></pre></div>
''',
''', # noqa: E501
True
)

Expand Down Expand Up @@ -720,11 +720,11 @@ def test_default_inline(self):
```
''',
'''
<p><code class="highlight"><span class="kn">import</span> <span class="nn">code</span></code></p>
<p><code class="highlight"><span class="kn">import</span><span class="w"> </span><span class="nn">code</span></code></p>
<div class="highlight"><pre><span></span><code>import code
</code></pre></div>
<div class="highlight"><pre><span></span><code>import code
</code></pre></div>
''',
''', # noqa: E501
True
)
16 changes: 9 additions & 7 deletions tests/test_extensions/test_inlinehilite.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,15 @@ def test_language(self):
# Test #! original syntax
self.check_markdown(
r'`#!python import module`.',
r'<p><code class="inlinehilite"><span class="kn">import</span> <span class="nn">module</span></code>.</p>'
R'<p><code class="inlinehilite">'
R'<span class="kn">import</span><span class="w"> </span><span class="nn">module</span>'
R'</code>.</p>'
)

# Test ::: syntax
self.check_markdown(
r'`:::python import module`.',
r'<p><code class="inlinehilite"><span class="kn">import</span> <span class="nn">module</span></code>.</p>'
r'<p><code class="inlinehilite"><span class="kn">import</span><span class="w"> </span><span class="nn">module</span></code>.</p>' # noqa: E501
)

# Test escaping language with space
Expand Down Expand Up @@ -105,8 +107,8 @@ def test_attributes(self):
self.check_markdown(
r'`#!python import module`{: .test}',
r'<p><code class="inlinehilite test">'
r'<span class="kn">import</span> <span class="nn">module</span>'
r'</code></p>'
'<span class="kn">import</span><span class="w"> </span><span class="nn">module</span>'
'</code></p>'
)


Expand Down Expand Up @@ -150,7 +152,7 @@ def test_no_class(self):

self.check_markdown(
r'Lets test inline highlight no guessing and no text styling `#!python import module`.',
r'<p>Lets test inline highlight no guessing and no text styling <code><span class="kn">import</span> <span class="nn">module</span></code>.</p>' # noqa: E501
r'<p>Lets test inline highlight no guessing and no text styling <code><span class="kn">import</span><span class="w"> </span><span class="nn">module</span></code>.</p>' # noqa: E501
)


Expand Down Expand Up @@ -305,13 +307,13 @@ def test_codehilite(self):
# Test #! original syntax
self.check_markdown(
r'`#!python import module`.',
r'<p><code class="highlight"><span class="kn">import</span> <span class="nn">module</span></code>.</p>'
r'<p><code class="highlight"><span class="kn">import</span><span class="w"> </span><span class="nn">module</span></code>.</p>' # noqa: E501
)

# Test ::: syntax
self.check_markdown(
r'`:::python import module`.',
r'<p><code class="highlight"><span class="kn">import</span> <span class="nn">module</span></code>.</p>'
r'<p><code class="highlight"><span class="kn">import</span><span class="w"> </span><span class="nn">module</span></code>.</p>' # noqa: E501
)

# Test escaping language with space
Expand Down
Loading

0 comments on commit 4745949

Please sign in to comment.