更新时间:2023-11-29 23:43:16
如果使用的是Markdown(.md
)文件来创建文章,则可以从字面上包括一个具有所需属性的图像元素:
If you're using a Markdown (.md
) file to create your article, then you can literally just include an image element with any attributes you like:
![This image is in Markdown format]({filename}/images/foo.png)
<img alt="This one is just a literal element" src="{filename}/images/bar.png" data-action="zoom" >
将成为:
<p><img alt="This image is in Markdown format" src="../images/foo.png"></p>
<p><img alt="This one is just a literal element" src="../images/bar.png" data-action="zoom"></p>
对于reStructuredText(.rst
)文章,您不能执行此操作; 根据文档仅支持有限的一组图像选项*,如果您只是尝试包含HTML内联,则会按原样呈现:
For reStructuredText (.rst
) articles, you can't do this; per the documentation only a limited set of image options are supported*, and if you just try and include HTML inline it gets rendered out as-is:
.. image:: {filename}/images/foo.png
:alt: this is an RST image directive
<img alt="This one is just a literal element" src="{filename}/images/bar.png" data-action="zoom">
成为:
<img alt="this is an RST image directive" src="../../../images/foo.png">
<p><img alt="This one is just a literal element" src="{filename}/images/bar.png" data-action="zoom"></p>
*具体为:alt
,height
,width
,scale
,align
,target
,class
和name
.
* Specifically: alt
, height
, width
, scale
, align
, target
, class
and name
.