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

milde--- via Docutils-checkins <[email protected]> Sun, 30 Mar 2025 20:13:14 +0000
Newsgroups gmane.text.docutils.cvs
Message-ID <[email protected]>
Revision: 10062
          http://sourceforge.net/p/docutils/code/10062
Author:   milde
Date:     2025-03-30 20:13:14 +0000 (Sun, 30 Mar 2025)
Log Message:
-----------
Fixup of recent changes to LaTeX writer docinfo handling.

Insert a space after the author-separator in "pdfauthor" meta-data entry.

Code formatting and structuring.

Modified Paths:
--------------
    trunk/docutils/docutils/writers/latex2e/__init__.py
    trunk/docutils/test/functional/expected/latex_docinfo.tex
    trunk/docutils/test/functional/expected/latex_leavevmode.tex
    trunk/docutils/test/functional/expected/latex_memoir.tex
    trunk/docutils/test/functional/expected/standalone_rst_latex.tex
    trunk/docutils/test/functional/expected/standalone_rst_xetex.tex

Modified: trunk/docutils/docutils/writers/latex2e/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/latex2e/__init__.py	2025-03-30 18:28:06 UTC (rev 10061)
+++ trunk/docutils/docutils/writers/latex2e/__init__.py	2025-03-30 20:13:14 UTC (rev 10062)
@@ -1193,9 +1193,9 @@
     literal = False                     # literal text (block or inline)
     alltt = False                       # inside `alltt` environment
 
-    # Nodes affected by "use_latex_docinfo" setting:
-    LATEX_DOCINFO_NODES = (nodes.address, nodes.author, nodes.contact,
-                           nodes.date, nodes.organization)
+    # Nodes to be stored in the "titledata" part if "use_latex_docinfo" is true
+    TITLEDATA_NODES = (nodes.address, nodes.author, nodes.authors,
+                       nodes.contact, nodes.date, nodes.organization)
 
     def __init__(self, document, babel_class=Babel) -> None:
         super().__init__(document)
@@ -1695,10 +1695,12 @@
         self.depart_inline(node)
 
     def visit_address(self, node) -> None:
+        self.insert_newline = True  # preserve newlines
         self.visit_docinfo_item(node)
 
     def depart_address(self, node) -> None:
         self.depart_docinfo_item(node)
+        self.insert_newline = False
 
     def visit_admonition(self, node) -> None:
         # strip the generic 'admonition' from the list of classes
@@ -1960,10 +1962,7 @@
             warnings.warn('visit_docinfo_item(): argument "name" is obsolete'
                           ' and will be removed in Docutils 0.24',
                           DeprecationWarning, stacklevel=2)
-        if isinstance(node, nodes.address):
-            self.insert_newline = True  # preserve newlines
-        if self.use_latex_docinfo and isinstance(node,
-                                                 self.LATEX_DOCINFO_NODES):
+        if self.use_latex_docinfo and isinstance(node, self.TITLEDATA_NODES):
             self.push_output_collector([])  # see depart_docinfo_item()
         else:
             label = self.language_label(node.tagname)
@@ -1976,9 +1975,7 @@
                 self.out.append(' ')
 
     def depart_docinfo_item(self, node) -> None:
-        self.insert_newline = False  # reset change with <address> node
-        if self.use_latex_docinfo and isinstance(node,
-                                                 self.LATEX_DOCINFO_NODES):
+        if self.use_latex_docinfo and isinstance(node, self.TITLEDATA_NODES):
             # Collect date and author info for use in `self.make_title()`:
             text = ''.join(self.pop_output_collector())
             if isinstance(node, nodes.date):
@@ -1991,7 +1988,7 @@
                 else:
                     self.author_stack[-1][0] = text
             else:
-                # Append affiliation/contact info to current "author info".
+                # Append affiliation & contact info to current "author info".
                 self.author_stack[-1].append(text)
         else:
             if isinstance(node, nodes.address):
@@ -2024,7 +2021,7 @@
             self.pdfinfo.insert(0, '  pdftitle={%s},' %
                                 self.encode(self.document.get('title', '')))
         if self.pdfauthor:
