Thursday, November 12, 2020

Graphviz Syntax Highlighting and Preview with Notepad++

I have about a 50/50 strike rate on getting Graphviz DOT notation correct at any given moment. This drastically reduces if I want the correct syntax and a graph looking like the way I want it to look!!! [edit] Came across this good guide to Graphviz DOT notation.

For a while, I have used online viewers to check my output, it was something of a clunky workflow. [edit] I did some reverse engineering of the code and worked out you can pass a URL parameter to specify the engine. 

https://dreampuf.github.io/GraphvizOnline/?engine=<name>#<graph data>
where <name> = dot, circo, fdp, neato, osage, or twopi. eg from DOT to CIRCO.

What I needed was something more sophisticated to;

  • Version Control - Notepad++ Verbose Backup with date and time of each save.
  • Correct Syntax - Notepad++ Graphviz user defined language
  • Check the output - Notepad++ preview plugin which launches Graphviz
    (a specific version to download as its a bit hard to find graphviz-2.44.1-win32.zip)
You can follow the detailed instructions but this is what I did.
  1.  Turn on Verbose Backup in  Settings|Preferences|Backup and set a backup directory.
  2. Import graphviz-notepad-udl.xml via the User Defined Language dialog which is accessible via the to Language|User Defined Lanuage|Define Your Language menu. After importing, I changed the file extension to DOT (my personal preference for extension) and you select Graphviz from the User Language drop-down Listbox.
  3. Download the correct 32 or 64bit DLL, depending on if you are using 32 or 64 bit Notepad++. Import the plugin DLL via the menu Settings|Import|Import Plugin(s). Note - the Notepad++ plugin install instructions on the Github site are out of date.
  4. The first time you press F9 the preview you will have to point to the command line tool Graphviz\Bin directory if it cannot find it on your PATH environment variable. I just unzipped the  graphviz-2.44.1-win32.zip to a directory.
This should give you colour coded syntax and access to a Graphviz preview via the F9 key.



1 comment:

  1. Hi. This worked great. However, my "preview" is very small. How can I make it larger. Just dragging the window and making it larger doesn't help.

    ReplyDelete