SF.net SVN: docutils:[9989 ] trunk/docutils/docutils/w riters/manpage.py

grubert--- via Docutils-checkins <[email protected]>
Newsgroups gmane.text.docutils.cvs
Message-ID <[email protected]>
Revision: 9989
          http://sourceforge.net/p/docutils/code/9989
Author:   grubert
Date:     2024-11-24 17:15:41 +0000 (Sun, 24 Nov 2024)
Log Message:
-----------
manpage writer: extract encode_special_chars from visit_Text

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

Modified: trunk/docutils/docutils/writers/manpage.py
===================================================================
--- trunk/docutils/docutils/writers/manpage.py	2024-11-24 17:09:34 UTC (rev 9988)
+++ trunk/docutils/docutils/writers/manpage.py	2024-11-24 17:15:41 UTC (rev 9989)
@@ -351,9 +351,7 @@
         text = text.replace('\u2020', '\\(dg')
         return text
 
-    def visit_Text(self, node) -> None:
-        text = node.astext()
-        text = text.replace('\\', '\\e')
+    def encode_special_chars(self, text):
         replace_pairs = [
             ('-', '\\-'),
             ('\'', '\\(aq'),
@@ -363,6 +361,12 @@
             ]
         for (in_char, out_markup) in replace_pairs:
             text = text.replace(in_char, out_markup)
+        return text
+
+    def visit_Text(self, node) -> None:
+        text = node.astext()
+        text = text.replace('\\', '\\e')
+        text = self.encode_special_chars(text)
         # unicode
         text = self.deunicode(text)
         # prevent interpretation of "." at line start

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.