以下代码保存为html文件,在浏览器访问会显示为两个plantuml图
<uml>
a -> b
</uml>
<br/>
<uml>
a -> b
</uml>
<script src="https://code.jquery.com/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/plantuml-encoder@1.4.0/dist/plantuml-encoder.min.js"></script>
<!--
若访问不到文件 plantuml-encoder.min.js,
控制台会报 Uncaught TypeError: Cannot read properties of undefined (reading 'encode')
网页查看
https://www.jsdelivr.com/package/npm/plantuml-encoder?tab=files&path=dist
-->
<script>
$("uml").each(function() {
var src = "https://www.plantuml.com/plantuml/svg/" + window.plantumlEncoder.encode( $(this).text() )
$(this).replaceWith($('<img>').attr('src', src));
});
</script>