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

Cannot build site with Pygments 2.12.0 #3617

Closed
JesperDramsch opened this issue Apr 24, 2022 · 5 comments
Closed

Cannot build site with Pygments 2.12.0 #3617

JesperDramsch opened this issue Apr 24, 2022 · 5 comments
Labels

Comments

@JesperDramsch
Copy link
Contributor

Environment

Python Version:
3.10
Nikola Version:
8.2.1
Operating System:
Ubuntu (nikola action)

Description:

Nikola fails to render post with pygments code blocks on latest release 8.2.1, which used to render perfectly fine before.

  PythonAction Error
  Traceback (most recent call last):
    File "/usr/local/lib/python3.10/site-packages/pygments/__init__.py", line 61, in format
      formatter.format(tokens, realoutfile)
    File "/usr/local/lib/python3.10/site-packages/pygments/formatter.py", line 94, in format
      return self.format_unencoded(tokensource, outfile)
    File "/usr/local/lib/python3.10/site-packages/nikola/packages/pygments_better_html/__init__.py", line 222, in format_unencoded
      return super().format_unencoded(tokensource, outfile)
    File "/usr/local/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:
  
  Traceback (most recent call last):
    File "/usr/local/lib/python3.10/site-packages/doit/action.py", line 461, in execute
      returned_value = self.py_callable(*self.args, **kwargs)
    File "/usr/local/lib/python3.10/site-packages/nikola/post.py", line 729, in compile
      self.compile_html(
    File "/usr/local/lib/python3.10/site-packages/nikola/plugins/compile/rest/__init__.py", line 151, in compile
      output, error_level, deps, shortcode_deps = self.compile_string(data, source, is_two_file, post, lang)
    File "/usr/local/lib/python3.10/site-packages/nikola/plugins/compile/rest/__init__.py", line 134, in compile_string
      output, error_level, deps, _ = rst2html(
    File "/usr/local/lib/python3.10/site-packages/nikola/plugins/compile/rest/__init__.py", line 382, in rst2html
      pub.publish(enable_exit_status=enable_exit_status)
    File "/usr/local/lib/python3.10/site-packages/docutils/core.py", line 217, in publish
      self.document = self.reader.read(self.source, self.parser,
    File "/usr/local/lib/python3.10/site-packages/docutils/readers/__init__.py", line 72, in read
      self.parse()
    File "/usr/local/lib/python3.10/site-packages/docutils/readers/__init__.py", line 78, in parse
      self.parser.parse(self.input, document)
    File "/usr/local/lib/python3.10/site-packages/docutils/parsers/rst/__init__.py", line 183, in parse
      self.statemachine.run(inputlines, document, inliner=self.inliner)
    File "/usr/local/lib/python3.10/site-packages/docutils/parsers/rst/states.py", line 170, in run
      results = StateMachineWS.run(self, input_lines, input_offset,
    File "/usr/local/lib/python3.10/site-packages/docutils/statemachine.py", line 240, in run
      context, next_state, result = self.check_line(
    File "/usr/local/lib/python3.10/site-packages/docutils/statemachine.py", line 452, in check_line
      return method(match, context, next_state)
    File "/usr/local/lib/python3.10/site-packages/docutils/parsers/rst/states.py", line 2352, in explicit_markup
      nodelist, blank_finish = self.explicit_construct(match)
    File "/usr/local/lib/python3.10/site-packages/docutils/parsers/rst/states.py", line 2364, in explicit_construct
      return method(self, expmatch)
    File "/usr/local/lib/python3.10/site-packages/docutils/parsers/rst/states.py", line 2101, in directive
      return self.run_directive(
    File "/usr/local/lib/python3.10/site-packages/docutils/parsers/rst/states.py", line 2151, in run_directive
      result = directive_instance.run()
    File "/usr/local/lib/python3.10/site-packages/nikola/plugins/compile/rest/listing.py", line 134, in run
      out = pygments.highlight(code, lexer, formatter)
    File "/usr/local/lib/python3.10/site-packages/pygments/__init__.py", line 82, in highlight
      return format(lex(code, lexer), formatter, outfile)
    File "/usr/local/lib/python3.10/site-packages/pygments/__init__.py", line 69, in format
      raise TypeError('format() argument must be a formatter instance, '
  TypeError: format() argument must be a formatter instance, not a class

if this helps, this is how the code snippets look like in this one:

.. code-block:: python

   int("0111", 2)
   >>> 7
@Kwpolska Kwpolska changed the title Pygments render fail on 8.2.1 Cannot build site with Pygments 2.12.0 Apr 24, 2022
@Kwpolska Kwpolska pinned this issue Apr 24, 2022
Kwpolska added a commit that referenced this issue Apr 24, 2022
Fix #3617, fix #3618 — compatibility with Pygments 2.12.0
@dvzrv
Copy link

dvzrv commented Apr 30, 2022

@Kwpolska can you please release a bugfix version for this? :)

@Kwpolska
Copy link
Member

Kwpolska commented May 1, 2022

@dvzrv Sure, v8.2.2 is out now.

@JesperDramsch
Copy link
Contributor Author

Thanks, that worked.

@woile
Copy link
Contributor

woile commented May 11, 2022

I get a new error, seems related to this:

".../nikola/utils.py", line 1717, in nikola_find_formatter_class
    if alias.lower().contains('html'):
AttributeError: 'str' object has no attribute 'contains'
pip freeze | grep Nikola
Nikola==8.2.2

@dvzrv
Copy link

dvzrv commented May 11, 2022

@woile that is unrelated to the reported (and closed) issue though. Please open a new ticket.

@Kwpolska Kwpolska unpinned this issue Dec 14, 2022
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

4 participants