-            authors = self.author_separator.join(self.pdfauthor)
+            authors = (self.author_separator + ' ').join(self.pdfauthor)
             self.pdfinfo.append('  pdfauthor={%s}' % authors)
         if self.pdfinfo:
             self.pdfsetup += [r'\hypersetup{'] + self.pdfinfo + ['}']

Modified: trunk/docutils/test/functional/expected/latex_docinfo.tex
===================================================================
--- trunk/docutils/test/functional/expected/latex_docinfo.tex	2025-03-30 18:28:06 UTC (rev 10061)
+++ trunk/docutils/test/functional/expected/latex_docinfo.tex	2025-03-30 20:13:14 UTC (rev 10062)
@@ -21,7 +21,7 @@
   \urlstyle{same} % normal text font (alternatives: tt, rm, sf)
 \fi
 \hypersetup{
-  pdfauthor={Foo Fred;Bar Barney}
+  pdfauthor={Foo Fred; Bar Barney}
 }
 
 %%% Body

Modified: trunk/docutils/test/functional/expected/latex_leavevmode.tex
===================================================================
--- trunk/docutils/test/functional/expected/latex_leavevmode.tex	2025-03-30 18:28:06 UTC (rev 10061)
+++ trunk/docutils/test/functional/expected/latex_leavevmode.tex	2025-03-30 20:13:14 UTC (rev 10062)
@@ -148,7 +148,7 @@
 \fi
 \hypersetup{
   pdftitle={Styling of Elements in Definition- or Field-List},
-  pdfauthor={Hänsel;Gretel}
+  pdfauthor={Hänsel; Gretel}
 }
 
 %%% Body

Modified: trunk/docutils/test/functional/expected/latex_memoir.tex
===================================================================
--- trunk/docutils/test/functional/expected/latex_memoir.tex	2025-03-30 18:28:06 UTC (rev 10061)
+++ trunk/docutils/test/functional/expected/latex_memoir.tex	2025-03-30 20:13:14 UTC (rev 10062)
@@ -191,7 +191,7 @@
   pdftitle={reStructuredText Test Document},
   pdfkeywords={reStructuredText, test, parser},
   pdfinfo={description={A test document, containing at least one example of each reStructuredText construct.}},
-  pdfauthor={David Goodger;Me;Myself;I}
+  pdfauthor={David Goodger; Me; Myself; I}
 }
 
 \title{reStructuredText Test Document%

Modified: trunk/docutils/test/functional/expected/standalone_rst_latex.tex
===================================================================
--- trunk/docutils/test/functional/expected/standalone_rst_latex.tex	2025-03-30 18:28:06 UTC (rev 10061)
+++ trunk/docutils/test/functional/expected/standalone_rst_latex.tex	2025-03-30 20:13:14 UTC (rev 10062)
@@ -190,7 +190,7 @@
   pdftitle={reStructuredText Test Document},
   pdfkeywords={reStructuredText, test, parser},
   pdfinfo={description={A test document, containing at least one example of each reStructuredText construct.}},
-  pdfauthor={David Goodger;Me;Myself;I}
+  pdfauthor={David Goodger; Me; Myself; I}
 }
 
 %%% Body

Modified: trunk/docutils/test/functional/expected/standalone_rst_xetex.tex
===================================================================
--- trunk/docutils/test/functional/expected/standalone_rst_xetex.tex	2025-03-30 18:28:06 UTC (rev 10061)
+++ trunk/docutils/test/functional/expected/standalone_rst_xetex.tex	2025-03-30 20:13:14 UTC (rev 10062)
@@ -56,7 +56,7 @@
   pdftitle={reStructuredText Test Document},
   pdfkeywords={reStructuredText, test, parser},
   pdfinfo={description={A test document, containing at least one example of each reStructuredText construct.}},
-  pdfauthor={David Goodger;Me;Myself;I}
+  pdfauthor={David Goodger; Me; Myself; I}
 }
 
 \title{reStructuredText Test Document%

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



_______________________________________________
Docutils-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/docutils-checkins