Closed Yannis4444 closed 1 month ago
I am using version 1.5.3 of mkdocs and get the following error:
ERROR - Error building page 'index.md': 'NoneType' object has no attribute 'replace' 2024-05-06T15:26:05.770035773Z Traceback (most recent call last): 2024-05-06T15:26:05.770039577Z File "/usr/local/bin/mkdocs", line 8, in <module> 2024-05-06T15:26:05.770043900Z sys.exit(cli()) 2024-05-06T15:26:05.770048151Z ^^^^^ 2024-05-06T15:26:05.770087243Z File "/usr/local/lib/python3.11/site-packages/click/core.py", line 1157, in __call__ 2024-05-06T15:26:05.770092756Z return self.main(*args, **kwargs) 2024-05-06T15:26:05.770095995Z ^^^^^^^^^^^^^^^^^^^^^^^^^^ 2024-05-06T15:26:05.770099024Z File "/usr/local/lib/python3.11/site-packages/click/core.py", line 1078, in main 2024-05-06T15:26:05.770102513Z rv = self.invoke(ctx) 2024-05-06T15:26:05.770105348Z ^^^^^^^^^^^^^^^^ 2024-05-06T15:26:05.770108204Z File "/usr/local/lib/python3.11/site-packages/click/core.py", line 1688, in invoke 2024-05-06T15:26:05.770111208Z return _process_result(sub_ctx.command.invoke(sub_ctx)) 2024-05-06T15:26:05.770114391Z ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2024-05-06T15:26:05.770117285Z File "/usr/local/lib/python3.11/site-packages/click/core.py", line 1434, in invoke 2024-05-06T15:26:05.770120205Z return ctx.invoke(self.callback, **ctx.params) 2024-05-06T15:26:05.770123057Z ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2024-05-06T15:26:05.770126077Z File "/usr/local/lib/python3.11/site-packages/click/core.py", line 783, in invoke 2024-05-06T15:26:05.770129015Z return __callback(*args, **kwargs) 2024-05-06T15:26:05.770131852Z ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2024-05-06T15:26:05.770134749Z File "/usr/local/lib/python3.11/site-packages/mkdocs/__main__.py", line 286, in build_command 2024-05-06T15:26:05.770137934Z build.build(cfg, dirty=not clean) 2024-05-06T15:26:05.770140811Z File "/usr/local/lib/python3.11/site-packages/mkdocs/commands/build.py", line 349, in build 2024-05-06T15:26:05.770143888Z _build_page( 2024-05-06T15:26:05.770154668Z File "/usr/local/lib/python3.11/site-packages/mkdocs/commands/build.py", line 235, in _build_page 2024-05-06T15:26:05.770157852Z output = config.plugins.on_post_page(output, page=page, config=config) 2024-05-06T15:26:05.770160798Z ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2024-05-06T15:26:05.770163789Z File "/usr/local/lib/python3.11/site-packages/mkdocs/plugins.py", line 586, in on_post_page 2024-05-06T15:26:05.770168042Z return self.run_event('post_page', output, page=page, config=config) 2024-05-06T15:26:05.770171124Z ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2024-05-06T15:26:05.770174091Z File "/usr/local/lib/python3.11/site-packages/mkdocs/plugins.py", line 507, in run_event 2024-05-06T15:26:05.770177078Z result = method(item, **kwargs) 2024-05-06T15:26:05.770179936Z ^^^^^^^^^^^^^^^^^^^^^^ 2024-05-06T15:26:05.770182773Z File "/usr/local/lib/python3.11/site-packages/mkdocs_puml/plugin.py", line 141, in on_post_page 2024-05-06T15:26:05.770185757Z page.html = self._replace(v, page.html) 2024-05-06T15:26:05.770188611Z ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2024-05-06T15:26:05.770194988Z File "/usr/local/lib/python3.11/site-packages/mkdocs_puml/plugin.py", line 149, in _replace 2024-05-06T15:26:05.770198153Z return content.replace( 2024-05-06T15:26:05.770200990Z ^^^^^^^^^^^^^^^ 2024-05-06T15:26:05.770203857Z AttributeError: 'NoneType' object has no attribute 'replace'
As far as I can tell this is caused by a faulty if condition in on_post_page(...). There is already a TODO describing why this if is needed:
on_post_page(...)
https://github.com/MikhailKravets/mkdocs_puml/blob/7b007a8b618483a8094615a20f154b9979d5c5e2/mkdocs_puml/plugin.py#L137-L141
It seems like page has the attribute html but the attribute is None. This should be fixed by changing the if as follows:
page
html
None
if hasattr(page, 'html') and page.html is not None:
@Yannis4444, your fix #40 is merged and released in 1.3.1 version 🎉
1.3.1
I am using version 1.5.3 of mkdocs and get the following error:
As far as I can tell this is caused by a faulty if condition in
on_post_page(...)
. There is already a TODO describing why this if is needed:https://github.com/MikhailKravets/mkdocs_puml/blob/7b007a8b618483a8094615a20f154b9979d5c5e2/mkdocs_puml/plugin.py#L137-L141
It seems like
page
has the attributehtml
but the attribute isNone
. This should be fixed by changing the if as follows: