Hello,

I am using Graph::Easy to render a link graph as boxart. Works very well, except when I am using the boxart in a browser and the nodes are containing html markup.

The problem arises as Graph::Easy usually handles only textual node labels. Now adding, as I do, HTML and smuggling in a href, the result is a discrepancy in length between the textual representation and the length of the label string (which Graph::Easy uses to compute the node-box dimensions.

The dirty hack I use to get around this is supplying Graph::Easy with two different strings, depending on the state of its layout processing - by overriding Graph::Easy::Node::dimensions:
# compensate discrepancy between textual length and rendered-html leng +th sub Graph::Easy::Node::dimensions { # Returns the minimum dimensions of the node/cell derived from the # label or name, in characters. my $self = shift; use HTML::Strip; my $hs = HTML::Strip->new(); my $align = $self->attribute('align'); my ($lines,$aligns) = $self->_aligned_label($align); my $w = 0; my $h = scalar @$lines; foreach my $line (@$lines){ $line = $hs->parse($line); # $line =~ s/\s+/ /g; $w = length($line); # if length($line) > $w; } ($w,$h); }


The problem now is that Graph::Easy still thinks the label is wider and leaves the box open, as this:
┌─────────────────────────┐  aaaaa bbbbbb ccccccc   ┌──────────────────────┐
│ xxxxxxxxxxxxxxxxxxxxxxx │ ──────────────────────> │ xxxxxxxxxxxxxxxxxxx
└─────────────────────────┘                         └──────────────────────┘

Anyone inclined to look into Graph::Easy for me as I am incapable of figuring it out any better.

In reply to Help with HTML-izing Graph::Easy by isync

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.