mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Fix #10434: extra whitespace in pdf output for highlighted inline code
Related: #10251
This commit is contained in:
@@ -1710,11 +1710,11 @@ class LaTeXTranslator(SphinxTranslator):
|
||||
# TODO: Use nowrap option once LaTeX formatter supports it
|
||||
# https://github.com/pygments/pygments/pull/1343
|
||||
hlcode = hlcode.replace(r'\begin{Verbatim}[commandchars=\\\{\}]',
|
||||
r'\sphinxcode{\sphinxupquote{')
|
||||
r'\sphinxcode{\sphinxupquote{%')
|
||||
# get consistent trailer
|
||||
hlcode = hlcode.rstrip()[:-14] # strip \end{Verbatim}
|
||||
hlcode = hlcode.rstrip()[:-15] # strip \n\end{Verbatim}
|
||||
self.body.append(hlcode)
|
||||
self.body.append('}}')
|
||||
self.body.append('%' + CR + '}}')
|
||||
raise nodes.SkipNode
|
||||
|
||||
def depart_literal(self, node: Element) -> None:
|
||||
|
@@ -1623,7 +1623,7 @@ def test_latex_code_role(app):
|
||||
r'\PYG{p}{)}'
|
||||
r'\PYG{p}{:} '
|
||||
r'\PYG{k}{pass}')
|
||||
assert (r'Inline \sphinxcode{\sphinxupquote{' + '\n' +
|
||||
common_content + '\n}} code block') in content
|
||||
assert (r'Inline \sphinxcode{\sphinxupquote{%' + '\n' +
|
||||
common_content + '%\n}} code block') in content
|
||||
assert (r'\begin{sphinxVerbatim}[commandchars=\\\{\}]' +
|
||||
'\n' + common_content + '\n' + r'\end{sphinxVerbatim}') in content
|
||||
|
Reference in New Issue
Block a user