SF.net SVN: docutils:[10323] trunk/docutils

milde--- via Docutils-checkins <[email protected]> Thu, 07 May 2026 12:36:02 +0000
Newsgroups gmane.text.docutils.cvs
Message-ID <[email protected]>
Revision: 10323
          http://sourceforge.net/p/docutils/code/10323
Author:   milde
Date:     2026-05-07 12:36:02 +0000 (Thu, 07 May 2026)
Log Message:
-----------
latex-footnotes: Fix PDF sidebar.

Prevent footnotes in section titles from showing up in the PDF "sidebar ToC".

Modified Paths:
--------------
    trunk/docutils/docutils/writers/latex2e/__init__.py
    trunk/docutils/test/functional/expected/latex_footnotes.tex

Modified: trunk/docutils/docutils/writers/latex2e/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/latex2e/__init__.py	2026-04-30 19:18:46 UTC (rev 10322)
+++ trunk/docutils/docutils/writers/latex2e/__init__.py	2026-05-07 12:36:02 UTC (rev 10323)
@@ -2417,6 +2417,8 @@
             self.footnote_queue.append(href)
             footnote_cmd = '%\n\\footnote'
             if isinstance(node.parent, nodes.title):
+                if isinstance(node.parent.parent, nodes.section):
+                    self.out.append('%\n\\texorpdfstring{')
                 footnote_cmd = '%\n \\protect\\footnote'
             add_label = target['names'] and self.document.refnames.get(
                                                 target['names'][0], [])
@@ -2440,7 +2442,7 @@
                 # subsequent items have their reference already set:
                 footnote_cmd = '%\n\\refstepcounter{footnote}\\footnotetext'
                 add_label = True
-            raise nodes.SkipNode  # ignore content (footnote number/symbol)
+            raise nodes.SkipChildren  # ignore content (footnote number/symbol)
 
     def depart_footnote_reference(self, node) -> None:
         if not self.latex_footnotes:
@@ -2448,6 +2450,9 @@
         elif not isinstance(self.document.ids[node['refid']], nodes.footnote):
             self.depart_reference(node)
             self.out.append('}')
+        elif isinstance(node.parent.parent, nodes.section
+                        ) and isinstance(node.parent, nodes.title):
+            self.out.append('}{}')
 
     # footnote/citation label
     def label_delim(self, node, bracket, superscript):

Modified: trunk/docutils/test/functional/expected/latex_footnotes.tex
===================================================================
--- trunk/docutils/test/functional/expected/latex_footnotes.tex	2026-04-30 19:18:46 UTC (rev 10322)
+++ trunk/docutils/test/functional/expected/latex_footnotes.tex	2026-05-07 12:36:02 UTC (rev 10323)
@@ -27,9 +27,10 @@
 
 
 \section{Test features of rST footnotes%
+\texorpdfstring{%
  \protect\footnote{\label{top}%
   referenced from a section title
-}}
+}}{}}
 
 \emph{Numbered} footnotes%
 \footnote{\label{exi}%

This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.