Fix #3207: latex issue with references from inside parsed-literal

This reverts commit e25cce1a64
in order to move ``\detokenize`` insertion away from latex writer
to inside the ``\DUrole`` definition in sphinx.sty.
This commit is contained in:
jfbu
2016-12-09 09:45:44 +01:00
parent e25cce1a64
commit e9c472c851
4 changed files with 11 additions and 11 deletions

View File

@@ -946,11 +946,11 @@
% inline markup (custom roles)
% \DUrole{#1}{#2} tries \DUrole#1{#2}
\providecommand*{\DUrole}[2]{%
\ifcsname DUrole#1\endcsname
\csname DUrole#1\endcsname{#2}%
\ifcsname DUrole\detokenize{#1}\endcsname
\csname DUrole\detokenize{#1}\endcsname{#2}%
\else% backwards compatibility: try \docutilsrole#1{#2}
\ifcsname docutilsrole#1\endcsname
\csname docutilsrole#1\endcsname{#2}%
\ifcsname docutilsrole\detokenize{#1}\endcsname
\csname docutilsrole\detokenize{#1}\endcsname{#2}%
\else
#2%
\fi

View File

@@ -2117,7 +2117,7 @@ class LaTeXTranslator(nodes.NodeVisitor):
self.body.append(r'\sphinxaccelerator{')
self.context.append('}')
elif classes and not self.in_title:
self.body.append(r'\DUrole{\detokenize{%s}}{' % ','.join(classes))
self.body.append(r'\DUrole{%s}{' % ','.join(classes))
self.context.append('}')
else:
self.context.append('')

View File

@@ -461,8 +461,8 @@ def test_reference_in_caption_and_codeblock_in_footnote(app, status, warning):
'\sphinxAtStartFootnote\n'
'Foot note in longtable\n%\n\\end{footnotetext}' in result)
assert ('This is a reference to the code-block in the footnote:\n'
'{\\hyperref[index:codeblockinfootnote]{\\sphinxcrossref{\\DUrole'
'{\\detokenize{std,std-ref}}{I am in a footnote}}}}') in result
'{\hyperref[index:codeblockinfootnote]{\\sphinxcrossref{\\DUrole'
'{std,std-ref}{I am in a footnote}}}}') in result
assert ('&\nThis is one more footnote with some code in it '
'\\sphinxfootnotemark[10].\n\\\\') in result
assert '\\begin{sphinxVerbatim}[commandchars=\\\\\\{\\}]' in result

View File

@@ -80,10 +80,10 @@ def test_code_block_namedlink_latex(app, status, warning):
latex = (app.outdir / 'Python.tex').text(encoding='utf-8')
label1 = '\def\sphinxLiteralBlockLabel{\label{caption:name-test-rb}}'
link1 = '\\hyperref[caption:name\\string-test\\string-rb]'\
'{\\sphinxcrossref{\\DUrole{\\detokenize{std,std-ref}}{Ruby}}'
'{\\sphinxcrossref{\\DUrole{std,std-ref}{Ruby}}'
label2 = '\def\sphinxLiteralBlockLabel{\label{namedblocks:some-ruby-code}}'
link2 = '\\hyperref[namedblocks:some\\string-ruby\\string-code]'\
'{\\sphinxcrossref{\\DUrole{\\detokenize{std,std-ref}}{the ruby code}}}'
'{\\sphinxcrossref{\\DUrole{std,std-ref}{the ruby code}}}'
assert label1 in latex
assert link1 in latex
assert label2 in latex
@@ -275,10 +275,10 @@ def test_literalinclude_namedlink_latex(app, status, warning):
latex = (app.outdir / 'Python.tex').text(encoding='utf-8')
label1 = '\def\sphinxLiteralBlockLabel{\label{caption:name-test-py}}'
link1 = '\\hyperref[caption:name\\string-test\\string-py]'\
'{\\sphinxcrossref{\\DUrole{\\detokenize{std,std-ref}}{Python}}'
'{\\sphinxcrossref{\\DUrole{std,std-ref}{Python}}'
label2 = '\def\sphinxLiteralBlockLabel{\label{namedblocks:some-python-code}}'
link2 = '\\hyperref[namedblocks:some\\string-python\\string-code]'\
'{\\sphinxcrossref{\\DUrole{\\detokenize{std,std-ref}}{the python code}}}'
'{\\sphinxcrossref{\\DUrole{std,std-ref}{the python code}}}'
assert label1 in latex
assert link1 in latex
assert label2 in latex