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

milde--- via Docutils-checkins <[email protected]> Sun, 01 Jun 2025 08:34:08 +0000
Newsgroups gmane.text.docutils.cvs
Message-ID <[email protected]>
Revision: 10150
          http://sourceforge.net/p/docutils/code/10150
Author:   milde
Date:     2025-06-01 08:34:07 +0000 (Sun, 01 Jun 2025)
Log Message:
-----------
manpage writer: do not drop text content of inline targets.

Inline targets are eponymous, they point to a text portion that is
also the base of the target's name and id.

Generated manpages do not implement internal hyperlinks but the
document source may be used with different writers and contain
cross references -> print the text as normal text.

Modified Paths:
--------------
    trunk/docutils/HISTORY.rst
    trunk/docutils/docutils/writers/manpage.py
    trunk/docutils/test/test_writers/test_manpage.py

Modified: trunk/docutils/HISTORY.rst
===================================================================
--- trunk/docutils/HISTORY.rst	2025-05-27 06:17:51 UTC (rev 10149)
+++ trunk/docutils/HISTORY.rst	2025-06-01 08:34:07 UTC (rev 10150)
@@ -256,6 +256,7 @@
   - Print Docutils version in header comment (feature-request #105).
   - Stop converting text to full capitals (bug #481).
   - Fix reference output (bug #497).
+  - Do not drop text of internal targets.
   - Use macros .UR/.UE for hyperlink references unless the new
     configuration setting text_references_ is True.
     The current default is True (text references), it will change

Modified: trunk/docutils/docutils/writers/manpage.py
===================================================================
--- trunk/docutils/docutils/writers/manpage.py	2025-05-27 06:17:51 UTC (rev 10149)
+++ trunk/docutils/docutils/writers/manpage.py	2025-06-01 08:34:07 UTC (rev 10150)
@@ -1113,6 +1113,7 @@
                                  % insert_URI_breakpoints(node.astext()))
                 raise nodes.SkipNode
         # elif 'refid' in node:
+        #     internal cross references are ignored (just print the text)
 
     def _depart_reference_no_macro(self, node) -> None:
         if 'refuri' in node:
@@ -1233,9 +1234,13 @@
         self._active_table = None
 
     def visit_target(self, node):
-        # targets are in-document hyper targets, without any use for man-pages.
-        raise nodes.SkipNode
+        # <target> elements are anchors of internal hyperlinks (not used
+        # in man-pages). Just print content (inline targets may contain text):
+        pass
 
+    def depart_target(self, node):
+        pass
+
     def visit_tbody(self, node) -> None:
         pass
 

Modified: trunk/docutils/test/test_writers/test_manpage.py
===================================================================
--- trunk/docutils/test/test_writers/test_manpage.py	2025-05-27 06:17:51 UTC (rev 10149)
+++ trunk/docutils/test/test_writers/test_manpage.py	2025-06-01 08:34:07 UTC (rev 10150)
@@ -358,6 +358,22 @@
 public domain
 .\\" End of generated man page.
 """],
+["""\
+Internal hyperlinks_ and targets_ are ignored.
+
+.. _hyperlinks:
+
+(Text content of hyperlinks and _`targets` is printed as normal text.)
+""",
+f"""{document_start}{indend_macros}.TH "" "" "" ""
+.SH Name
+ \\- \n\
+Internal hyperlinks and targets are ignored.
+.sp
+(Text content of hyperlinks and targets is printed as normal text.)
+.\\" End of generated man page.
+"""],
+
 ]
 
 totest['table'] = [

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