Rename languages processed by `highlight' to be `hl:BLAH'. This will
break existing deployments. Benefit: now I can add new language tags
which don't interfere with `highlight'.
open my $fh, "-|", "highlight", "-p" or die "highlight: $!";
while (<$fh>) {
my ($descr, $lang) = /^(.*\S)\s*:\s*(\S+)(?:\s.*|)$/;
open my $fh, "-|", "highlight", "-p" or die "highlight: $!";
while (<$fh>) {
my ($descr, $lang) = /^(.*\S)\s*:\s*(\S+)(?:\s.*|)$/;
- next unless defined $lang;
- $newlang{$lang} = $descr;
+ next if !defined $lang or $lang eq "txt";
+ $newlang{"hl:$lang"} = $descr;
}
close $fh or die "close highlight: $! $?";
}
close $fh or die "close highlight: $! $?";
-$newlang{"txt"} //= "Plain text";
+$newlang{"txt"} = "Plain text";
Odin::xact {
my $h = $db->selectall_hashref
Odin::xact {
my $h = $db->selectall_hashref
"$Odin::PASTEBIN/$tag" |h %></a>
</div>
% }
"$Odin::PASTEBIN/$tag" |h %></a>
</div>
% }
+</pre>
+% } elsif ($lang =~ /^hl:(.*)$/) {
+<pre class="paste">
my $kid = open my $fh, "-|" // die "fork: $!";
if ($kid == 0) {
my $kid = open my $fh, "-|" // die "fork: $!";
if ($kid == 0) {
- open my $hl, "|-", "highlight", "-Ohtml", "-f", "-t8", "-S$lang"
+ open my $hl, "|-", "highlight", "-Ohtml", "-f", "-t8", "-S$hl_lang"
or die "open highlight: $!";
syswrite $hl, $content // die "highlight write: $!";
close $hl or die "highlight kid: $!, $?";
or die "open highlight: $!";
syswrite $hl, $content // die "highlight write: $!";
close $hl or die "highlight kid: $!, $?";
or die "highlight parent: $!, $?";
}
</%perl>
or die "highlight parent: $!, $?";
}
</%perl>
+% } else {
+<div class="note">
+<p>I don't know how to display content with language
+ ‘<% $lang |h %>’. This is a bug in the Pastebin program.
+ Here's the raw text, in case that's useful.
+</div>
+<pre class="paste">
+<% $content |h %>\
+</pre>
+% }