Using Graphviz with Pelican and liquid tags

I really like keeping things simple. And I also like generating figures from code using Graphviz. And since there was no Graphviz plugin for pelican I wrote my own one.

Using liquid tags I wanted to get my graphviz code rendered and automatically included as a base64 encoded image in my HTML code. I've created a pull request but you can find a fork at dorneanu-pelican.

Basically the tags works as follows:

{% graphviz 
    <program> {
        <DOT CODE>
    }
%}

program could be dot, neato, twopi, circo etc. The DOT CODE is simply sent to the binary utility and the output (PNG data) is saved into the document.

This is some minimal example:

{% graphviz 
    dot { 
            digraph graphname { 
                a -> b -> c; 
                b -> d; 
                e -> f; 
            } 
        }
%}

which will be rendered to:

You could then use neato instead of dot:

{% graphviz 
    neato { 
            digraph graphname { 
                a -> b -> c; 
                b -> d; 
                e -> f; 
            } 
        }
%}

...which will be rendered to:

Some other examples:

  • dot
    • digraph

  • dot
    • subgraphs

  • neato

  • twopi

  • circo

  • misc


Prev: HowTo: iOS Apps - Static analysis
Next: Using Blockdiag with Pelican and liquid tags

comments powered by Disqus
Published:
2014-11-13 00:00
category:
Tag: