sphinx-doc / sphinx-doc/sphinx

Can't generate correct filename for a specific downloaded image for .tex

Open
#7,801 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

builder:latex type:bug
Dominant language
Python
Stars
8k
Forks
2.6k
PR merge metrics
No merged PRs in 30d

Description

Describe the bug
When .rst contain remote image like https://img.shields.io/badge/linux%20kernel-5.1-green, it will generate incorrect file name that can't be parsed by latex,

\noindent{\hspace*{\fill}\sphinxincludegraphics{{test_doc/_build/doctrees/images/83b85f2d6c1db9b7d1e27fc64644d4b3bcab8852/linux%20kernel-5}.1-green}}

Thus make latexpdf would fail.

To Reproduce
Steps to reproduce the behavior:

  1. Prepare a .rst file contains the following content
.. image:: https://img.shields.io/badge/linux%20kernel-5.1-green
    :align: right
  1. make pdflatex
Runaway argument?
{{test_doc/_build/doctrees/images/83b85f2d6\ETC.
! Paragraph ended before \\sphinxsafeincludegraphics was complete.
<to be read again>
                   \par

Expected behavior

sphinx could generate the correct file name and make latexpdf will succeed.

Environment info

  • OS: [e.g. Unix/Linux/Mac/Win/other with version]
  • Python version: 3.8
  • Sphinx version: 3.0.4
  • Sphinx extensions: None

Additional context

I encounter this issue when trying to compile https://github.com/shuveb/loti using sphinx. If this issue is fixed, we need to instruct sphinx to use xelatex to handle some special UTF-8 characters (see #4136) and to use sphinx.ext.imgconverter to include svg images,

extensions = ['manpage', 'sphinx.ext.imgconverter']
latex_engine = 'xelatex'
latex_elements = {}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue with a .rst image using make latexpdf or make pdflatex, then trace how Sphinx downloads the remote image and derives its filename for LaTeX output. Done means the generated filename does not break at the period in 5.1-green and the LaTeX build succeeds for the provided example.

Written by the indexing model from the issue text.

Assessment

Tech stack
latex, python
Domain
build-system, documentation
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.