glejeune / node-graphviz

Node.js interface to the GraphViz graphing tool
http://algorithmique.net
MIT License
197 stars 58 forks source link

Issue in creating HTML-like labels. #18

Open shobhitg opened 10 years ago

shobhitg commented 10 years ago

Dot specification has HTML-like labels.

They are generally like: label=<<FONT POINT-SIZE='12'>Some Text</FONT>>

The issue is that Graphviz doesn't understand it if that html label is quoted like this: label="<<FONT POINT-SIZE='12'>Some Text</FONT>>"

In the attributes js file, lbl is of type lblString, which means it would be quoted. https://github.com/glejeune/node-graphviz/blob/master/lib/deps/attributs.js#L59

We need a way to say if our label is a string or an html markup. Based on that it must be quoted or not.

I don't know what would be an elegant solution to this.

Any fixes (or even ideas) would be awesome?

ravenscar commented 2 years ago

Apologies for necroing this ancient issue but I was also hoping for a solution and there now seems to be a provision for that in the code and I thought I would document it for future visitors. You can add a ! before the string and it will end up being enclosed by <...> in the dotfile.

e.g.

const n1 = g.addNode('APIGW', {
  label: '!<B>API</B> <i>Gateway</i>',
});

comes out as:

"APIGW" [ label =<<B>API</B> <i>Gateway</i>> ];

I think this issue can be closed.