shuzo-kino.hateblo.jp
の続き的内容
ドキュメント生成ができるなら図表だってバージョン管理したくなるというもの。
大分まえから取り上げていて、Gitlabのmarkdownでも使えるplantUMLを使えるように
実際のところ
たたき台のDocker環境を用意
作業用のDocker環境をpandocの公式イメージから生成します
後々作業するため、WindowsのDocumentディレクトリをボリューム領域としてリンクさせておきます
$ docker.exe run -it --volume "C:\Users\user\Documents:/data" --name ourDocumentServer pandoc/core
必要なソフトウェア群の入手
普通にいれていればalpine linuxなのでapkでJavaRuntimeを入手
$ apk -U update $ apk add openjdk8-jre
plantuml.jarはplantUML公式から導入してWinの作業ディレクトリにおいておけばよいです。
さらに、変換用のLuaスクリプトも入れましょう。
lua-filters/diagram-generator at master · pandoc/lua-filters · GitHubから"diagram-generator.lua"を確保。
これもWinの作業ディレクトリでよいです。
実際に動かす
こんなサンプルファイルを用意します
$ cat foobar.md # My document This is a paragraph. ```{.plantuml} @startuml Alice -> Bob: Authentication Request Bob --> Alice: Authentication Response Alice -> Bob: Another authentication Request Alice <-- Bob: another authentication Response @enduml ```
これをレンダリングするには
$ pandoc foobar.md --lua-filter=diagram-generator.lua -t docx -o FOOBAR.docx
ditaaも使えるように
ここまで出来るなら、任意図面の自動化もしたいところ
shuzo-kino.hateblo.jp
$ apk add graphviz
今度は
$ cat foobar.md # My document This is a paragraph. ```{.plantuml} @startuml digraph foo { PlantUML -> Dot [label=use]; } @enduml ``` ```{.plantuml} @startuml ditaa +--------+ +-------+ +-------+ |cBLU +---+ ditaa +--> | | | Text | +-------+ |diagram| |Document| |!magic!| | | | {d}| | cRED | | | +---+----+ +-------+ +-------+ : ^ | Lots of work | +-------------------------+ @enduml ```
コマンドは変わらず
$ pandoc foobar.md --lua-filter=diagram-generator.lua -t docx -o FOOBAR.docx
結果、色分けされたZIGBEEのスタック図がご覧の通り