Kakoune-plantuml.kak | command line tool UML to PNG | file-type (puml or plantuml) highlighter

kakoune-plantuml.kak ← the repo.

PlantUML support for the Kakoune editor.

In order to run PlantUML you need to have installed:

  • Java links to install via sdkman
  • Graphviz (optional if you only need sequence diagrams and activity (beta) diagrams)

PlantUML installation notes faq


Install

mv plantuml.kak ~/.config/kak/autoload/plantuml.kak

plug.kak

plug "KJ_Duncan/kakoune-plantuml.kak" domain "bitbucket.org"

Supported file extensions: (puml|plantuml)


Use PlantUML’s command line syntax to include it in your own scripts or documentation tools.

First, create a text file with PlantUML commands, like this example called sequenceDiagram.puml:

@startuml
Alice -> Bob: test
@enduml

Then run PlantUML using sequenceDiagram.puml as input. The output is an image, which either appears in the other software, or is written to an image file on disk.

java -jar plantuml.jar sequenceDiagram.puml

This outputs your sequence diagram to a file called sequenceDiagram.png.

sequenceDiagram

The PlantUML usage instructions have been adapted from their Getting Started page.

Enjoy thank guys. Bye :wave:.


A theme song for the French kakoune users enjoy :smile:

Mickey Kojak covers Art vs Science ‘Parlez Vous Francais?’ for Like A Version on spotify or youtube.

1 Like

Cool! I wonder if you can get images to display with new multiline replace ranges highlighter and use of something like Überzug

You can embed images in asciidoc demo render or markdown. Just scroll through this single page for quick look overview and some builtin functions.

Its renders static images; PNG, SVG, and LaTex.

Also does ascii-art and unicode, you can use their online server to try before you buy the free open source continuous integration software.

FAQ

Images (whatever their format : PNG, SVG…) generated by the execution of PlantUML are owned by the author of their corresponding sources code (that is, their textual description in PlantUML language).
[…]
So you can use PlantUML comments into your own code : those comments are owned by yourself, and are not considered as covered work, and are not covered by the GPL/LGPL/APL/EPL/MIT license.

Best bit, acknowledges its planet earth:
Screenshot_2020-05-13 Frequently Asked Questions


For non-trivial real-world examples look here.


You could view the static image in the terminal with imagcat.sh.


Hope that helps to clear a few things up, long story short ‘just use it’. Thanks buddy.

Updated to plantuml v1.2021.4 and refactored rc/plantuml.kak.

Run and won on; osx, manjaro, lubuntu, wsl.exe (ubuntu).

Play it hard, fast and loud:
Through The Never or youtube

peek up my dress
# rc/plantuml.kak: <https://bitbucket.org/KJ_Duncan/kakoune-plantuml.kak/src/master/plantuml.kak>
#
# style macro: 93l<a-t><space>i<ret><esc><esc>
#
evaluate-commands %sh{
  types='abstract actor agent archimate artifact boundary card class cloud component control
    database detach diamond entity enum file folder frame interface node object package
    participant queue rectangle stack state storage usecase'

  # [...]

  preprocessor='!define !definelong !else !enddefinelong !endif !exit !if !ifdef !ifndef !include !pragma !undef'

  # [...]

  # -------------------------------------------------------------------------------------------- #
  # c-family.kak: <https://github.com/mawww/kakoune/blob/master/rc/filetype/c-family.kak#L271>
  join() { sep=$2; eval set -- $1; IFS="$sep"; echo "$*"; }
  # -------------------------------------------------------------------------------------------- #
  add_highlighter() { printf "add-highlighter shared/plantuml/code/ regex %s %s\n" "$1" "$2"; }
  # -------------------------------------------------------------------------------------------- #
  add_start_word_highlighter() {

    while [ $# -gt 0 ]; do
      words=$1 face=$2; shift 2
      regex="^($(join "${words}" '|'))\\b"
      add_highlighter "$regex" "1:$face"
    done

  }
  # -------------------------------------------------------------------------------------------- #
  # Thanks alexherbo2: <https://github.com/alexherbo2/plug.kak/blob/master/rc/plug.kak#L108>
  add_word_highlighter() {

    while [ $# -gt 0 ]; do
      words=$1 face=$2; shift 2
      regex="\\b($(join "${words}" '|'))\\b(?=[\\s\\n])"
      add_highlighter "$regex" "1:$face"
    done

  }
  # -------------------------------------------------------------------------------------------- #
  # lesson learnt: using style macro in for loop use: $@ not "$@"
  print_static_words() {

    for name in $@
    do
      printf " %s" "$name"
    done

  }
  # -------------------------------------------------------------------------------------------- #
  printf "declare-option str-list plantuml_static_words "

  print_static_words "$types" "$keywords" "$declaration" "$preprocessor" "$skinparameter" "$plantumlcolour"

  printf "\n"
  # -------------------------------------------------------------------------------------------- #
  add_word_highlighter "$types" "type" "$keywords" "keyword" "$skinparameter" "variable" "$plantumlcolour" "meta"

  add_start_word_highlighter "$declaration" "keyword" "$preprocessor" "value"

  printf "\n"
  # -------------------------------------------------------------------------------------------- #
}
1 Like