#29: fix some option list issues, in HTML, LaTeX and text writers.

This commit is contained in:
Georg Brandl
2008-11-03 21:40:21 +01:00
parent 25f63fec52
commit 324145853e
7 changed files with 61 additions and 3 deletions

View File

@@ -130,6 +130,9 @@ New features added
Bugs fixed
----------
* Support option lists in the text writer. Make sure that dashes
introducing long option names are not contracted to en-dashes.
* Support the "scale" option for images in HTML output.
* Properly escape quotes in HTML help attribute values.

View File

@@ -447,6 +447,13 @@ class SmartyPantsHTMLTranslator(HTMLTranslator):
finally:
self.no_smarty -= 1
def visit_option(self, node):
self.no_smarty += 1
HTMLTranslator.visit_option(self, node)
def depart_option(self, node):
self.no_smarty -= 1
HTMLTranslator.depart_option(self, node)
def bulk_text_processor(self, text):
if self.no_smarty <= 0:
return sphinx_smarty_pants(text)

View File

@@ -1069,9 +1069,9 @@ class LaTeXTranslator(nodes.NodeVisitor):
pass
def visit_option_string(self, node):
pass
def depart_option_string(self, node):
pass
ostring = node.astext()
self.body.append(self.encode(ostring.replace('--', u'--')))
raise nodes.SkipNode
def visit_description(self, node):
self.body.append( ' ' )

View File

@@ -284,6 +284,46 @@ class TextTranslator(nodes.NodeVisitor):
def visit_label(self, node):
raise nodes.SkipNode
# XXX: option list could use some better styling
def visit_option_list(self, node):
pass
def depart_option_list(self, node):
pass
def visit_option_list_item(self, node):
self.new_state(0)
def depart_option_list_item(self, node):
self.end_state()
def visit_option_group(self, node):
self._firstoption = True
def depart_option_group(self, node):
self.add_text(' ')
def visit_option(self, node):
if self._firstoption:
self._firstoption = False
else:
self.add_text(', ')
def depart_option(self, node):
pass
def visit_option_string(self, node):
pass
def depart_option_string(self, node):
pass
def visit_option_argument(self, node):
self.add_text(node['delimiter'])
def depart_option_argument(self, node):
pass
def visit_description(self, node):
pass
def depart_description(self, node):
pass
def visit_tabular_col_spec(self, node):
raise nodes.SkipNode

View File

@@ -34,6 +34,8 @@ tex_replacements = [
(u'±', ur'\(\pm\)'),
(u'', ur'\(\rightarrow\)'),
(u'', ur'\(\rightarrow\)'),
# used to separate -- in options
(u'', ur'{}'),
# map some special Unicode characters to similar ASCII ones
(u'', ur'-'),
(u'', ur'\_'),

View File

@@ -110,6 +110,11 @@ This is a side note.
This tests :CLASS:`role names in uppercase`.
Option list:
-h help
--help also help
.. centered:: LICENSE AGREEMENT
.. acks::

View File

@@ -59,6 +59,7 @@ HTML_XPATH = {
".//meta[@name='keywords'][@content='docs, sphinx']": '',
".//a[@href='contents.html#ref1']": '',
".//div[@id='label']": '',
".//span[@class='option']": '--help',
},
'desc.html': {
".//dt[@id='mod.Cls.meth1']": '',