[ovs-dev] [PATCH 01/14] ovsdb-doc: Distinguish hyphens and minus signs in nroff output.

Ben Pfaff blp at nicira.com
Fri Apr 9 00:06:59 UTC 2010


In nroff, a minus sign (\-) should generally be used in literal text,
whereas hyphens are generally correct elsewhere.  This roughly corresponds
to bold versus non-bold text, so this commit makes ovsdb-doc output "-"
that appears in input as a minus sign if it is bold or a hyphen if it is
not.
---
 ovsdb/ovsdb-doc.in |   13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/ovsdb/ovsdb-doc.in b/ovsdb/ovsdb-doc.in
index cb21c1f..f6cf4d4 100755
--- a/ovsdb/ovsdb-doc.in
+++ b/ovsdb/ovsdb-doc.in
@@ -14,9 +14,14 @@ from OVSDB import *
 
 argv0 = sys.argv[0]
 
-def textToNroff(s):
+def textToNroff(s, font=r'\fR'):
     def escape(match):
         c = match.group(0)
+        if c == '-':
+            if font == r'\fB':
+                return r'\-'
+            else:
+                return '-'
         if c == '\\':
             return r'\e'
         elif c == '"':
@@ -26,17 +31,17 @@ def textToNroff(s):
         else:
             raise Error("bad escape")
 
-    s = re.sub('([\\\\"\'])', escape, s)
+    s = re.sub('([-\\\\"\'])', escape, s)
     if s.startswith('.'):
         s = '\\' + s
     return s
 
 def escapeNroffLiteral(s):
-    return r'\fB%s\fR' % textToNroff(s)
+    return r'\fB%s\fR' % textToNroff(s, r'\fB')
 
 def inlineXmlToNroff(node, font):
     if node.nodeType == node.TEXT_NODE:
-        return textToNroff(node.data)
+        return textToNroff(node.data, font)
     elif node.nodeType == node.ELEMENT_NODE:
         if node.tagName == 'code' or node.tagName == 'em':
             s = r'\fB'
-- 
1.6.6.1





More information about the dev mailing list