comwes/mkpdfs-mkdocs-plugin

Crash in mkpdfs

TimW55 opened this issue · 5 comments

I am experiencing a crash in mkpdfs and hope that you can tell me what I am doing wrong.
My environment is:
O/S: Ubuntu 18.04
mkdocs: 1.0.4
mkpdfs-mkdocs: 1.0.0
weasyprint: 47
beautiful soup: 4.7.1

traceback:
File "/home/tjw/.local/lib/python3.6/site-packages/mkdocs/plugins.py", line 94, in run_event
result = method(item, **kwargs)
File "/home/tjw/.local/lib/python3.6/site-packages/mkpdfs_mkdocs/mkpdfs.py", line 58, in on_post_page
pdf_url = self.generator.add_article(output_content, page, base_url)
File "/home/tjw/.local/lib/python3.6/site-packages/mkpdfs_mkdocs/generator.py", line 64, in add_article
article = prep_combined(article, base_url, page.file.url)
File "/home/tjw/.local/lib/python3.6/site-packages/mkpdfs_mkdocs/preprocessor/prep.py", line 9, in get_combined
for id in soup.find_all(id=True):
AttributeError: 'NoneType' object has no attribute 'find_all'

It seems that in Generator.add_article article = soup.find('article') is setting article to None. I have attached a file showing the contents of soup.

soup_contents.txt

mkdocs itself is working well.

Thanks for your help.

Tim

Hello @TimW55,

I have an Idea about what's the problem. This seems to be a bug in the current version. I'll do my best to work on it asap.
Just to confirm, can you provide the markdown this particular page?

Thanks,
Gerry N.

@TimW55, I've found out where was the bug coming from. I'm working on a release for next week. The problem was located to the fact that I was assuming any theme has integrated <article></article> tag as the page content's container. Obviously this is not the case. I've seen that the default theme integrates page content in a <div role="main"></div> . I'll use these two to fetch the page content and integrate PDF link, and if any of them does not exist, the pdf version will not be generated at all.

I hope this will be an acceptable solution. If you do have another Idea just let me know.

Hello Tim,
This will definitely fix your issue.
I've released version 1.0.1 earlier than planned.
Enjoy, and share with your friends :) !
Gerry N.