Skip to content

Instantly share code, notes, and snippets.

@tsibley
Created April 27, 2023 06:09
Show Gist options
  • Save tsibley/5a76253d4cd855247d9df14f20c35585 to your computer and use it in GitHub Desktop.
Save tsibley/5a76253d4cd855247d9df14f20c35585 to your computer and use it in GitHub Desktop.
#!/usr/bin/env perl
use strict;
use warnings;
use open qw< :std :encoding(UTF-8) >;
use utf8;
use HTML::FromANSI::Tiny;
my $conv = HTML::FromANSI::Tiny->new(
auto_reverse => 1,
background => 'white',
foreground => 'black',
remove_escapes => 1,
);
my $ansi = do { local $/; <> };
my $template = do { local $/; <DATA> };
printf $template, scalar $conv->css, scalar $conv->html($ansi);
__DATA__
<html>
<head>
<style>
pre { line-height: 1em; }
%s
</style>
</head>
<body>
<pre>%s</pre>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment