diff options
author | zhaohuabing <zhaohuabing@gmail.com> | 2022-06-30 08:31:56 +0300 |
---|---|---|
committer | zhaohuabing <zhaohuabing@gmail.com> | 2022-06-30 08:44:32 +0300 |
commit | c48c8628f6c6938dd1c1c52a00521f6785e34706 (patch) | |
tree | 00c1405d683a88318ad39c72b7b512c5429aae23 | |
parent | fe526c5444d5e533c71d49f83ec2d46b129f4ea7 (diff) |
support plantuml
Signed-off-by: zhaohuabing <zhaohuabing@gmail.com>
-rw-r--r-- | README.md | 27 | ||||
-rw-r--r-- | images/plantuml.png | bin | 0 -> 6816 bytes | |||
-rw-r--r-- | layouts/partials/footer.html | 16 |
3 files changed, 43 insertions, 0 deletions
@@ -243,6 +243,33 @@ Vimeo {{< vimeo 146022717 >}}
```
+### Plantuml
+
+Plantuml support can be enabled at site or page level by adding the following line in the config.yaml or page header.
+
+```
+plantuml: true
+```
+
+Then you can just put plantuml source code in markdown files and the picture will be generated automatically.
+
+An example:
+
+```
+```plantuml
+@startuml
+Alice -> Bob: Authentication Request
+Bob --> Alice: Authentication Response
+
+Alice -> Bob: Another authentication Request
+Alice <-- Bob: Another authentication Response
+@enduml
+```
+```
+
+![screenshot](https://raw.githubusercontent.com/zhaohuabing/hugo-theme-cleanwhite/master/images/plantuml.png)
+
+
## Thanks
Thanks for the great jobs of [huxblog Jekyll Theme](https://github.com/Huxpro/huxpro.github.io) and [Clean Blog Jekyll Theme](https://github.com/BlackrockDigital/startbootstrap-clean-blog-jekyll) which are the the two upstream projects CleanWhite Hugo theme is based on.
diff --git a/images/plantuml.png b/images/plantuml.png Binary files differnew file mode 100644 index 0000000..4158771 --- /dev/null +++ b/images/plantuml.png diff --git a/layouts/partials/footer.html b/layouts/partials/footer.html index f061726..281587e 100644 --- a/layouts/partials/footer.html +++ b/layouts/partials/footer.html @@ -430,3 +430,19 @@ </script> {{ end }} +{{ if or .Page.Params.plantuml .Site.Params.plantuml }} +<!-- PlantUML --> +<script src="https://cdn.jsdelivr.net/gh/jmnote/plantuml-encoder@1.2.4/dist/plantuml-encoder.min.js" integrity="sha256-Qsk2KRBCN5qVZX7B+8+2IvQl1Aqc723qV1tBCQaVoqo=" crossorigin="anonymous"></script> +<script> +(function(){ + let plantumlPrefix = "language-plantuml"; + Array.prototype.forEach.call(document.querySelectorAll("[class^=" + plantumlPrefix + "]"), function(code){ + let image = document.createElement("IMG"); + image.loading = 'lazy'; // Lazy loading + image.src = 'http://www.plantuml.com/plantuml/svg/~1' + plantumlEncoder.encode(code.innerText); + code.parentNode.parentNode.insertBefore(image, code.parentNode); + code.parentNode.style.display = 'none'; + }); +})(); +</script> +{{ end }} |