Skip to content

Error reading page: format() argument must be a formatter instance, not a class #2119

@Lucas-C

Description

@Lucas-C

Hi

Since the release of pygments 2.12.0, my mkdocs-based documentation build is failing:
https://github.com/PyFPDF/fpdf2/runs/6149548887

Detailed stacktrace:

ERROR    -  Error reading page 'Development.md': format() argument must be a formatter instance, not a class
Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.10.4/x64/lib/python3.10/site-packages/pygments/__init__.py", line 61, in format
    formatter.format(tokens, realoutfile)
  File "/opt/hostedtoolcache/Python/3.10.4/x64/lib/python3.10/site-packages/pygments/formatter.py", line 94, in format
    return self.format_unencoded(tokensource, outfile)
  File "/opt/hostedtoolcache/Python/3.10.4/x64/lib/python3.10/site-packages/pygments/formatters/html.py", line 981, in format_unencoded
    source = self.wrap(source)
TypeError: BlockHtmlFormatter.wrap() missing 1 required positional argument: 'outfile'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.10.4/x64/bin/mkdocs", line 8, in <module>
    sys.exit(cli())
  File "/opt/hostedtoolcache/Python/3.10.4/x64/lib/python3.10/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/opt/hostedtoolcache/Python/3.10.4/x64/lib/python3.10/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/opt/hostedtoolcache/Python/3.10.4/x64/lib/python3.10/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/opt/hostedtoolcache/Python/3.10.4/x64/lib/python3.10/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/opt/hostedtoolcache/Python/3.10.4/x64/lib/python3.10/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/opt/hostedtoolcache/Python/3.10.4/x64/lib/python3.10/site-packages/mkdocs/__main__.py", line 192, in build_command
    build.build(config.load_config(**kwargs), dirty=not clean)
  File "/opt/hostedtoolcache/Python/3.10.4/x64/lib/python3.10/site-packages/mkdocs/commands/build.py", line 292, in build
    _populate_page(file.page, config, files, dirty)
  File "/opt/hostedtoolcache/Python/3.10.4/x64/lib/python3.10/site-packages/mkdocs/commands/build.py", line 174, in _populate_page
    page.render(config, files)
  File "/opt/hostedtoolcache/Python/3.10.4/x64/lib/python3.10/site-packages/mkdocs/structure/pages.py", line 175, in render
    self.content = md.convert(self.markdown)
  File "/opt/hostedtoolcache/Python/3.10.4/x64/lib/python3.10/site-packages/markdown/core.py", line 268, in convert
    newRoot = treeprocessor.run(root)
  File "/opt/hostedtoolcache/Python/3.10.4/x64/lib/python3.10/site-packages/pymdownx/highlight.py", line 491, in run
    code.highlight(
  File "/opt/hostedtoolcache/Python/3.10.4/x64/lib/python3.10/site-packages/pymdownx/highlight.py", line 392, in highlight
    code = highlight(src, lexer, formatter)
  File "/opt/hostedtoolcache/Python/3.10.4/x64/lib/python3.10/site-packages/pygments/__init__.py", line 82, in highlight
    return format(lex(code, lexer), formatter, outfile)
  File "/opt/hostedtoolcache/Python/3.10.4/x64/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

The Markdown document triggering this error is there: https://github.com/PyFPDF/fpdf2/blob/master/docs/Development.md

I'm going to try to reproduce this locally, and to narrow the problem to a minimal source file...

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-formattingarea: changes to formatters

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions