mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Closes #1174: Fix smart quotes being applied inside roles like :rst:role:program
or :rst:role:makevar
.
This commit is contained in:
parent
336ae30edb
commit
06364ca784
3
CHANGES
3
CHANGES
@ -18,6 +18,9 @@ New features
|
||||
Bugs fixed
|
||||
----------
|
||||
|
||||
* #1174: Fix smart quotes being applied inside roles like :rst:role:`program` or
|
||||
:rst:role:`makevar`.
|
||||
|
||||
* #1335: Fix autosummary template overloading with exclamation prefix like
|
||||
``{% extends "!autosummary/class.rst" %}`` cause infinite recursive function
|
||||
call. This caused by PR#181.
|
||||
|
@ -199,10 +199,13 @@ the following public API:
|
||||
.. index:: pair: function; directive
|
||||
|
||||
The reference node will be of class ``literal`` (so it will be rendered in a
|
||||
proportional font, as appropriate for code) unless you give the *ref_nodeclass*
|
||||
argument, which must be a docutils node class (most useful are
|
||||
``docutils.nodes.emphasis`` or ``docutils.nodes.strong`` -- you can also use
|
||||
``docutils.nodes.generated`` if you want no further text decoration).
|
||||
proportional font, as appropriate for code) unless you give the
|
||||
*ref_nodeclass* argument, which must be a docutils node class. Most useful
|
||||
are ``docutils.nodes.emphasis`` or ``docutils.nodes.strong`` -- you can also
|
||||
use ``docutils.nodes.generated`` if you want no further text decoration. If
|
||||
the text should be treated as literal (e.g. no smart quote replacement), but
|
||||
not have typewriter styling, use ``sphinx.addnodes.literal_emphasis`` or
|
||||
``sphinx.addnodes.literal_strong``.
|
||||
|
||||
For the role content, you have the same syntactical possibilities as for
|
||||
standard Sphinx roles (see :ref:`xref-syntax`).
|
||||
|
@ -168,6 +168,11 @@ class literal_emphasis(nodes.emphasis):
|
||||
applied (e.g. smartypants for HTML output).
|
||||
"""
|
||||
|
||||
class literal_strong(nodes.strong):
|
||||
"""Node that behaves like `strong`, but further text processors are not
|
||||
applied (e.g. smartypants for HTML output).
|
||||
"""
|
||||
|
||||
class abbreviation(nodes.Inline, nodes.TextElement):
|
||||
"""Node for abbreviations with explanations."""
|
||||
|
||||
|
@ -22,15 +22,15 @@ from sphinx.util.nodes import split_explicit_title, process_index_entry, \
|
||||
|
||||
|
||||
generic_docroles = {
|
||||
'command' : nodes.strong,
|
||||
'command' : addnodes.literal_strong,
|
||||
'dfn' : nodes.emphasis,
|
||||
'kbd' : nodes.literal,
|
||||
'mailheader' : addnodes.literal_emphasis,
|
||||
'makevar' : nodes.strong,
|
||||
'makevar' : addnodes.literal_strong,
|
||||
'manpage' : addnodes.literal_emphasis,
|
||||
'mimetype' : addnodes.literal_emphasis,
|
||||
'newsgroup' : addnodes.literal_emphasis,
|
||||
'program' : nodes.strong, # XXX should be an x-ref
|
||||
'program' : addnodes.literal_strong, # XXX should be an x-ref
|
||||
'regexp' : nodes.literal,
|
||||
}
|
||||
|
||||
|
@ -99,7 +99,8 @@ class GroupedField(Field):
|
||||
return Field.make_field(self, types, domain, items[0])
|
||||
for fieldarg, content in items:
|
||||
par = nodes.paragraph()
|
||||
par += self.make_xref(self.rolename, domain, fieldarg, nodes.strong)
|
||||
par += self.make_xref(self.rolename, domain, fieldarg,
|
||||
addnodes.literal_strong)
|
||||
par += nodes.Text(' -- ')
|
||||
par += content
|
||||
listnode += nodes.list_item('', par)
|
||||
@ -137,7 +138,8 @@ class TypedField(GroupedField):
|
||||
def make_field(self, types, domain, items):
|
||||
def handle_item(fieldarg, content):
|
||||
par = nodes.paragraph()
|
||||
par += self.make_xref(self.rolename, domain, fieldarg, nodes.strong)
|
||||
par += self.make_xref(self.rolename, domain, fieldarg,
|
||||
addnodes.literal_strong)
|
||||
if fieldarg in types:
|
||||
par += nodes.Text(' (')
|
||||
# NOTE: using .pop() here to prevent a single type node to be
|
||||
|
@ -492,6 +492,11 @@ class HTMLTranslator(BaseTranslator):
|
||||
def depart_literal_emphasis(self, node):
|
||||
return self.depart_emphasis(node)
|
||||
|
||||
def visit_literal_strong(self, node):
|
||||
return self.visit_strong(node)
|
||||
def depart_literal_strong(self, node):
|
||||
return self.depart_strong(node)
|
||||
|
||||
def visit_abbreviation(self, node):
|
||||
attrs = {}
|
||||
if node.hasattr('explanation'):
|
||||
@ -602,6 +607,14 @@ class SmartyPantsHTMLTranslator(HTMLTranslator):
|
||||
self.depart_emphasis(node)
|
||||
self.no_smarty -= 1
|
||||
|
||||
def visit_literal_strong(self, node):
|
||||
self.no_smarty += 1
|
||||
self.visit_strong(node)
|
||||
|
||||
def depart_literal_strong(self, node):
|
||||
self.depart_strong(node)
|
||||
self.no_smarty -= 1
|
||||
|
||||
def visit_desc_signature(self, node):
|
||||
self.no_smarty += 1
|
||||
HTMLTranslator.visit_desc_signature(self, node)
|
||||
|
@ -1247,6 +1247,13 @@ class LaTeXTranslator(nodes.NodeVisitor):
|
||||
def depart_strong(self, node):
|
||||
self.body.append('}')
|
||||
|
||||
def visit_literal_strong(self, node):
|
||||
self.body.append(r'\textbf{\texttt{')
|
||||
self.no_contractions += 1
|
||||
def depart_literal_strong(self, node):
|
||||
self.body.append('}}')
|
||||
self.no_contractions -= 1
|
||||
|
||||
def visit_abbreviation(self, node):
|
||||
abbr = node.astext()
|
||||
self.body.append(r'\textsc{')
|
||||
|
@ -304,6 +304,11 @@ class ManualPageTranslator(BaseTranslator):
|
||||
def depart_literal_emphasis(self, node):
|
||||
return self.depart_emphasis(node)
|
||||
|
||||
def visit_literal_strong(self, node):
|
||||
return self.visit_strong(node)
|
||||
def depart_literal_strong(self, node):
|
||||
return self.depart_strong(node)
|
||||
|
||||
def visit_abbreviation(self, node):
|
||||
pass
|
||||
def depart_abbreviation(self, node):
|
||||
|
@ -1207,6 +1207,11 @@ class TexinfoTranslator(nodes.NodeVisitor):
|
||||
def depart_literal_emphasis(self, node):
|
||||
self.body.append('}')
|
||||
|
||||
def visit_literal_strong(self, node):
|
||||
self.body.append('@code{')
|
||||
def depart_literal_strong(self, node):
|
||||
self.body.append('}')
|
||||
|
||||
def visit_index(self, node):
|
||||
# terminate the line but don't prevent paragraph breaks
|
||||
if isinstance(node.parent, nodes.paragraph):
|
||||
|
@ -762,6 +762,11 @@ class TextTranslator(nodes.NodeVisitor):
|
||||
def depart_strong(self, node):
|
||||
self.add_text('**')
|
||||
|
||||
def visit_literal_strong(self, node):
|
||||
self.add_text('**')
|
||||
def depart_literal_strong(self, node):
|
||||
self.add_text('**')
|
||||
|
||||
def visit_abbreviation(self, node):
|
||||
self.add_text('')
|
||||
def depart_abbreviation(self, node):
|
||||
|
Loading…
Reference in New Issue
Block a user