diff --git a/ha-org-plantuml-example.png b/ha-org-plantuml-example.png new file mode 100644 index 0000000..7b77a76 Binary files /dev/null and b/ha-org-plantuml-example.png differ diff --git a/ha-org.org b/ha-org.org index 4aefbdd..28bdc0a 100644 --- a/ha-org.org +++ b/ha-org.org @@ -349,7 +349,7 @@ And turn on ALL the languages: (css . t) (plantuml . t))) #+END_SRC - +*** Graphviz The [[https://graphviz.org/][graphviz project]] can be written in org blocks, and then rendered as an image: #+NAME: ob-graphviz #+BEGIN_SRC emacs-lisp :tangle no @@ -377,6 +377,56 @@ For example: #+ATTR_ORG: :width 400px #+RESULTS: [[file:support/ha-org-graphviz-example.png]] +*** PlantUML +Need to install and configure Emacs to work with [[https://plantuml.com/][PlantUML]]. Granted, this is easier now that [[http://orgmode.org/worg/org-contrib/babel][Org-Babel]] natively supports [[http://eschulte.github.io/babel-dev/DONE-integrate-plantuml-support.html][blocks of plantuml code]]. First, [[https://plantuml.com/download][download the Jar]]. + +#+BEGIN_SRC sh + curl -o ~/bin/plantuml.jar https://github.com/plantuml/plantuml/releases/download/v1.2022.4/plantuml-1.2022.4.jar +#+END_SRC + +After installing the [[https://github.com/skuro/plantuml-mode][plantuml-mode]], we need to reference the location: +#+BEGIN_SRC emacs-lisp + (use-package plantuml-mode + :straight (:host github :repo "skuro/plantuml-mode") + :init + (setq org-plantuml-jar-path (expand-file-name "~/bin/plantuml.jar"))) +#+END_SRC + +With some [[file:snippets/org-mode/plantuml][YASnippets]], I have = Bob: Authentication Request + Bob --> Alice: Authentication Response + + Alice -> Bob: Another authentication Request + Alice <-- Bob: Another authentication Response + @enduml + #+end_src + +#+ATTR_ORG: :width 800px +[[file:ha-org-plantuml-example.png]] *** Next Image When I create images or other artifacts that I consider /part/ of the org document, I want to have them based on the org file, but with a prepended number. Keeping track of what numbers are now free is difficult, so for a /default/ let's figure it out: @@ -395,15 +445,6 @@ When I create images or other artifacts that I consider /part/ of the org docume (setq largest (max largest (string-to-number (match-string-no-properties 1))))) (format "%s-%02d" prefix (1+ largest))))) #+END_SRC -*** In a PlantUML Block -To make the snippets more context aware, this predicate - -#+BEGIN_SRC emacs-lisp -(defun ha-org-nested-in-plantuml-block () - "Predicate is true if point is inside a Plantuml Source code block in org-mode." - (equal "plantuml" - (plist-get (cadr (org-element-at-point)) :language))) -#+END_SRC ** Keybindings Global keybindings available to all file buffers: #+NAME: global-keybindings diff --git a/snippets/org-mode/activity-diagram b/snippets/org-mode/activity-diagram index 36a4ff6..424f099 100644 --- a/snippets/org-mode/activity-diagram +++ b/snippets/org-mode/activity-diagram @@ -2,7 +2,7 @@ # contributor: Howard Abrams # name: activity-diagram # key: activity -# condition: (ha/org-nested-in-plantuml-block) +# condition: (ha-org-nested-in-plantuml-block) # group: plantuml # -- ' See details at https://plantuml.com/activity-diagram-betastart diff --git a/snippets/org-mode/component-diagram b/snippets/org-mode/component-diagram index 67a43d6..a18ce9a 100644 --- a/snippets/org-mode/component-diagram +++ b/snippets/org-mode/component-diagram @@ -2,7 +2,7 @@ # contributor: Howard Abrams # name: component-diagram # key: component -# condition: (ha/org-nested-in-plantuml-block) +# condition: (ha-org-nested-in-plantuml-block) # group: plantuml # -- ' See details at https://plantuml.com/component-diagram diff --git a/snippets/org-mode/deployment-diagram b/snippets/org-mode/deployment-diagram index fe65b4f..2d9d7a7 100644 --- a/snippets/org-mode/deployment-diagram +++ b/snippets/org-mode/deployment-diagram @@ -2,7 +2,7 @@ # contributor: Howard Abrams # name: deployment-diagram # key: deployment -# condition: (ha/org-nested-in-plantuml-block) +# condition: (ha-org-nested-in-plantuml-block) # group: plantuml # -- ' See details at https://plantuml.com/deployment-diagram diff --git a/snippets/org-mode/object-diagram b/snippets/org-mode/object-diagram index 3876004..1e8c6d1 100644 --- a/snippets/org-mode/object-diagram +++ b/snippets/org-mode/object-diagram @@ -2,7 +2,7 @@ # contributor: Howard Abrams # name: object-diagram # key: object -# condition: (ha/org-nested-in-plantuml-block) +# condition: (ha-org-nested-in-plantuml-block) # group: plantuml # -- ' See details at https://plantuml.com/object-diagram diff --git a/snippets/org-mode/plantuml b/snippets/org-mode/plantuml index 48e7a57..969ee27 100644 --- a/snippets/org-mode/plantuml +++ b/snippets/org-mode/plantuml @@ -7,10 +7,11 @@ #+begin_src plantuml :file ${1:`(file-name-base (buffer-file-name)))`-`(ha-org-next-image-number)`}.${2:png} :exports file :results file @startuml -!include plantuml-dark-theme.puml +!include https://raw.githubusercontent.com/ptrkcsk/one-dark-plantuml-theme/v1.0.0/theme.puml ' See details at https://plantuml.com/ $0 @enduml #+end_src -#+ATTR_ORG: :width 800px \ No newline at end of file +#+ATTR_ORG: :width 800px +[[file:$1.$2]] \ No newline at end of file diff --git a/snippets/org-mode/sequence-diagram b/snippets/org-mode/sequence-diagram index ed2340e..644cfe2 100644 --- a/snippets/org-mode/sequence-diagram +++ b/snippets/org-mode/sequence-diagram @@ -2,7 +2,7 @@ # contributor: Howard Abrams # name: sequence-diagram # key: sequence -# condition: (ha/org-nested-in-plantuml-block) +# condition: (ha-org-nested-in-plantuml-block) # group: plantuml # -- ' See details at https://plantuml.com/sequence-diagram diff --git a/snippets/org-mode/state-diagram b/snippets/org-mode/state-diagram index a231392..0542fe9 100644 --- a/snippets/org-mode/state-diagram +++ b/snippets/org-mode/state-diagram @@ -2,7 +2,7 @@ # contributor: Howard Abrams # name: state-diagram # key: state -# condition: (ha/org-nested-in-plantuml-block) +# condition: (ha-org-nested-in-plantuml-block) # group: plantuml # -- ' See details at https://plantuml.com/state-diagram diff --git a/snippets/org-mode/timing-diagram b/snippets/org-mode/timing-diagram index f413a94..be2c24c 100644 --- a/snippets/org-mode/timing-diagram +++ b/snippets/org-mode/timing-diagram @@ -2,7 +2,7 @@ # contributor: Howard Abrams # name: timing-diagram # key: timing -# condition: (ha/org-nested-in-plantuml-block) +# condition: (ha-org-nested-in-plantuml-block) # group: plantuml # -- ' See details at https://plantuml.com/timing-diagram diff --git a/snippets/org-mode/use-case-diagram b/snippets/org-mode/use-case-diagram index 888af47..7af3013 100644 --- a/snippets/org-mode/use-case-diagram +++ b/snippets/org-mode/use-case-diagram @@ -2,7 +2,7 @@ # contributor: Howard Abrams # name: use-case-diagram # key: use-case -# condition: (ha/org-nested-in-plantuml-block) +# condition: (ha-org-nested-in-plantuml-block) # group: plantuml # -- ' See details at https://plantuml.com/use-case-diagram