danodic-dev / mkdocs-backlinks

A plugin for adding backlinks to mkdocs.
MIT License
15 stars 2 forks source link

GuessedAtParserWarning: No parser was explicitly specified #4

Open jurgenhaas opened 11 months ago

jurgenhaas commented 11 months ago

This is a great plugin, thank you so much. My only issue is that I get hundreds of warnings while the site is being built:

mkdocs  | INFO    -  GuessedAtParserWarning: No parser was explicitly specified, so I'm using the best available HTML parser for this system ("lxml"). This usually isn't a problem, but if you run this code on another system, or in a different virtual environment, it may use a different parser and behave differently.
mkdocs  | 
mkdocs  | The code that caused this warning is on line 32 of the file /usr/lib/python3.11/site-packages/backlinks_plugin/plugin.py. To get rid of this warning, pass the additional argument 'features="lxml"' to the BeautifulSoup constructor.
mkdocs  | 
mkdocs  |   File "/usr/lib/python3.11/site-packages/backlinks_plugin/plugin.py", line 32, in links
mkdocs  |     links = BeautifulSoup(self.html).find_all('a')
mkdocs  |   File "/usr/lib/python3.11/site-packages/bs4/__init__.py", line 299, in __init__
mkdocs  |     warnings.warn(

It looks to me, that changing line 32 from links = BeautifulSoup(self.html).find_all('a') to links = BeautifulSoup(self.html, feature='lxml').find_all('a') would avoid those warnings. Could that be added? Or does it have to be made configurable? Although, it's not now either.

danodic commented 11 months ago

Thanks for the report, I'll validate this and will let you know.

jurgenhaas commented 3 months ago

I'm still seeing these warnings all over the place. Any chance of getting this addressed eventually?