简体   繁体   English

是否可以在Sphinx文档工具的html输出中嵌入音频文件?

[英]Is it possible to embed an audio file in the html output of the Sphinx documentation tool?

There probably isn't a specific directive for embedding audio files in the html output, but is it possible to at least embed an html code that does this, such as: 可能没有针对在html输出中嵌入音频文件的特定指令 ,但是是否可以至少嵌入执行此操作的html代码,例如:

<audio controls="controls">
  <source src="foo.wav" type="audio/wav">
  Your browser does not support the <code>audio</code> element. 
</audio>

And, if yes, how? 而且,如果是,怎么办?

Update: OK, I managed to solve this, simply adding this to the .rst document: 更新:好的,我设法解决了这个问题,只需将其添加到.rst文档中即可:

.. raw:: html

   <audio controls="controls">
         <source src="_static/foo.wav" type="audio/wav">
         Your browser does not support the <code>audio</code> element. 
   </audio>

But, I had to manually copy the foo.wav file into _build/html/_static . 但是,我必须手动将foo.wav文件复制到_build/html/_static This isn't that bad, but I was wondering whether this can be done automatically and if I can keep the audio files, say in, audio directory inside the docs root dir...?!? 这还不错,但是我想知道是否可以自动完成此操作,以及是否可以将音频文件(例如, audio目录)保留在docs root目录中?

Use the raw directive. 使用raw指令。

.. raw:: html

    <audio controls="controls">
      <source src="foo.wav" type="audio/wav">
      Your browser does not support the <code>audio</code> element. 
    </audio>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM