Debian Codegraph @

examples/as_html

raw
1 #!/usr/bin/perl -w
2
3 #############################################################################
4 # This example is a bit outdated, please use the new bin/graph-easy script -
5 # which is after "make install" available on any command line in your system.
6
7 # Convert an input file containing a Graph::Easy description to
8 # an HTML page.
9
10 # Example usage:
11 # examples/as_html t/in/2nodes.txt >test.html
12 # echo "[ A ] -> [ B ]" | examples/as_ascii
13
14 BEGIN { $|++; }
15
16 use strict;
17 use lib 'lib';
18 use Graph::Easy::Parser;
19
20 my $file = shift;
21 my $id = shift || '';
22 my $debug = shift || 0;
23
24 my $parser = Graph::Easy::Parser->new( debug => $debug );
25
26 if (!defined $file)
27 {
28 $file = \*STDIN;
29 binmode STDIN, ':utf8' or die ("binmode STDIN, ':utf8' failed: $!");
30 }
31 binmode STDERR, ':utf8' or die ("binmode STDERR, ':utf8' failed: $!");
32 my $graph = $parser->from_file( $file );
33
34 die ($parser->error()) unless defined $graph;
35
36 $graph->id($id);
37 $graph->timeout(360);
38 $graph->layout();
39
40 warn ($graph->error()) if $graph->error();
41 binmode STDOUT, ':utf8' or die ("binmode STDOUT, ':utf8' failed: $!");
42 print $graph->as_html_page();
43