This doesn't actually work, but is a bit of an attempt at syntax
highlighting for code blocks, using enscript to do the work. I
may come back to it again, or maybe not. One thing's for sure:
the feature will be added sooner if someone helps out with a patch.
--- wiki.pm Mon Dec 23 21:56:08 2002
+++ wiki.pm Mon Dec 23 21:53:43 2002
@@ -829,7 +829,7 @@
my $text = removeSystemTags(@_);
my ($result, $nextMode, $lastWasBlank, $tableMode) = ("",'wiki',1,0);
-
+ my ($enscriptLang, $enscriptText) = ('','');
#$text =~ s/\\\n//go; # what _is_ that? seems dumb.
@@ -871,6 +871,16 @@
} else {
$result .= literalText($_) . "
\n"
}
+ } elsif ($mode eq 'enscript') {
+ if (/^\s*\}\}\}\s*$/o) {
+ $nextMode = 'wiki';
+ $result .= enscriptHighlight($enscriptText, $enscriptLang);
+ $result .= "$codeBlockClose\n";
+ $lastWasBlank = 0;
+ } else {
+ $enscriptText .= "$_\n";
+ }
+
} elsif (/^\s*\
\s*$/io) { $result .= "\n"; @@ -879,10 +889,19 @@ } elsif (s/^\s*{{{\s*$/$codeBlockOpen/o) { + #$result .= '\n"; } elsif ($nextMode eq 'code') { $result .= "$codeBlockClose\n\n"; + } elsif ($nextMode eq 'enscript') { + $result .= enscriptHighlight($enscriptText, $enscriptLang); + $result .= "$codeBlockClose\n\n"; } elsif ($tableMode) { $result .= "$endTable\n"; } @@ -1180,5 +1202,17 @@ return $_; } + + + + +sub enscriptHighlight { + my ($text, $mode) = @_; + + my $output = `/usr/bin/enscript --language=html --output=- --pretty-print=$mode <<}}}\n$text}}}`; + return $output; +} + + 1;
' unless $lastWasBlank; + $result .= "$codeBlockOpen\n"; $nextMode = 'code'; $lastWasBlank = 0; + } elsif (s/^\s*{{{\s*\@(\w+)\s*$/$codeBlockOpen/o) { + $nextMode = "enscript"; + $enscriptLang = lc($1); + $enscriptText = ''; + + $result .= "$codeBlockOpen\n"; + $lastWasBlank = 0; } elsif (s/^~//o) { #temporary code mode @@ -1125,6 +1144,9 @@ $result .= "