X-Git-Url: https://git.shemshak.org/~bandali/bndl.org/blobdiff_plain/e02deb23bf382d706e4085467fc0eb2b5b7364c0..212ec2e606552fdfa9fcd970a5e27a7dc9ce0042:/txt2html diff --git a/txt2html b/txt2html index f2a23d9..e6dc30b 100644 --- a/txt2html +++ b/txt2html @@ -26,7 +26,9 @@ use warnings 'all'; use Getopt::Long; my $opt_lang = 'en'; -GetOptions ('lang=s' => \$opt_lang) +my $opt_index; +GetOptions ('lang=s' => \$opt_lang, + 'index' => \$opt_index) or die("bad command line arguments\n"); my $link_re = @@ -94,6 +96,7 @@ sub linkify { my $txt = do { local $/; }; + my $title = html_esc($txt =~ /\A([^\n]+)/); $title =~ s/^\s+|\s+$//g; if ($opt_lang eq 'fa') { @@ -102,20 +105,42 @@ if ($opt_lang eq 'fa') { $title .= ' — bandali' if $title !~ /bandali/; } +my ($upd, $pub, $url) = $txt =~ /(.*)\r?\n(.*)\r?\n(.*)\r?\n?\z/; +($upd) = $upd =~ /(?:updated|ویرایش): (.*)/ if $upd; +($pub) = $pub =~ /(?:published|انتشار): (.*)/ if $pub; +($url) = $url =~ /(?:plain text|متن ساده): (.*)/ if $url; +$url = 'https://bndl.org/bandali-cv.txt' + if (!$url and $title =~ /curriculum vitae/); +$url = html_esc($url) if $url; + $txt = linkify(html_esc($txt)); -print('', +print("", qq(', - '', - "$title", + $opt_lang eq 'fa' ? ' dir="rtl"' : '', + ">", + qq( +\n), + "$title\n", + qq(\n), + $url ? qq(\n) : '', + ($opt_index and $opt_lang eq 'en') + ? qq(\n) + : ($opt_index and $opt_lang eq 'fa') + ? qq(\n) + : '', + qq(\n" +url('sahel.woff2')format('woff2');}pre{font-family:sahel}) : '', - '
', $txt, '
'); + "\n", + "
$txt
\n"); STDOUT->flush;