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

grubert--- via Docutils-checkins <[email protected]>
Newsgroups gmane.text.docutils.cvs
Message-ID <[email protected]>
Revision: 9554
          http://sourceforge.net/p/docutils/code/9554
Author:   grubert
Date:     2024-03-10 11:34:27 +0000 (Sun, 10 Mar 2024)
Log Message:
-----------
manpage: Add multiple definition list term support

Modified Paths:
--------------
    trunk/docutils/HISTORY.txt
    trunk/docutils/docutils/writers/manpage.py

Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt	2024-03-08 23:41:41 UTC (rev 9553)
+++ trunk/docutils/HISTORY.txt	2024-03-10 11:34:27 UTC (rev 9554)
@@ -174,6 +174,7 @@
 
 * docutils/writers/manpage.py
 
+  - Add multiple definition list term support, see feature #60.
   - Add preprocessor hinting tbl first line, see bugs #477.
   - Change tbl-Tables using box option, see bugs #475.
   - Apply literal block patch #205. Use ``.EE`` and ``.EX`` macros.

Modified: trunk/docutils/docutils/writers/manpage.py
===================================================================
--- trunk/docutils/docutils/writers/manpage.py	2024-03-08 23:41:41 UTC (rev 9553)
+++ trunk/docutils/docutils/writers/manpage.py	2024-03-10 11:34:27 UTC (rev 9554)
@@ -203,6 +203,7 @@
         self._in_literal = False
         self.header_written = 0
         self._line_block = 0
+        self._second_term = False   # multiple term in definition list
         self.authors = []
         self.section_level = 0
         self._indent = [0]
@@ -231,7 +232,6 @@
                 'reference': (r'\fI\%', r'\fP'),
                 'emphasis': ('\\fI', '\\fP'),
                 'strong': ('\\fB', '\\fP'),
-                'term': ('\n.B ', '\n'),
                 'title_reference': ('\\fI', '\\fP'),
 
                 'topic-title': ('.SS ',),
@@ -1097,10 +1097,20 @@
         pass
 
     def visit_term(self, node):
-        self.body.append(self.defs['term'][0])
+        if self._second_term:
+            self._second_term = False
+        else:
+            self.body.append('\n.B ')
 
     def depart_term(self, node):
-        self.body.append(self.defs['term'][1])
+        _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):
+            self.body.append('\\fR,\\fB \\')
+            self._second_term = True
+        self.body.append('\n')
 
     def visit_tgroup(self, node):
         pass

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.