Repository navigation
Description
We encountered a bug when building our HTML documentation via mkdocs build.
It seems that the README.md could not be parsed anymore.
The README.md was not changed.
The only change was upgrading to the new pygements version 2.20.0 as part of our automated regression tests.
After pining the version to 2.19.2 the build is not failing anymore.
ERROR - Error reading page 'README.md': 'NoneType' object has no attribute 'replace'
Traceback (most recent call last):
File "<frozen runpy>", line 198, in _run_module_as_main
File "<frozen runpy>", line 88, in _run_code
File "C:\Users\<User>\AppData\Local\pypoetry\Cache\virtualenvs\<lib-env>-py3.12\Scripts\mkdocs.exe\__main__.py", line 7, in <module>
File "C:\Users\<User>\AppData\Local\pypoetry\Cache\virtualenvs\<lib-env>-py3.12\Lib\site-packages\click\core.py", line 1485, in __call__
return self.main(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\<User>\AppData\Local\pypoetry\Cache\virtualenvs\<lib-env>-py3.12\Lib\site-packages\click\core.py", line 1406, in main
rv = self.invoke(ctx)
^^^^^^^^^^^^^^^^
File "C:\Users\<User>\AppData\Local\pypoetry\Cache\virtualenvs\<lib-env>-py3.12\Lib\site-packages\click\core.py", line 1873, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\<User>\AppData\Local\pypoetry\Cache\virtualenvs\<lib-env>-py3.12\Lib\site-packages\click\core.py", line 1269, in invoke
return ctx.invoke(self.callback, **ctx.params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\<User>\AppData\Local\pypoetry\Cache\virtualenvs\<lib-env>-py3.12\Lib\site-packages\click\core.py", line 824, in invoke
return callback(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\<User>\AppData\Local\pypoetry\Cache\virtualenvs\<lib-env>-py3.12\Lib\site-packages\mkdocs\__main__.py", line 288, in build_command
build.build(cfg, dirty=not clean)
File "C:\Users\<User>\AppData\Local\pypoetry\Cache\virtualenvs\<lib-env>-py3.12\Lib\site-packages\mkdocs\commands\build.py", line 310, in build
_populate_page(file.page, config, files, dirty)
File "C:\Users\<User>\AppData\Local\pypoetry\Cache\virtualenvs\<lib-env>-py3.12\Lib\site-packages\mkdocs\commands\build.py", line 167, in _populate_page
page.render(config, files)
File "C:\Users\<User>\AppData\Local\pypoetry\Cache\virtualenvs\<lib-env>-py3.12\Lib\site-packages\mkdocs\structure\pages.py", line 285, in render
self.content = md.convert(self.markdown)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\<User>\AppData\Local\pypoetry\Cache\virtualenvs\<lib-env>-py3.12\Lib\site-packages\markdown\core.py", line 367, in convert
newRoot = treeprocessor.run(root)
^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\<User>\AppData\Local\pypoetry\Cache\virtualenvs\<lib-env>-py3.12\Lib\site-packages\pymdownx\highlight.py", line 527, in run
code.highlight(
File "C:\Users\<User>\AppData\Local\pypoetry\Cache\virtualenvs\<lib-env>-py3.12\Lib\site-packages\pymdownx\highlight.py", line 400, in highlight
formatter = html_formatter(
^^^^^^^^^^^^^^^
File "C:\Users\<User>\AppData\Local\pypoetry\Cache\virtualenvs\<lib-env>-py3.12\Lib\site-packages\pymdownx\highlight.py", line 179, in __init__
HtmlFormatter.__init__(self, **options)
File "C:\Users\<User>\AppData\Local\pypoetry\Cache\virtualenvs\<lib-env>-py3.12\Lib\site-packages\pygments\formatters\html.py", line 434, in __init__
self.filename = html.escape(self._decodeifneeded(options.get('filename', '')))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\<User>\AppData\Local\Programs\Python\Python312\Lib\html\__init__.py", line 19, in escape
s = s.replace("&", "&") # Must be done first!
^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'replace'
Reacted by Peter Stenger, Brendan McAndrew, Brendan, Mikhail Manturov, Angela Liss and Pablo Parada
Metadata
Metadata
Assignees
Labels
No labels
Activity
styx0x6 commentedon Mar 30, 2026
Hi,
html.escapehave been added for hardening purpose in class attributes when initiated. It usesreplacebuilt-in function inside itself to do its business. This function only take strings as argument.It seems that sometimes not all attributes may be initiated with a value, works like that up to 2.19.2. But since the hardening, built-in
replacedoesn't acceptNoneobject, only string.Maybe the best solution is to force-cast escaped values with
str(), just to render theNoneobject or any other as readable.styx0x6 commentedon Mar 30, 2026
My proposal to fix this issue: #3078
Pin pygments==2.19.2 in docs dependency group
Use `uv` and pin pygments in readthedocs (#14550)
Pin pygments version (#375)
TTFrSim commentedon Mar 31, 2026
Thanks for working on a fix... this fast 🚀
When the artifact is ready, I also can test it on my side and give Feedback.
ci: add mkdocs build
woodruffw commentedon Apr 1, 2026
Just for searchability/cross-referencing: this appears to affect Zensical as well (which is similar to MkDocs).
birkenfeld commentedon Apr 1, 2026
Fix will be released shortly, however, for the record, this is a bug in (appears to be) pymdownx since AFAICS we never guaranteed that None would work as an option value. So please also report there.
to avoid AttributeError: 'NoneType' object has no attribute 'replace'
Merge pull request pygments#3078 from styx0x6/issue-3076
Pin pymdown-extensions>=10.21.2 (pygments 2.20.0 compat fix)
Pin pygments version (vllm-project#375)
chore: Pin pyments==2.19.2
Temporarily pin pygments version to avoids mkdocs build failures (#55)
chore(deps): pin pygments==2.19.2
ci: add mkdocs build (#212)
build: reverted pygment to 2.19.2 because of breaking change introduc…
Fix for docs not building (#1146)
Pin pygments to fix readthedocs build failure (#15)