Subject: | Perl::Tidy css compatibility? |
I've created a patch for Perl::Tidy compatibility. Basically it first caches the original values and then alters the %classes hash. Users can disable/enable it anytime they want.
149a150,200
> =item tidy_compat()
>
> If called with a true value, enabled C<Perl::Tidy> compatibility
> mode and the resulting html will have C<Perl::Tidy> css classes.
> This method must be called before L</parse()>.
>
> B<Examples>
>
> $highlighter->tidy_compat(1);
> $html = $highlighter->parse(q{ echo "hello world" });
> # you can disable compatibilitiy afterwards
> $highlighter->tidy_compat(0);
> $html = $highlighter->parse(q{ echo "hello world" });
>
> See L<Perl::Tidy> for more information.
>
> =cut
>
> my(%tidy_map, %classes_orig);
> my $tidy_state = 0; # active/passive?
> sub tidy_compat {
> my $self = shift;
> my $bool = shift;
> return unless defined $bool;
> if ($bool) {
> unless (%tidy_map && %classes_orig) { # initialize cache
> %tidy_map = qw(
> s-key k
> s-blt m
> s-cmd w
> s-arg l
> s-mta pu
> s-quo q
> s-var v
> s-avr s
> s-val hh
> s-cmt c
> s-lno n
> );
> %classes_orig = (%classes);
> }
> foreach my $k (keys %classes) {
> $classes{$k} = $tidy_map{$classes{$k}} || $classes{$k};
> }
> $tidy_state = 1;
> } else {
> %classes = (%classes_orig);
> $tidy_state = 0;
> }
> }
>