Markdown中嵌入PlantUML

应用场景

使用VSCode阅读Markdown文件,希望能够直接内嵌PlantUML,并能在VSCode中阅读时能渲染PlantUML。

实现方法

  1. 在VSCode中安装PlantUML插件。
  2. 进入VSCode设置,选择“在settings.json中编辑”。
  3. 在打开的json文件中末尾加上
    1
    2
    "plantuml.render": "PlantUMLServer",
    "plantuml.server": "http://www.plantuml.com/plantuml"
    • server配置的是官方PlantUML的解析服务器地址。如需要自建PlantUML解析服务器:GitHub项目地址
  4. 在VSCode中按下快捷键Ctrl+Shift+P显示显示命令面板,输入Markdown:Change Preview Security Settings,选择Allow insecure content 允许不安全内容
  5. 在你的Markdown文件中,使用以下格式就能嵌入PlantUML
    1
    2
    3
    4
    5
    6
    7
    ```plantuml
    Class01 <|-- Class02
    Class03 *-- Class04
    Class05 o-- Class06
    Class07 .. Class08
    Class09 -- Class10
    ```