getnikola / nikola

A static website and blog generator
https://getnikola.com/
MIT License
2.6k stars 445 forks source link

Cannot build site with Pygments 2.12.0 #3617

Closed JesperDramsch closed 2 years ago

JesperDramsch commented 2 years ago

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
dvzrv commented 2 years ago

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

Kwpolska commented 2 years ago

@dvzrv Sure, v8.2.2 is out now.

JesperDramsch commented 2 years ago

Thanks, that worked.

woile commented 2 years ago

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 commented 2 years ago

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