Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incompatibility with newer pygments version or similar(?) #3618

Closed
sfan5 opened this issue Apr 24, 2022 · 2 comments
Closed

Incompatibility with newer pygments version or similar(?) #3618

sfan5 opened this issue Apr 24, 2022 · 2 comments
Labels

Comments

@sfan5
Copy link

sfan5 commented Apr 24, 2022

Environment

Python Version: 3.10

Nikola Version: Nikola v8.2.1

Operating System: Linux

Description:

I'm not totally sure what caused this, except I upgraded everything in my virtualenv and it started happening.

Using a code block in a post (presumably) causes this exception to happen:

TaskError - taskid:render_posts:cache/posts/post-name-here.html
PythonAction Error
Traceback (most recent call last):
  File ".../venv/lib/python3.10/site-packages/pygments/__init__.py", line 61, in format
    formatter.format(tokens, realoutfile)
  File ".../venv/lib/python3.10/site-packages/pygments/formatter.py", line 94, in format
    return self.format_unencoded(tokensource, outfile)
  File ".../venv/lib/python3.10/site-packages/nikola/packages/pygments_better_html/__init__.py", line 222, in format_unencoded
    return super().format_unencoded(tokensource, outfile)
  File ".../venv/lib/python3.10/site-packages/pygments/formatters/html.py", line 981, in format_unencoded
    source = self.wrap(source)
TypeError: NikolaPygmentsHTML.wrap() missing 1 required positional argument: 'outfile'

During handling of the above exception, another exception occurred:

[...]

The following change gets rid of the exception and output looks fine:

diff --git a/nikola/utils.py b/nikola/utils.py
index e2a64a3cc..4323aa908 100644
--- a/nikola/utils.py
+++ b/nikola/utils.py
@@ -1690,7 +1690,7 @@ class NikolaPygmentsHTML(BetterHtmlFormatter):
         kwargs['nowrap'] = False
         super().__init__(**kwargs)
 
-    def wrap(self, source, outfile):
+    def wrap(self, source, *_):
         """Wrap the ``source``, which is a generator yielding individual lines, in custom generators."""
         style = []
         if self.prestyles:
@sfan5 sfan5 added the bug label Apr 24, 2022
@Kwpolska
Copy link
Member

Duplicate of #3617 (with a time difference of two minutes, so it’s not your fault or anything :))

@sfan5
Copy link
Author

sfan5 commented Apr 24, 2022

Ahhh what a coincidence 😄

Kwpolska added a commit that referenced this issue Apr 24, 2022
Fix #3617, fix #3618 — compatibility with Pygments 2.12.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants