Skip Menu |

This queue is for tickets about the GraphViz CPAN distribution.

Report information
The Basics
Id: 18511
Status: resolved
Priority: 0/
Queue: GraphViz

People
Owner: Nobody in particular
Requestors: agentzh [...] gmail.org
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: 2.02
Fixed in: (no value)



Subject: Support for HTML-like labels
It will be cool if the GraphViz module supports HTML-like Labels: http://www.graphviz.org/doc/info/shapes.html#html Cheers, Agent
From: peter.oliver [...] eon-is.co.uk
On Mon Apr 03 04:45:16 2006, AGENT wrote: Show quoted text
> It will be cool if the GraphViz module supports HTML-like Labels: > > http://www.graphviz.org/doc/info/shapes.html#html
The module does allow HTML-style labels, but only if the label starts with a tag. So, for example, '<<FONT COLOR="red">root</FONT>>' works, but '<line one<BR/>line two>' does not. The attached patch fixes this so that both work, and mentions this capability in the documentation.
diff -ur GraphViz-2.04~/lib/GraphViz.pm GraphViz-2.04/lib/GraphViz.pm --- GraphViz-2.04~/lib/GraphViz.pm 2008-12-12 21:31:42.000000000 +0000 +++ GraphViz-2.04/lib/GraphViz.pm 2009-12-01 10:36:30.000000000 +0000 @@ -429,6 +429,12 @@ $g->add_node('Paris', label => 'City of\nlurve'); +If a label starts with '<' and ends with '>', then a rudimentary form +of HTML is used. See http://www.graphviz.org/doc/info/shapes.html#html +for details. + + $g->add_node('Paris', label => '<City of<br/>lurve>'); + Attributes need not all be specified in the one line: successive declarations of the same node have a cumulative effect, in that any later attributes are just added to the existing ones. For example, the @@ -574,11 +580,8 @@ } } else { $node->{label} =~ s#([|<>\[\]{}"])#\\$1#g - unless $node->{shape} - && ($node->{shape} eq 'record' - || ( $node->{label} =~ /^<</ - && $node->{shape} eq 'plaintext' ) - ); + unless ( $node->{shape} && $node->{shape} eq 'record' + || $node->{label} =~ /^<.*>$/ ); } delete $node->{cluster} @@ -1241,7 +1244,7 @@ my $value = $thing->{$key}; $value =~ s|"|\"|g; $value = '"' . $value . '"' - unless ( $key eq 'label' && $value =~ /^<</ ); + unless ( $key eq 'label' && $value =~ /^<.*>$/ ); $value =~ s|\n|\\n|g; $value = '""' if not defined $value; diff -ur GraphViz-2.04~/t/simple.t GraphViz-2.04/t/simple.t --- GraphViz-2.04~/t/simple.t 2008-12-12 21:30:13.000000000 +0000 +++ GraphViz-2.04/t/simple.t 2009-12-01 10:27:02.000000000 +0000 @@ -4,7 +4,7 @@ use warnings; use lib '../lib', 'lib'; use GraphViz; -use Test::More tests => 30; +use Test::More tests => 31; my @lines = <DATA>; @@ -492,3 +492,11 @@ ratio="fill"; GOroot [label=<<FONT COLOR="red">root</FONT>>, shape="plaintext"]; } +-- test -- +$g = GraphViz->new(); +$g->add_node('html_text', label => '<line one<br/>line two>'); +-- expect -- +digraph test { + ratio="fill"; + html_text [label=<line one<br/>line two>]; +}
This issue is not fixed in GraphViz2 V 1.00. Nevertheless, I (Ron) have noted it, and I certainly want to make it work, so I'll do some more development in this area now that V 1.00 has been uploaded to CPAN. There're won't be any further development on GraphViz.