Commits

Jon Waltman committed d60b5cc

[texinfo] Prevent hyphen conversion in option directive signatures.

Comments (0)

Files changed (1)

sphinx/writers/texinfo.py

         self.seen_title = False
         self.next_section_ids = set()
         self.escape_newlines = 0
+        self.escape_hyphens = 0
         self.curfilestack = []
         self.footnotestack = []
         self.in_footnote = 0
         # prevent `` and '' quote conversion
         s = s.replace('``', "`@w{`}")
         s = s.replace("''", "'@w{'}")
-        # prevent "--" from being converted to an "em dash"
-        # s = s.replace('-', '@w{-}')
         return s
 
     def escape_arg(self, s):
         s = self.escape(node.astext())
         if self.escape_newlines:
             s = s.replace('\n', ' ')
+        if self.escape_hyphens:
+            # prevent "--" and "---" conversion
+            s = s.replace('-', '@w{-}')
         self.body.append(s)
     def depart_Text(self, node):
         pass
         pass
 
     def visit_option(self, node):
+        self.escape_hyphens += 1
         self.body.append('\n%s ' % self.at_item_x)
         self.at_item_x = '@itemx'
     def depart_option(self, node):
-        pass
+        self.escape_hyphens -= 1
 
     def visit_option_string(self, node):
         pass
         self.body.append('@end deffn\n')
 
     def visit_desc_signature(self, node):
+        self.escape_hyphens += 1
         objtype = node.parent['objtype']
         if objtype != 'describe':
             for id in node.get('ids'):
         self.at_deffnx = '@deffnx'
     def depart_desc_signature(self, node):
         self.body.append("\n")
+        self.escape_hyphens -= 1
 
     def visit_desc_name(self, node):
         pass