]> Sergey Matveev's repositories - public-inbox.git/blob - Documentation/txt2pre
6f2a8c8ae2707b73aa6fe47314de2a425e7b3eab
[public-inbox.git] / Documentation / txt2pre
1 #!/usr/bin/env perl
2 # Copyright (C) 2014-2019 all contributors <meta@public-inbox.org>
3 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
4 #
5 # Stupid script to make HTML from preformatted, utf-8 text versions,
6 # only generating links for http(s).  Markdown does too much
7 # and requires indentation to output preformatted text.
8 use strict;
9 use warnings;
10 use PublicInbox::Linkify;
11 use PublicInbox::Hval qw(ascii_html);
12
13 my $str = eval { local $/; <> };
14 my ($title) = ($str =~ /\A([^\n]+)/);
15 $title = ascii_html($title);
16 my $l = PublicInbox::Linkify->new;
17 $str = $l->linkify_1($str);
18 $str = ascii_html($str);
19 $str = $l->linkify_2($str);
20
21 print '<html><head>',
22   qq(<meta\nhttp-equiv="Content-Type"\ncontent="text/html; charset=utf-8"\n/>),
23   "<title>$title</title>",
24   "</head><body><pre>",  $str , '</pre></body></html>';