SF.net SVN: docutils:[9567 ] trunk

grubert--- via Docutils-checkins <[email protected]>
Newsgroups gmane.text.docutils.cvs
Message-ID <[email protected]>
Revision: 9567
          http://sourceforge.net/p/docutils/code/9567
Author:   grubert
Date:     2024-03-15 14:08:49 +0000 (Fri, 15 Mar 2024)
Log Message:
-----------
Fix multiple definition list terms with classifiers

Modified Paths:
--------------
    trunk/docutils/docutils/writers/manpage.py
    trunk/sandbox/manpage-writer/expected/termtest-manpage.man

Modified: trunk/docutils/docutils/writers/manpage.py
===================================================================
--- trunk/docutils/docutils/writers/manpage.py	2024-03-15 12:52:14 UTC (rev 9566)
+++ trunk/docutils/docutils/writers/manpage.py	2024-03-15 14:08:49 UTC (rev 9567)
@@ -495,10 +495,11 @@
         raise nodes.SkipNode
 
     def visit_classifier(self, node):
-        pass
+        self.body.append('(')
 
     def depart_classifier(self, node):
-        pass
+        self.body.append(')')
+        self.depart_term(node)  # close the term element after last classifier
 
     def visit_colspec(self, node):
         self.colspecs.append(node)
@@ -1099,13 +1100,15 @@
         self.body.append('\n.B ')
 
     def depart_term(self, node):
-        _next = None
-        if isinstance(node.parent, nodes.definition_list_item):
-            _next = next(node.findall(condition=None, include_self=False,
-                                     descend=False, siblings=True, ascend=False))
-        if _next and isinstance(_next, nodes.term):
+        _next = node.next_node(None, descend=False, siblings=True)
+        # Nest (optional) classifier(s) in the <dt> element
+        if isinstance(_next, nodes.classifier):
+            self.body.append(' ')
+            return  # skip (depart_classifier() calls this function again)
+        if isinstance(_next, nodes.term):
             self.body.append('\n.TQ')
-        self.body.append('\n')
+        else:
+            self.body.append('\n')
 
     def visit_tgroup(self, node):
         pass

Modified: trunk/sandbox/manpage-writer/expected/termtest-manpage.man
===================================================================
--- trunk/sandbox/manpage-writer/expected/termtest-manpage.man	2024-03-15 12:52:14 UTC (rev 9566)
+++ trunk/sandbox/manpage-writer/expected/termtest-manpage.man	2024-03-15 14:08:49 UTC (rev 9567)
@@ -37,14 +37,12 @@
 .TP
 .B term 2a
 .TQ
-
 .B term 2b
 definition 2
 .TP
-.B term 3a
-classifier 3aclassifier 3aa
-.B term 3b
-classifier 3b
+.B term 3a (classifier 3a) (classifier 3aa)
+.TQ
+.B term 3b (classifier 3b)
 definition 3
 .UNINDENT
 .\" Generated by docutils manpage writer.

This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.