60 |
$out->end_section; |
$out->end_section; |
61 |
} # generate_parse_error_section |
} # generate_parse_error_section |
62 |
|
|
63 |
sub generate_structure_dump_section ($) { } |
sub generate_structure_dump_section ($) { |
64 |
|
my $self = shift; |
65 |
|
|
66 |
|
my $parser = $self->{structure}; |
67 |
|
return if $parser->errnum; |
68 |
|
|
69 |
|
my $out = $self->output; |
70 |
|
$out->start_section (id => 'graph-', title => 'Graph'); |
71 |
|
|
72 |
|
require Regexp::Visualize::Simple; |
73 |
|
my $v = Regexp::Visualize::Simple->new; |
74 |
|
$v->push_regexp_node ($parser->root); |
75 |
|
|
76 |
|
require Encode; |
77 |
|
require MIME::Base64; |
78 |
|
|
79 |
|
while ($v->has_regexp_node) { |
80 |
|
my ($g, $i) = $v->next_graph; |
81 |
|
|
82 |
|
my $index = $out->input->full_subdocument_index; |
83 |
|
$index = $index ? $index . '.' . $i : $i; |
84 |
|
|
85 |
|
$out->start_section (id => 'graph-' . $i, |
86 |
|
title => 'Regexp #', text => $index, |
87 |
|
notab => 1); |
88 |
|
|
89 |
|
## If browsers supported SVG in text/html! |
90 |
|
|
91 |
|
my $svg = $g->as_svg; |
92 |
|
my $width = ''; |
93 |
|
my $height = ''; |
94 |
|
$width = int $1 + 1 if $svg =~ /width="([\d.]+)"/; |
95 |
|
$height = int $1 + 1 if $svg =~ /height="([\d.]+)"/; |
96 |
|
|
97 |
|
my $data_url = Encode::encode ('utf8', $svg); |
98 |
|
$data_url = MIME::Base64::encode_base64 ($data_url); |
99 |
|
$data_url =~ s/\s+//g; |
100 |
|
$data_url = 'data:image/svg+xml;base64,' . $data_url; |
101 |
|
|
102 |
|
$out->start_tag ('iframe', |
103 |
|
src => $data_url, |
104 |
|
width => $width, height => $height, |
105 |
|
seamless => 1); |
106 |
|
$out->end_tag ('iframe'); |
107 |
|
|
108 |
|
$out->end_section; |
109 |
|
} |
110 |
|
|
111 |
|
$out->end_section |
112 |
|
|
113 |
|
} # generate_structure_dump_section |
114 |
|
|
115 |
sub generate_structure_error_section ($) { } |
sub generate_structure_error_section ($) { } |
116 |
|
|