Skip Menu |

This queue is for tickets about the HTML-Mason CPAN distribution.

Report information
The Basics
Id: 34558
Status: resolved
Priority: 0/
Queue: HTML-Mason

People
Owner: Nobody in particular
Requestors: LAXEN [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in:
  • 1.36
  • 1.37
  • 1.38
  • 1.39
Fixed in: 1.35



Subject: Problem with Syntax-Highlight-Mason and Mason version > 1.35
In version 1.36 you changed line 265 in Mason::Compiler.pm from if $c->{comp_with_content_stack} && @{ $c->{comp_with_content_stack} }; to if @{ $c->{comp_with_content_stack} }; This ended up breaking my Syntax-Highlight-Mason program, for what reason I have no idea. The array was undefined because $c->{comp_with_content_stack} was undefined, and the result wasn't pretty. After adding the test back in, everything worked fine. I've attached the test file that comes with my distribution, so you can see for yourself. I hope this is helpful. Best wishes, Henry Laxen This is perl, v5.8.8 built for x86_64-linux-gnu-thread-multi Linux exxor 2.6.18-6-amd64 #1 SMP Sun Feb 10 17:50:19 UTC 2008 x86_64 GNU/Linux HTML-Mason-1.39
Subject: Syntax-Highlight-Mason.t
# Before `make install' is performed this script should be runnable with # `make test'. After `make install' it should work as `perl Syntax-Highlight-Mason.t' ######################### # change 'tests => 1' to 'tests => last_test_to_print'; use Test::More tests => 2; BEGIN { use_ok('Syntax::Highlight::Mason') }; ######################### my $mcode = <<'END'; <%doc> test for mason highlighter </%doc> HTML <b>code</b> here % my $x = 'a perl variable'; <%init> # More perl code $x =~ s/perl/PERL/g; </%init> <%args> $x $y => '' </%args> END my $expected_result = <<'END'; <html> <head> <style type="text/css"> .m-tag { color: #0000ff; font-weight: bold; } /* mason tag */ /* ====================================================================== * * Sample stylesheet for Syntax::Highlight::HTML * * * * Copyright (C)2004 Sebastien Aperghis-Tramoni, All Rights Reserved. * * * * This file is free software; you can redistribute it and/or modify * * it under the same terms as Perl itself. * * ====================================================================== */ .h-decl { color: #336699; font-style: italic; } /* doctype declaration */ .h-pi { color: #336699; } /* process instruction */ .h-com { color: #338833; font-style: italic; } /* comment */ .h-ab { color: #000000; font-weight: bold; } /* angles as tag delim. */ .h-tag { color: #993399; font-weight: bold; } /* tag name */ .h-attr { color: #000000; font-weight: bold; } /* attribute name */ .h-attv { color: #333399; } /* attribute value */ .h-ent { color: #cc3333; } /* entity */ .h-lno { color: #aaaaaa; background: #f7f7f7;} /* line numbers */ </style> </head> <body> <pre> <span class="m-tag">&lt;%doc&gt; </span> test for mason highlighter <span class="m-tag">&lt;/%doc&gt; </span>HTML <span class="h-ab">&lt;</span><span class="h-tag">b</span><span class="h-ab">&gt;</span>code<span class="h-ab">&lt;/</span><span class="h-tag">b</span><span class="h-ab">&gt;</span> here % <span style="color:#000;">my</span> <span style="color:#080;">$x</span> <span style="color:#000;">=</span> <span style="color:#00a;">'</span><span style="color:#00a;">a perl variable</span><span style="color:#00a;">'</span><span style="color:#000;">;</span> <span class="m-tag">&lt;%init&gt; </span> <span style="color:#069;font-style:italic;"># More perl code</span> <span style="color:#080;">$x</span> <span style="color:#000;">=~</span> <span style="color:#00a;">s/</span><span style="color:#00a;">perl</span><span style="color:#00a;">/</span><span style="color:#00a;">PERL</span><span style="color:#00a;">/</span><span style="color:#00a;">g</span><span style="color:#000;">;</span> <span class="m-tag">&lt;/%init&gt; </span><span class="m-tag">&lt;%args&gt; </span>$x $y =&gt; &#39;&#39; <span class="m-tag">&lt;/%args&gt; </span></pre> </body> </html> END my $result = Syntax::Highlight::Mason->new->compile($mcode); is($result, $expected_result, 'basic test');
On Sun Mar 30 18:32:48 2008, LAXEN wrote: Show quoted text
> In version 1.36 you changed line 265 in Mason::Compiler.pm from > > if $c->{comp_with_content_stack} && @{ $c->{comp_with_content_stack} }; > > to > > if @{ $c->{comp_with_content_stack} }; > > This ended up breaking my Syntax-Highlight-Mason program, for what > reason I have no idea. The array was undefined because > $c->{comp_with_content_stack} was undefined, and the result wasn't > pretty. After adding the test back in, everything worked fine. > > I've attached the test file that comes with my distribution, so you can > see for yourself. I hope this is helpful.
I took a look at your code and I see the basic problem. You override compile() and never call SUPER::compile(), so various internal data structures the compiler expects to exist end up not existing. Basically, the compiler doesn't expect to be overridden this way. You might be able to just override compiled_component instead, and have it return the highlighted syntax. If you have further questions please ask them on the mason dev list.