我有兴趣知道是否可以将本地图像嵌入到美人鱼图表上。我正在尝试使用Mermaid_cli进行此操作,因为它是在本地安装在我的计算机上的,因此从理论上讲,它应该更容易访问本地文件。
这是我一直在尝试的代码(Chart.mmd):
%%{init: { "securityLevel": "loose", "flowchart": { "htmlLabels": true } } }%%
flowchart LR;
A( <img src='C:/path/image.png' height='200px' width='200px'/> )--> B & C & D;
B--> A & E;
C--> A & E;
D--> A & E;
E--> B & C & D;
然后我称其
mmdc -i chart.mmd -o chart_cli.png
为不会呈现图像。但是,我已将图像上传到我的GitHub存储库上,并提供了URL,然后它起作用。我想知道是否可以跳过上传图像并使用文件路径的步骤。我还尝试了“文件:// c:/...”的不同变体,但无济于事。提前致谢!
I am interested in knowing if it is theoretically possible to embed a local image onto a mermaid chart. I am trying to do this with mermaid_cli since it is installed locally on my machine and it should therefore in theory be easier to access local files.
This is the code I have been trying (chart.mmd):
%%{init: { "securityLevel": "loose", "flowchart": { "htmlLabels": true } } }%%
flowchart LR;
A( <img src='C:/path/image.png' height='200px' width='200px'/> )--> B & C & D;
B--> A & E;
C--> A & E;
D--> A & E;
E--> B & C & D;
and then I'm calling
mmdc -i chart.mmd -o chart_cli.png
It will not render the image. However, I have uploaded the image onto my GitHub repository and provided the URL then it works. I was wondering if I could skip the step of uploading an image and just use the file path. I have also tried different variations of 'file://C:/...' but to no avail. Thanks in advance!
发布评论
评论(2)
我弄清楚了!在文件路径为我工作之前添加//。例如:
I figured it out! Adding // before the file path worked for me. For example:
在我看来,美人鱼试图从某些服务器加载图像。但是,由于图像是在本地存储的,因此我使用Python HTTP服务器在本地创建服务器。
只需打开命令提示符或同等标准,请移动到包含图像的文件夹,然后运行给定命令以创建HTTP服务器。
接下来使用 IP地址和端口号,创建所需的URL。在我的情况下,IP地址为“ 127.0.0.1”,端口号为“ 8000”,因此所需的链接为
最后,您可以将代码嵌入为,
It seems to me that mermaid tries to load images from some server. However since the images are stored locally, I am making use of python http server to create a server locally.
Just open command prompt or equivalent, move to the folder that contain your images and run the given command to create http server.
Next using ip address and port number, create the required url. In my case, ip address was "127.0.0.1" and port number was "8000", so the required link is http://127.0.0.1:8000/
Finally you can embed code as,