summaryrefslogtreecommitdiff
path: root/sphinx
diff options
context:
space:
mode:
authorJonathan Waltman <jonathan.waltman@gmail.com>2013-02-19 04:38:21 -0600
committerJonathan Waltman <jonathan.waltman@gmail.com>2013-02-19 04:38:21 -0600
commit1cc08420742bedfbdce085a9297bbb946e6e2562 (patch)
tree54caed406a11f62334f18059a655e614c6c4a7c7 /sphinx
parent7c976f4ce3f079b1986205b8b6291cbdbcd35d93 (diff)
downloadsphinx-1cc08420742bedfbdce085a9297bbb946e6e2562.tar.gz
[texinfo] Prevent hyphen conversion in option directive signatures.
Diffstat (limited to 'sphinx')
-rw-r--r--sphinx/writers/texinfo.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/sphinx/writers/texinfo.py b/sphinx/writers/texinfo.py
index bbfe0576..551edbc8 100644
--- a/sphinx/writers/texinfo.py
+++ b/sphinx/writers/texinfo.py
@@ -161,6 +161,7 @@ class TexinfoTranslator(nodes.NodeVisitor):
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
@@ -325,8 +326,6 @@ class TexinfoTranslator(nodes.NodeVisitor):
# 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):
@@ -525,6 +524,9 @@ class TexinfoTranslator(nodes.NodeVisitor):
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
@@ -847,10 +849,11 @@ class TexinfoTranslator(nodes.NodeVisitor):
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
@@ -1270,6 +1273,7 @@ class TexinfoTranslator(nodes.NodeVisitor):
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'):
@@ -1287,6 +1291,7 @@ class TexinfoTranslator(nodes.NodeVisitor):
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