Skip to content

%20 is not escaped in image file names/URLs for LaTeX #13189

Open
@Paebbels

Description

@Paebbels

Describe the bug

When a shield from Shields.io is embedded in the documentation, the URL might contain %20 for a space (or other escaped characters). This URL is used as filename without escaping/rewriting the percent-sign by Sphinx. When translating the document afterwards with LaTeX (xelatex), the document structure is broken, due to a comment sign (%).

Suggestion:

  • Remove all occurrences of %, or
  • rename all occurrences of % to _.

How to Reproduce

Example URL: https://raster.shields.io/badge/doc-CC--BY%204.0-green.png

This generates a shield with CC-BY 4.0 as text.
%20 is the space character:

Generated LaTeX Code:

\sphinxAtStartPar
\sphinxhref{https://GitHub.com/pyTooling/Actions}{\sphinxincludegraphics[height=22\sphinxpxdimen]{{pyTooling-Actions-63bf7f}.png}} \sphinxhref{https://GitHub.com/pyTooling/Actions/blob/main/LICENSE.md}{\sphinxincludegraphics[height=22\sphinxpxdimen]{{pyTooling}.png}} \sphinxhref{https://pyTooling.github.io/pyTooling/}{\sphinxincludegraphics[height=22\sphinxpxdimen]{{website}.png}} \sphinxhref{https://GitHub.com/pyTooling/Actions/blob/main/doc/License.rst}{\sphinxincludegraphics[height=22\sphinxpxdimen]{{doc-CC--BY%2041}.0-green}}
\sphinxhref{https://GitHub.com/pyTooling/Actions/tags}{\sphinxincludegraphics[height=22\sphinxpxdimen]{{Actions}.png}} \sphinxhref{https://GitHub.com/pyTooling/Actions/releases}{\sphinxincludegraphics[height=22\sphinxpxdimen]{{Actions1}.png}}

Produced LaTeX Error message:

Actions.tex: Error: 108: Paragraph ended before \sphinxhref was complete.

Environment Information

Platform:              win32; (Windows-11-10.0.22631-SP0)
Python version:        3.13.1 (tags/v3.13.1:0671451, Dec  3 2024, 19:06:28) [MSC v.1942 64 bit (AMD64)])
Python implementation: CPython
Sphinx version:        8.1.3
Docutils version:      0.21.2
Jinja2 version:        3.1.4
Pygments version:      2.18.0

Sphinx extensions

No extension needed for this bug.

Additional context

LaTeX environment: MikTeX (all updated)
LaTeX processor: xelatex

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions