Menu

#195 invalid html for citation nodes with no siblings

None
closed-fixed
nobody
None
5
2023-05-10
2022-08-25
No

When citations appear in a parent that has no other siblings besides this single citation, a spurious </div> is generated resulting in invalid html code. It appears that this is because the opening <div role="list" class="citation-list"> is not being generated. I've tracked it to this docutils failing to add an opening div for the citation list here:

https://github.com/docutils/docutils/blob/master/docutils/docutils/writers/_html_base.py#L632

It gets then closed here leading to the extra tag:

https://github.com/docutils/docutils/blob/master/docutils/docutils/writers/_html_base.py#L640

Basically, this is due to odd behaviour of previous_sibling: if index relative to parent is zero and there are no other siblings, it returns the node itself instead of None. This looks like a docutils bug, and the attached patch fixes the issue.

Originally reported here: https://github.com/mcmtroffaes/sphinxcontrib-bibtex/issues/309 .

Also reported here: https://github.com/sphinx-doc/sphinx/issues/10784 .

1 Attachments

Related

Bugs: #472

Discussion

  • Abramo Bagnara

    Abramo Bagnara - 2022-10-11

    I confirm that the patch fixes the problem of unmatched </div> generation.

     
  • Günter Milde

    Günter Milde - 2022-10-11
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -1,4 +1,4 @@
    -When citations appear in a parent that has no other siblings besides this single citation, a spurious &lt;/div&gt; is generated resulting in invalid html code. It appears that this is because the opening &lt;div role=&#34;list&#34; class=&#34;citation-list&#34;&gt; is not being generated. I&#39;ve tracked it to this docutils failing to add an opening div for the citation list here:
    +When citations appear in a parent that has no other siblings besides this single citation, a spurious `&lt;/div&gt;` is generated resulting in invalid html code. It appears that this is because the opening `&lt;div role=&#34;list&#34; class=&#34;citation-list&#34;&gt;` is not being generated. I&#39;ve tracked it to this docutils failing to add an opening div for the citation list here:
    
     https://github.com/docutils/docutils/blob/master/docutils/docutils/writers/_html_base.py#L632
    
    @@ -8,6 +8,6 @@
    
     Basically, this is due to odd behaviour of previous_sibling: if index relative to parent is zero and there are no other siblings, it returns the node itself instead of None. This looks like a docutils bug, and the attached patch fixes  the issue.
    
    -Originally reported here: https://github.com/mcmtroffaes/sphinxcontrib-bibtex/issues/309.
    +Originally reported here: https://github.com/mcmtroffaes/sphinxcontrib-bibtex/issues/309 .
    
    -Also reported here: https://github.com/sphinx-doc/sphinx/issues/10784.
    +Also reported here: https://github.com/sphinx-doc/sphinx/issues/10784 .
    
     
  • Günter Milde

    Günter Milde - 2022-10-11
    • status: open --> open-fixed
     
  • Günter Milde

    Günter Milde - 2022-10-11

    Fixed in [r9126].
    Thank you for report, analysis, and patch.

     

    Related

    Commit: [r9126]

  • Günter Milde

    Günter Milde - 2023-05-10
    • status: open-fixed --> closed-fixed
     
  • Günter Milde

    Günter Milde - 2023-05-10

    Fixed in Docutils 0.20
    Thank you for the report and patch.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.