From ce2fcdbc0e2287db5b91536e512b3fab738c29fc Mon Sep 17 00:00:00 2001 From: Amin Bandali Date: Sun, 10 Oct 2021 00:17:54 -0400 Subject: [PATCH 1/1] add rel="alternate" links to articles and indices --- GNUmakefile | 15 +++++++------ fa/fsf-internship-beyond.fa.txt | 1 - txt2html | 37 +++++++++++++++++++++++---------- 3 files changed, 33 insertions(+), 20 deletions(-) diff --git a/GNUmakefile b/GNUmakefile index f5b4014..d791a55 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -8,8 +8,7 @@ # without any warranty. -gen = perl txt2html < $< > $@ -gen_fa = perl txt2html --lang='fa' < $< > $@ +gen-html = perl txt2html $(1) < $< > $@ port := $(if $(port),$(port),8000) TXT := $(filter-out bandali-pubkey.txt bandali.txt,$(wildcard *.txt)) @@ -22,13 +21,13 @@ OUT_FA := $(patsubst fa/bandali-%.html,fa/%.html,$(OUT_FA)) all: $(OUT) $(OUT_FA) index.html fa/index.html -%.html: bandali-%.txt ; $(gen) -%.html: %.txt ; $(gen) -index.html: bandali.txt ; $(gen) +%.html: bandali-%.txt; $(gen-html) +%.html: %.txt; $(gen-html) +index.html: bandali.txt; $(call gen-html,--index) -fa/%.html: fa/bandali-%.fa.txt ; $(gen_fa) -fa/%.html: fa/%.fa.txt ; $(gen_fa) -fa/index.html: fa/bandali.fa.txt ; $(gen_fa) +fa/%.html: fa/bandali-%.fa.txt; $(call gen-html,--lang='fa') +fa/%.html: fa/%.fa.txt; $(call gen-html,--lang='fa') +fa/index.html: fa/bandali.fa.txt; $(call gen-html,--lang='fa' --index) clean: diff --git a/fa/fsf-internship-beyond.fa.txt b/fa/fsf-internship-beyond.fa.txt index 5826162..5634f75 100644 --- a/fa/fsf-internship-beyond.fa.txt +++ b/fa/fsf-internship-beyond.fa.txt @@ -101,4 +101,3 @@ without any warranty. شوند. این پرونده به صورت موجود و بدون هیچ گونه ضمانت ارائه می‌شود. متن ساده: https://bndl.org/fa/fsf-internship-beyond.fa.txt - diff --git a/txt2html b/txt2html index f2a23d9..5b0acb8 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 = @@ -101,21 +103,34 @@ if ($opt_lang eq 'fa') { } else { $title .= ' — bandali' if $title !~ /bandali/; } +my ($url) = $txt =~ /(?:plain text|متن ساده): (.*)\r?\n?\z/; +$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", + $url ? qq(\n) : '', + ($opt_index and $opt_lang eq 'en') + ? qq(\n) + : ($opt_index and $opt_lang eq 'fa') + ? qq(\n) + : '', $opt_lang eq 'fa' - ? "\n\n" +url('sahel.woff2')format('woff2');}pre{font-family:sahel}\n) : '', - '
', $txt, '
'); + "
$txt
\n"); STDOUT->flush; -- 2.20.1