mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Fix generating emphasis nodes without semantic reason
Roles ``ref``, ``term`` and ``menusel`` now don't generate :durole:`emphasis` nodes anymore. If you want to keep italic style, adapt your stylesheet.
This commit is contained in:
parent
ea97e6658c
commit
8a273d139b
10
CHANGES
10
CHANGES
@ -1,3 +1,13 @@
|
|||||||
|
Release 1.3 (in development)
|
||||||
|
============================
|
||||||
|
|
||||||
|
Incompatible changes
|
||||||
|
--------------------
|
||||||
|
|
||||||
|
* Roles ``ref``, ``term`` and ``menusel`` now don't generate :durole:`emphasis`
|
||||||
|
nodes anymore. If you want to keep italic style, adapt your stylesheet.
|
||||||
|
|
||||||
|
|
||||||
Release 1.3b3 (released Feb 24, 2015)
|
Release 1.3b3 (released Feb 24, 2015)
|
||||||
=====================================
|
=====================================
|
||||||
|
|
||||||
|
@ -462,10 +462,10 @@ class StandardDomain(Domain):
|
|||||||
# links to tokens in grammar productions
|
# links to tokens in grammar productions
|
||||||
'token': XRefRole(),
|
'token': XRefRole(),
|
||||||
# links to terms in glossary
|
# links to terms in glossary
|
||||||
'term': XRefRole(lowercase=True, innernodeclass=nodes.emphasis,
|
'term': XRefRole(lowercase=True, innernodeclass=nodes.inline,
|
||||||
warn_dangling=True),
|
warn_dangling=True),
|
||||||
# links to headings or arbitrary labels
|
# links to headings or arbitrary labels
|
||||||
'ref': XRefRole(lowercase=True, innernodeclass=nodes.emphasis,
|
'ref': XRefRole(lowercase=True, innernodeclass=nodes.inline,
|
||||||
warn_dangling=True),
|
warn_dangling=True),
|
||||||
# links to labels of numbered figures, tables and code-blocks
|
# links to labels of numbered figures, tables and code-blocks
|
||||||
'numref': XRefRole(lowercase=True,
|
'numref': XRefRole(lowercase=True,
|
||||||
@ -584,7 +584,7 @@ class StandardDomain(Domain):
|
|||||||
**options):
|
**options):
|
||||||
nodeclass = options.pop('nodeclass', nodes.reference)
|
nodeclass = options.pop('nodeclass', nodes.reference)
|
||||||
newnode = nodeclass('', '', internal=True, **options)
|
newnode = nodeclass('', '', internal=True, **options)
|
||||||
innernode = nodes.emphasis(sectname, sectname)
|
innernode = nodes.inline(sectname, sectname)
|
||||||
if docname == fromdocname:
|
if docname == fromdocname:
|
||||||
newnode['refid'] = labelid
|
newnode['refid'] = labelid
|
||||||
else:
|
else:
|
||||||
|
@ -243,7 +243,7 @@ def menusel_role(typ, rawtext, text, lineno, inliner, options={}, content=[]):
|
|||||||
text = text.replace('-->', u'\N{TRIANGULAR BULLET}')
|
text = text.replace('-->', u'\N{TRIANGULAR BULLET}')
|
||||||
spans = _amp_re.split(text)
|
spans = _amp_re.split(text)
|
||||||
|
|
||||||
node = nodes.emphasis(rawtext=rawtext)
|
node = nodes.inline(rawtext=rawtext)
|
||||||
for i, span in enumerate(spans):
|
for i, span in enumerate(spans):
|
||||||
span = span.replace('&&', '&')
|
span = span.replace('&&', '&')
|
||||||
if i == 0:
|
if i == 0:
|
||||||
|
@ -1249,11 +1249,12 @@ class LaTeXTranslator(nodes.NodeVisitor):
|
|||||||
# references to labels in the same document
|
# references to labels in the same document
|
||||||
id = self.curfilestack[-1] + ':' + uri[1:]
|
id = self.curfilestack[-1] + ':' + uri[1:]
|
||||||
self.body.append(self.hyperlink(id))
|
self.body.append(self.hyperlink(id))
|
||||||
|
self.body.append(r'\emph{')
|
||||||
if self.builder.config.latex_show_pagerefs and not \
|
if self.builder.config.latex_show_pagerefs and not \
|
||||||
self.in_production_list:
|
self.in_production_list:
|
||||||
self.context.append('}} (%s)' % self.hyperpageref(id))
|
self.context.append('}}} (%s)' % self.hyperpageref(id))
|
||||||
else:
|
else:
|
||||||
self.context.append('}}')
|
self.context.append('}}}')
|
||||||
elif uri.startswith('%'):
|
elif uri.startswith('%'):
|
||||||
# references to documents or labels inside documents
|
# references to documents or labels inside documents
|
||||||
hashindex = uri.find('#')
|
hashindex = uri.find('#')
|
||||||
@ -1264,16 +1265,17 @@ class LaTeXTranslator(nodes.NodeVisitor):
|
|||||||
# reference to a label
|
# reference to a label
|
||||||
id = uri[1:].replace('#', ':')
|
id = uri[1:].replace('#', ':')
|
||||||
self.body.append(self.hyperlink(id))
|
self.body.append(self.hyperlink(id))
|
||||||
|
self.body.append(r'\emph{')
|
||||||
if len(node) and hasattr(node[0], 'attributes') and \
|
if len(node) and hasattr(node[0], 'attributes') and \
|
||||||
'std-term' in node[0].get('classes', []):
|
'std-term' in node[0].get('classes', []):
|
||||||
# don't add a pageref for glossary terms
|
# don't add a pageref for glossary terms
|
||||||
self.context.append('}}')
|
self.context.append('}}}')
|
||||||
else:
|
else:
|
||||||
if self.builder.config.latex_show_pagerefs and not \
|
if self.builder.config.latex_show_pagerefs and not \
|
||||||
self.in_production_list:
|
self.in_production_list:
|
||||||
self.context.append('}} (%s)' % self.hyperpageref(id))
|
self.context.append('}}} (%s)' % self.hyperpageref(id))
|
||||||
else:
|
else:
|
||||||
self.context.append('}}')
|
self.context.append('}}}')
|
||||||
else:
|
else:
|
||||||
self.builder.warn('unusable reference target found: %s' % uri,
|
self.builder.warn('unusable reference target found: %s' % uri,
|
||||||
(self.curfilestack[-1], node.line))
|
(self.curfilestack[-1], node.line))
|
||||||
@ -1545,7 +1547,10 @@ class LaTeXTranslator(nodes.NodeVisitor):
|
|||||||
|
|
||||||
def visit_inline(self, node):
|
def visit_inline(self, node):
|
||||||
classes = node.get('classes', [])
|
classes = node.get('classes', [])
|
||||||
self.body.append(r'\DUspan{%s}{' % ','.join(classes))
|
if classes in [['menuselection'], ['guilabel']]:
|
||||||
|
self.body.append(r'\emph{')
|
||||||
|
else:
|
||||||
|
self.body.append(r'\DUspan{%s}{' % ','.join(classes))
|
||||||
def depart_inline(self, node):
|
def depart_inline(self, node):
|
||||||
self.body.append('}')
|
self.body.append('}')
|
||||||
|
|
||||||
|
@ -823,9 +823,11 @@ class TextTranslator(nodes.NodeVisitor):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
def visit_inline(self, node):
|
def visit_inline(self, node):
|
||||||
pass
|
if 'xref' in node['classes'] or 'term' in node['classes']:
|
||||||
|
self.add_text('*')
|
||||||
def depart_inline(self, node):
|
def depart_inline(self, node):
|
||||||
pass
|
if 'xref' in node['classes'] or 'term' in node['classes']:
|
||||||
|
self.add_text('*')
|
||||||
|
|
||||||
def visit_container(self, node):
|
def visit_container(self, node):
|
||||||
pass
|
pass
|
||||||
|
@ -134,7 +134,7 @@ HTML_XPATH = {
|
|||||||
(".//li/strong", r'^program\\n$'),
|
(".//li/strong", r'^program\\n$'),
|
||||||
(".//li/em", r'^dfn\\n$'),
|
(".//li/em", r'^dfn\\n$'),
|
||||||
(".//li/code/span[@class='pre']", r'^kbd\\n$'),
|
(".//li/code/span[@class='pre']", r'^kbd\\n$'),
|
||||||
(".//li/em", u'File \N{TRIANGULAR BULLET} Close'),
|
(".//li/span", u'File \N{TRIANGULAR BULLET} Close'),
|
||||||
(".//li/code/span[@class='pre']", '^a/$'),
|
(".//li/code/span[@class='pre']", '^a/$'),
|
||||||
(".//li/code/em/span[@class='pre']", '^varpart$'),
|
(".//li/code/em/span[@class='pre']", '^varpart$'),
|
||||||
(".//li/code/em/span[@class='pre']", '^i$'),
|
(".//li/code/em/span[@class='pre']", '^i$'),
|
||||||
@ -188,7 +188,7 @@ HTML_XPATH = {
|
|||||||
(".//p", 'In both.'),
|
(".//p", 'In both.'),
|
||||||
(".//p", 'Always present'),
|
(".//p", 'Always present'),
|
||||||
# tests for ``any`` role
|
# tests for ``any`` role
|
||||||
(".//a[@href='#with']/em", 'headings'),
|
(".//a[@href='#with']/span", 'headings'),
|
||||||
(".//a[@href='objects.html#func_without_body']/code/span", 'objects'),
|
(".//a[@href='objects.html#func_without_body']/code/span", 'objects'),
|
||||||
],
|
],
|
||||||
'objects.html': [
|
'objects.html': [
|
||||||
@ -247,9 +247,9 @@ HTML_XPATH = {
|
|||||||
(".//div[@class='footer']", 'Georg Brandl & Team'),
|
(".//div[@class='footer']", 'Georg Brandl & Team'),
|
||||||
(".//a[@href='http://python.org/']"
|
(".//a[@href='http://python.org/']"
|
||||||
"[@class='reference external']", ''),
|
"[@class='reference external']", ''),
|
||||||
(".//li/a[@href='genindex.html']/em", 'Index'),
|
(".//li/a[@href='genindex.html']/span", 'Index'),
|
||||||
(".//li/a[@href='py-modindex.html']/em", 'Module Index'),
|
(".//li/a[@href='py-modindex.html']/span", 'Module Index'),
|
||||||
(".//li/a[@href='search.html']/em", 'Search Page'),
|
(".//li/a[@href='search.html']/span", 'Search Page'),
|
||||||
# custom sidebar only for contents
|
# custom sidebar only for contents
|
||||||
(".//h4", 'Contents sidebar'),
|
(".//h4", 'Contents sidebar'),
|
||||||
# custom JavaScript
|
# custom JavaScript
|
||||||
@ -554,12 +554,12 @@ def test_numfig_without_numbered_toctree(app, status, warning):
|
|||||||
"span[@class='caption-number']", '^Listing 9 $', True),
|
"span[@class='caption-number']", '^Listing 9 $', True),
|
||||||
(".//div[@class='code-block-caption']/"
|
(".//div[@class='code-block-caption']/"
|
||||||
"span[@class='caption-number']", '^Listing 10 $', True),
|
"span[@class='caption-number']", '^Listing 10 $', True),
|
||||||
(".//li/a/em", '^Fig. 9$', True),
|
(".//li/a/span", '^Fig. 9$', True),
|
||||||
(".//li/a/em", '^Figure6$', True),
|
(".//li/a/span", '^Figure6$', True),
|
||||||
(".//li/a/em", '^Table 9$', True),
|
(".//li/a/span", '^Table 9$', True),
|
||||||
(".//li/a/em", '^Table:6$', True),
|
(".//li/a/span", '^Table:6$', True),
|
||||||
(".//li/a/em", '^Listing 9$', True),
|
(".//li/a/span", '^Listing 9$', True),
|
||||||
(".//li/a/em", '^Code-6$', True),
|
(".//li/a/span", '^Code-6$', True),
|
||||||
],
|
],
|
||||||
'foo.html': [
|
'foo.html': [
|
||||||
(".//div[@class='figure']/p[@class='caption']/"
|
(".//div[@class='figure']/p[@class='caption']/"
|
||||||
@ -649,12 +649,12 @@ def test_numfig_with_numbered_toctree(app, status, warning):
|
|||||||
"span[@class='caption-number']", '^Listing 1 $', True),
|
"span[@class='caption-number']", '^Listing 1 $', True),
|
||||||
(".//div[@class='code-block-caption']/"
|
(".//div[@class='code-block-caption']/"
|
||||||
"span[@class='caption-number']", '^Listing 2 $', True),
|
"span[@class='caption-number']", '^Listing 2 $', True),
|
||||||
(".//li/a/em", '^Fig. 1$', True),
|
(".//li/a/span", '^Fig. 1$', True),
|
||||||
(".//li/a/em", '^Figure2.2$', True),
|
(".//li/a/span", '^Figure2.2$', True),
|
||||||
(".//li/a/em", '^Table 1$', True),
|
(".//li/a/span", '^Table 1$', True),
|
||||||
(".//li/a/em", '^Table:2.2$', True),
|
(".//li/a/span", '^Table:2.2$', True),
|
||||||
(".//li/a/em", '^Listing 1$', True),
|
(".//li/a/span", '^Listing 1$', True),
|
||||||
(".//li/a/em", '^Code-2.2$', True),
|
(".//li/a/span", '^Code-2.2$', True),
|
||||||
],
|
],
|
||||||
'foo.html': [
|
'foo.html': [
|
||||||
(".//div[@class='figure']/p[@class='caption']/"
|
(".//div[@class='figure']/p[@class='caption']/"
|
||||||
@ -747,12 +747,12 @@ def test_numfig_with_prefix(app, status, warning):
|
|||||||
"span[@class='caption-number']", '^Code-1 $', True),
|
"span[@class='caption-number']", '^Code-1 $', True),
|
||||||
(".//div[@class='code-block-caption']/"
|
(".//div[@class='code-block-caption']/"
|
||||||
"span[@class='caption-number']", '^Code-2 $', True),
|
"span[@class='caption-number']", '^Code-2 $', True),
|
||||||
(".//li/a/em", '^Figure:1$', True),
|
(".//li/a/span", '^Figure:1$', True),
|
||||||
(".//li/a/em", '^Figure2.2$', True),
|
(".//li/a/span", '^Figure2.2$', True),
|
||||||
(".//li/a/em", '^Tab_1$', True),
|
(".//li/a/span", '^Tab_1$', True),
|
||||||
(".//li/a/em", '^Table:2.2$', True),
|
(".//li/a/span", '^Table:2.2$', True),
|
||||||
(".//li/a/em", '^Code-1$', True),
|
(".//li/a/span", '^Code-1$', True),
|
||||||
(".//li/a/em", '^Code-2.2$', True),
|
(".//li/a/span", '^Code-2.2$', True),
|
||||||
],
|
],
|
||||||
'foo.html': [
|
'foo.html': [
|
||||||
(".//div[@class='figure']/p[@class='caption']/"
|
(".//div[@class='figure']/p[@class='caption']/"
|
||||||
@ -842,12 +842,12 @@ def test_numfig_with_secnum_depth(app, status, warning):
|
|||||||
"span[@class='caption-number']", '^Listing 1 $', True),
|
"span[@class='caption-number']", '^Listing 1 $', True),
|
||||||
(".//div[@class='code-block-caption']/"
|
(".//div[@class='code-block-caption']/"
|
||||||
"span[@class='caption-number']", '^Listing 2 $', True),
|
"span[@class='caption-number']", '^Listing 2 $', True),
|
||||||
(".//li/a/em", '^Fig. 1$', True),
|
(".//li/a/span", '^Fig. 1$', True),
|
||||||
(".//li/a/em", '^Figure2.1.2$', True),
|
(".//li/a/span", '^Figure2.1.2$', True),
|
||||||
(".//li/a/em", '^Table 1$', True),
|
(".//li/a/span", '^Table 1$', True),
|
||||||
(".//li/a/em", '^Table:2.1.2$', True),
|
(".//li/a/span", '^Table:2.1.2$', True),
|
||||||
(".//li/a/em", '^Listing 1$', True),
|
(".//li/a/span", '^Listing 1$', True),
|
||||||
(".//li/a/em", '^Code-2.1.2$', True),
|
(".//li/a/span", '^Code-2.1.2$', True),
|
||||||
],
|
],
|
||||||
'foo.html': [
|
'foo.html': [
|
||||||
(".//div[@class='figure']/p[@class='caption']/"
|
(".//div[@class='figure']/p[@class='caption']/"
|
||||||
|
@ -102,13 +102,13 @@ def test_inline():
|
|||||||
|
|
||||||
# interpolation of arrows in menuselection
|
# interpolation of arrows in menuselection
|
||||||
yield (verify, ':menuselection:`a --> b`',
|
yield (verify, ':menuselection:`a --> b`',
|
||||||
u'<p><em class="menuselection">a \N{TRIANGULAR BULLET} b</em></p>',
|
u'<p><span class="menuselection">a \N{TRIANGULAR BULLET} b</span></p>',
|
||||||
'\\emph{a \\(\\rightarrow\\) b}')
|
'\\emph{a \\(\\rightarrow\\) b}')
|
||||||
|
|
||||||
# interpolation of ampersands in guilabel/menuselection
|
# interpolation of ampersands in guilabel/menuselection
|
||||||
yield (verify, ':guilabel:`&Foo -&&- &Bar`',
|
yield (verify, ':guilabel:`&Foo -&&- &Bar`',
|
||||||
u'<p><em class="guilabel"><span class="accelerator">F</span>oo '
|
u'<p><span class="guilabel"><span class="accelerator">F</span>oo '
|
||||||
'-&- <span class="accelerator">B</span>ar</em></p>',
|
'-&- <span class="accelerator">B</span>ar</span></p>',
|
||||||
r'\emph{\DUspan{accelerator}{F}oo -\&- \DUspan{accelerator}{B}ar}')
|
r'\emph{\DUspan{accelerator}{F}oo -\&- \DUspan{accelerator}{B}ar}')
|
||||||
|
|
||||||
# non-interpolation of dashes in option role
|
# non-interpolation of dashes in option role
|
||||||
|
Loading…
Reference in New Issue
Block a user