Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #10434: extra whitespace in pdf output for highlighted inline code #10435

Merged
merged 1 commit into from May 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions sphinx/writers/latex.py
Expand Up @@ -1710,11 +1710,11 @@ def visit_literal(self, node: Element) -> None:
# 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:
Expand Down
4 changes: 2 additions & 2 deletions tests/test_build_latex.py
Expand Up @@ -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