X-Git-Url: http://git.shiar.nl/sheet.git/blobdiff_plain/effd000ff281f2187bf653b6e1c6aa0fc796c5f9..94952046ef8b8676384fb294ecc6fc50dccc3d6b:/source.plp diff --git a/source.plp b/source.plp index e645cd2..9c18320 100644 --- a/source.plp +++ b/source.plp @@ -74,6 +74,16 @@ else { -r $source or Abort("Requested file not found", '404 source not found'); my $size = (stat $source)->[7]; + my $cachefile = "source/$source.html"; + if (-e $cachefile and (stat $cachefile)->[9] >= (stat $source)->[9]) { + say '
';
+		print ReadFile($cachefile);
+		say '
'; + exit; + } + open my $cache, '>', $cachefile + or Alert("Could not save cache", "Opening $cachefile failed: $!");; + if (my $hl = eval { $size < 32_768 or die 'large files take too long to parse'; require Text::VimColor; @@ -89,6 +99,7 @@ else { Statement => 'strong', Error => 'em', Todo => 'em', + PreProc => 'strong', ); say '
';
@@ -110,6 +121,7 @@ else {
 
 			$line = qq(<$tag class="sy-\l$type">$line) if $tag;
 			print $line;
+			print {$cache} $line if $cache;
 		}
 		say '
'; }