图像未显示在 reStructuredText (.rst) - HTML - 在 VS Code 中预览

Images are not displayed in reStructuredText (.rst) - HTML - preview in VS Code

根据 docs,图像应该可以在 HTML 预览中显示,如下所示:

.. image:: /path/to/image.jpg

然而,在 VS Code version 1.56.2 on Windows 10 with the reStructuredTest - extension 上,HTML 预览不显示真实图片,仅显示占位符。 我在 UNIX 和 Windows 类路径上都尝试过:

我使用的代码是:

...
4) ...
5) .. image:: C:\Users\andreas.luckert\Downloads\Step-Functions-page1.png
6) .. image:: /c/Users/andreas.luckert/Downloads/Step-Functions-page2.png

您提供的link未到official Sphinx docs, but a wiki page. Here are the docs for handling images

reST supports an image directive (ref), used like so:

.. image:: gnu.png
    (options)

When used within Sphinx, the file name given (here gnu.png) must either be relative to the source file, or absolute which means that they are relative to the top source directory. For example, the file sketch/spam.rst could refer to the image images/spam.png as ../images/spam.png or /images/spam.png.

Sphinx will automatically copy image files over to a subdirectory of the output directory on building (e.g. the _static directory for HTML output.)

因此,将您的图像放在顶级源目录中名为 _static 的目录中,然后按如下方式更新图像的相对路径。

.. image:: _static/path/to/my-image.png
    (options)