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

grubert--- via Docutils-checkins <[email protected]>
Newsgroups gmane.text.docutils.cvs
Message-ID <[email protected]>
Revision: 9812
          http://sourceforge.net/p/docutils/code/9812
Author:   grubert
Date:     2024-08-01 10:46:38 +0000 (Thu, 01 Aug 2024)
Log Message:
-----------
add some tests for UR/UE

Modified Paths:
--------------
    trunk/docutils/HISTORY.txt
    trunk/docutils/test/test_writers/test_manpage.py

Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt	2024-08-01 07:32:03 UTC (rev 9811)
+++ trunk/docutils/HISTORY.txt	2024-08-01 10:46:38 UTC (rev 9812)
@@ -156,6 +156,8 @@
     docutils version in header
   - Stop converting text to full capitals (bug #481).
   - Add module function insert_URI_breakpoints.
+  - Add command line option ``--use-reference-macros`` to enable usage of man
+    macros .UR/.UE.
 
 * docutils/writers/null.py
 

Modified: trunk/docutils/test/test_writers/test_manpage.py
===================================================================
--- trunk/docutils/test/test_writers/test_manpage.py	2024-08-01 07:32:03 UTC (rev 9811)
+++ trunk/docutils/test/test_writers/test_manpage.py	2024-08-01 10:46:38 UTC (rev 9812)
@@ -57,7 +57,22 @@
                         }).decode()
                     self.assertEqual(case_expected, output)
 
+    def test_reference_macros(self):
+        writer = 'manpage'
+        for name, cases in totest_refs.items():
+            for casenum, (case_input, case_expected) in enumerate(cases):
+                with self.subTest(id=f'totest_refs[{name!r}][{casenum}]'):
+                    output = publish_string(
+                        source=case_input,
+                        writer=writer,
+                        settings_overrides={
+                            '_disable_config': True,
+                            'strict_visitor': True,
+                            'use_reference_macros': True,
+                        }).decode()
+                    self.assertEqual(case_expected, output)
 
+
 document_start = r""".\" Man page generated from reStructuredText by manpage writer
 .\" from docutils 0.22b.dev.
 .
@@ -92,6 +107,60 @@
 ..
 """
 
+totest_refs = {}
+
+totest_refs['ext hyperlink'] = [
+        [r"""External hyperlinks, like Python_.
+
+.. _Python: https://www.python.org/
+""",
+         document_start + indend_macros + """.TH "" "" "" ""
+.SH Name
+ \\- \n\
+External hyperlinks, like 
+.UR https://www.python.org/
+Python
+.UE
+\&.
+.\\" End of generated man page.
+"""],
+        ]
+
+totest_refs['emb hyperlink'] = [
+        [r"""embedded External hyperlinks, like `Python
+<https://www.python.org/>`_.
+""",
+         document_start + indend_macros + """.TH "" "" "" ""
+.SH Name
+ \\- \n\
+embedded External hyperlinks, like \n\
+.UR https://www.python.org/
+Python
+.UE
+\&.
+.\\" End of generated man page.
+"""],
+        ]
+
+totest_refs['email'] = [
+        [r"""`Write to me`_ with your questions.
+
+.. _Write to me: [email protected]
+
+whatever.""",
+         document_start + indend_macros + """.TH "" "" "" ""
+.SH Name
+ \\- \n\
+.UR mailto:[email protected]
+Write to me
+.UE
+ with your questions.
+.sp
+whatever.
+.\\" End of generated man page.
+"""],
+        ]
+
 totest = {}
 
 totest['blank'] = [

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.