[Python-checkins] r65122 - in doctools/branches/0.4.x: CHANGES sphinx/latexwriter.py sphinx/roles.py
georg.brandl
python-checkins at python.org
Fri Jul 18 23:51:28 CEST 2008
Author: georg.brandl
Date: Fri Jul 18 23:51:28 2008
New Revision: 65122
Log:
Don't use \samp{} for code with whitespaces, only for :samp:`code`.
Modified:
doctools/branches/0.4.x/CHANGES
doctools/branches/0.4.x/sphinx/latexwriter.py
doctools/branches/0.4.x/sphinx/roles.py
Modified: doctools/branches/0.4.x/CHANGES
==============================================================================
--- doctools/branches/0.4.x/CHANGES (original)
+++ doctools/branches/0.4.x/CHANGES Fri Jul 18 23:51:28 2008
@@ -1,6 +1,9 @@
Release 0.4.2 (in development)
==============================
+* Don't automatically enclose code with whitespace in it in quotes;
+ only do this for the ``samp`` role.
+
* autodoc now emits a more precise error message when a module
can't be imported or an attribute can't be found.
Modified: doctools/branches/0.4.x/sphinx/latexwriter.py
==============================================================================
--- doctools/branches/0.4.x/sphinx/latexwriter.py (original)
+++ doctools/branches/0.4.x/sphinx/latexwriter.py Fri Jul 18 23:51:28 2008
@@ -873,7 +873,7 @@
content = self.encode(node.astext().strip())
if self.in_title:
self.body.append(r'\texttt{%s}' % content)
- elif re.search('[ \t\n]', content):
+ elif node.has_key('role') and node['role'] == 'samp':
self.body.append(r'\samp{%s}' % content)
else:
self.body.append(r'\code{%s}' % content)
Modified: doctools/branches/0.4.x/sphinx/roles.py
==============================================================================
--- doctools/branches/0.4.x/sphinx/roles.py (original)
+++ doctools/branches/0.4.x/sphinx/roles.py Fri Jul 18 23:51:28 2008
@@ -195,17 +195,17 @@
def emph_literal_role(typ, rawtext, text, lineno, inliner, options={}, content=[]):
text = utils.unescape(text)
- retnodes = []
pos = 0
+ retnode = nodes.literal(role=typ)
for m in _litvar_re.finditer(text):
if m.start() > pos:
txt = text[pos:m.start()]
- retnodes.append(nodes.literal(txt, txt))
- retnodes.append(nodes.emphasis('', '', nodes.literal(m.group(1), m.group(1))))
+ retnode += nodes.Text(txt, txt)
+ retnode += nodes.emphasis(m.group(1), m.group(1))
pos = m.end()
if pos < len(text):
- retnodes.append(nodes.literal(text[pos:], text[pos:]))
- return retnodes, []
+ retnode += nodes.Text(text[pos:], text[pos:])
+ return [retnode], []
specific_docroles = {
More information about the Python-checkins
mailing list