gen = perl txt2html < $< > $@
-gen_fa = perl txt2html 'fa' < $< > $@
+gen_fa = perl txt2html --lang='fa' < $< > $@
port := $(if $(port),$(port),8000)
TXT := $(filter-out bandali-pubkey.txt bandali.txt,$(wildcard *.txt))
use strict;
use warnings 'all';
+use Getopt::Long;
+
+my $opt_lang = 'en';
+GetOptions ('lang=s' => \$opt_lang)
+ or die("bad command line arguments\n");
my $link_re =
qr{([\('!])?\b((?:ftps?|https?|nntps?|imaps?|s?news|gopher)://
my $txt = do { local $/; <STDIN> };
my $title = html_esc($txt =~ /\A([^\n]+)/);
$title =~ s/^\s+|\s+$//g;
-if ($ARGV[0] and $ARGV[0] eq 'fa') {
+if ($opt_lang eq 'fa') {
$title .= ' — بندعلی' if $title !~ /بندعلی/;
} else {
$title .= ' — bandali' if $title !~ /bandali/;
$txt = linkify(html_esc($txt));
print('<!doctype html>',
- ($ARGV[0] and $ARGV[0] eq 'fa')
- ? '<html lang="fa" dir="rtl">'
- : '<html>',
- '<head>',
- '<meta
+ qq(<html lang="$opt_lang"),
+ $opt_lang eq 'fa' ? ' dir="rtl"' : '', '>',
+ '<head><meta
http-equiv="Content-Type"
content="text/html; charset=utf-8"
/>',
"<title>$title</title>",
- ($ARGV[0] and $ARGV[0] eq 'fa')
+ $opt_lang eq 'fa'
? "\n<style>\@font-face{font-family:sahel;font-weight:normal;
src:local('Sahel WOL'),local('Sahel'),
url('sahel.woff2')format('woff2');}pre{font-family:sahel}</style>\n"