getnikola / nikola

A static website and blog generator
https://getnikola.com/
MIT License
2.62k stars 450 forks source link

[possible regression] inline code breaks build #3783

Closed Sponge5 closed 3 months ago

Sponge5 commented 4 months ago

Environment

Python Version: Python 3.12.4 Nikola Version: Nikola v8.3.1 Operating System: Archlinux Docutils: Docutils 0.21.2

Description:

Hi, this is possibly a docutils issue but I'm first opening it here. After updating my environment and updating (reinstalling) all packages in it, nikola build is failing on .rst files with inline code. Running find posts/ -type f | xargs sed -i 's/:code:/:subscript:/g' fixes the problem. Maybe I'm missing a package or something, but if not, here is the stacktrace:

$ nikola build
...
PythonAction Error
Traceback (most recent call last):
  File "/home/adam/Other/PythonEnv/adamprocio.cz/lib/python3.12/site-packages/doit/action.py", line 461, in execute
    returned_value = self.py_callable(*self.args, **kwargs)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/adam/Other/PythonEnv/adamprocio.cz/lib/python3.12/site-packages/nikola/post.py", line 729, in compile
    self.compile_html(
  File "/home/adam/Other/PythonEnv/adamprocio.cz/lib/python3.12/site-packages/nikola/plugins/compile/rest/__init__.py", line 151, in compile
    output, error_level, deps, shortcode_deps = self.compile_string(data, source, is_two_file, post, lang)
                                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/adam/Other/PythonEnv/adamprocio.cz/lib/python3.12/site-packages/nikola/plugins/compile/rest/__init__.py", line 134, in compile_string
    output, error_level, deps, _ = rst2html(
                                   ^^^^^^^^^
  File "/home/adam/Other/PythonEnv/adamprocio.cz/lib/python3.12/site-packages/nikola/plugins/compile/rest/__init__.py", line 382, in rst2html
    pub.publish(enable_exit_status=enable_exit_status)
  File "/home/adam/Other/PythonEnv/adamprocio.cz/lib/python3.12/site-packages/docutils/core.py", line 237, in publish
    output = self.writer.write(self.document, self.destination)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/adam/Other/PythonEnv/adamprocio.cz/lib/python3.12/site-packages/docutils/writers/__init__.py", line 80, in write
    self.translate()
  File "/home/adam/Other/PythonEnv/adamprocio.cz/lib/python3.12/site-packages/docutils/writers/_html_base.py", line 156, in translate
    self.document.walkabout(visitor)
  File "/home/adam/Other/PythonEnv/adamprocio.cz/lib/python3.12/site-packages/docutils/nodes.py", line 186, in walkabout
    if child.walkabout(visitor):
       ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/adam/Other/PythonEnv/adamprocio.cz/lib/python3.12/site-packages/docutils/nodes.py", line 186, in walkabout
    if child.walkabout(visitor):
       ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/adam/Other/PythonEnv/adamprocio.cz/lib/python3.12/site-packages/docutils/nodes.py", line 199, in walkabout
    visitor.dispatch_departure(self)
  File "/home/adam/Other/PythonEnv/adamprocio.cz/lib/python3.12/site-packages/docutils/nodes.py", line 2005, in dispatch_departure
    return method(node)
           ^^^^^^^^^^^^
  File "/home/adam/Other/PythonEnv/adamprocio.cz/lib/python3.12/site-packages/docutils/writers/html5_polyglot/__init__.py", line 319, in depart_literal
    self.depart_inline(node)
  File "/home/adam/Other/PythonEnv/adamprocio.cz/lib/python3.12/site-packages/docutils/writers/html5_polyglot/__init__.py", line 270, in depart_inline
    self.body.append(f'</{node.html5tagname}>')
                          ^^^^^^^^^^^^^^^^^
AttributeError: 'literal' object has no attribute 'html5tagname'

I might find some time to delve deeper, but I'm not sure when. Maybe someone can first try to replicate the problem?

Kwpolska commented 4 months ago

This seems to be caused by our override for visit_inline, which may need to be updated to match the behaviour in docutils.