Docutils 0.18 returns an error when searching for author metadata
choldgraf opened this issue · 0 comments
choldgraf commented
Describe the bug
On a page that has page metadata, but not the metadata needed for ABlog
, there seems to be a broken logic check for whether metadata fields exist and we get a list index error:
File "/home/choldgraf/github/forks/python/ebp/pydata-sphinx-theme/.nox/docs-live/lib/python3.9/site-packages/ablog/post.py", line 186, in apply
metadata["author"] = list(docinfo.traverse(nodes.author))[0].astext()
I think this is because of the check here:
Lines 185 to 191 in 9545dc1
I think for some reason traverse(nodes.author)
will register as True
even if the resulting list will be empty.
I suggest instead wrapping it in a list, which fixed it for me:
if list(docinfo.traverse(nodes.author)):
To Reproduce
- Install docutils 0.18 and latest ablog
- Put metadata on a non-ABlog page
- Build the site and I think this should pop up
System Details
- docutils version: 0.18
- ablog version: latest release