在 Sphinx 中使用 iframe 嵌入外部 html 文件

Embed external html file using iframe in Sphinx

我正在尝试使用 iframe:

在 reStructuredText 文档中嵌入交互式图形,该图形另存为 html 文件
.. raw:: html

    <iframe src="filename.html" height="345px" width="100%"></iframe>

html 文件与我的 .rst 文件位于同一目录中,但图表不显示,我收到 file could not be found 错误。

但是,如果我将外部 html 文件粘贴到 _build/html 目录中,图表显示正常。如何正确嵌入此 html 文件,以便在 make html?

时自动嵌入图形

Working example of the thing that I want.

您可以将文件 filename.html 放在您的 source/_static 目录中。然后它将被复制到 build/html/_static,因此您必须将 iframe 属性替换为 src="_static/filename.html"

你也可以直接包含一个文件:

.. raw:: html
   :file: filename.html

可能不是您想要的,但可能会帮助来自google...

的其他人