目录

Markdown PlantUML

Markdown搭配PlantUML画各种图

PlantUML的安装

包管理工具安装

PlantUML的运行需要Java环境,如果是用pacman之类的包管理工具安装,会自动安装jre.

#pacman -S plantuml

如果需要绘制时序图和活动图之外的图,还需要安装graphviz软件.

#pacman -S graphviz

手动安装

  1. 下载plantuml.jar文件,保存到本地目录.
  2. 用PlantUML书写你的文本文件.
  3. 用plantuml将你的PlantUML文件输出为图像,如:
java -jar plantuml.jar demo.txt

此时你将得到一个demo.png的图片.

在Markdown中使用PlantUML绘图

官网文档详细说明了PlantUML支持的各种图的语法.

docs.png

流程图

@startuml
(*) --> "Initialization"

if "Some Test" then
  -->[true] "Some Activity"
  --> "Another activity"
  -right-> (*)
else
  ->[false] "Something else"
  -->[Ending process] (*)
endif

@enduml
Diagram
Diagram

时序图

@startuml
== Initialization ==
Alice -> Bob: : Can you solve: <math>ax^2+bx+c=0</math>
Bob --> Alice: <math>x = (-b+-sqrt(b^2-4ac))/(2a)</math>
activate Alice #FFBBBB
note left: this is a first note

Alice -> Bob: Another dialogue
deactivate Alice

Alice <-- Bob: Another dialogue

@enduml
Diagram
Diagram

思维导图

思维导图还处于测试阶段,语法随时可能修改.

@startuml
@startmindmap
+ OS
++ Ubuntu
+++ Linux Mint
+++ Kubuntu
+++ Lubuntu
+++ KDE Neon
++ LMDE
++ SolydXK
++ SteamOS
++ Raspbian
-- Windows 95
-- Windows 98
-- Windows NT
--- Windows 8
--- Windows 10
@endmindmap
@enuml

mindmap.png

组织结构图

@startuml
@startwbs
+ New Job
++ Decide on Job Requirements
+++ Identity gaps
+++ Review JDs
++++ Sign-Up for courses
++++ Volunteer
++++ Reading
++- Checklist
+++- Responsibilities
+++- Location
++ CV Upload Done
+++ CV Updated
++++ Spelling & Grammar
++++ Check dates
---- Skills
+++ Recruitment sites chosen
@endwbs
@enduml

wbs.png

其他图形

除此之外,PlantUML还支持时序图,用例图,类图,组件图,状态图,对象图,部署图,定时图,Network,Wireframe,Archimate,Gantt等多种图形,具体语法可以查看官网文档