Commits

Shlomi Fish committed 6a37850

Add more features to PerlBegin::TopicsExamples.

  • Participants
  • Parent commits ea64ca5

Comments (0)

Files changed (2)

File lib/PerlBegin/TopicsExamples.pm

 
 use Carp ();
 
+has default_syntax => (is => 'ro', isa => 'Str');
+has main_pre_css_classes => (is => 'ro', isa => 'ArrayRef[Str]',
+    default => sub {
+        return [qw(code)];
+    },
+);
+
 sub _calc_post_code
 {
     my $self = shift;
     }
     else
     {
+        my $syntax = ($ex_spec->{syntax} || $self->default_syntax);
+
         my $code = <<"EOF";
 #!/usr/bin/perl
 
 
         my $tvc = Text::VimColor->new(
             string => \$code,
-            filetype => 'perl',
+            filetype => $syntax,
         );
 
         return
-            qq|<pre class="perl">\n|
+            qq|<pre class="|
+                . join(' ', map { CGI::escapeHTML($_) }
+                    @{$self->main_pre_css_classes}, $syntax
+                )
+            . qq|">\n|
             . ($tvc->html() =~ s{(class=")syn}{$1}gr)
             . qq|\n</pre>\n|
             ;

File src/topics/files-and-directories/index.html.wml

     # Examples generator:
     my $ex_gen = PerlBegin::TopicsExamples->new(
         {
+            default_syntax => 'perl',
         }
     );