};
my $title = html_esc($txt =~ /\A([^\n]+)/);
$title =~ s/^\s+|\s+$//g;
$title .= " — $author" if $title !~ /$author/;
my ($upd, $pub, $url) = $txt =~ /(.*)\r?\n(.*)\r?\n(.*)\r?\n?\z/;
($upd) = $upd =~ /(?:updated|ویرایش): (.*)/ if $upd;
($pub) = $pub =~ /(?:published|انتشار): (.*)/ if $pub;
$upd = $pub if (!$upd);
($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));
my $upd_iso8601 = `date -Iseconds -ud '$upd' | tr -d \\\\n` if $upd;
my $pub_iso8601 = `date -Iseconds -ud '$pub' | tr -d \\\\n` if $pub;
my $pub_rfc5322 = `date -uRd '$pub' | tr -d \\\\n` if $pub;
my $url_html = $url =~ s/(?:[.]$lang)?[.]txt$/.html/r if $url;
$url_html =~ s|/bandali-(.*)|/$1| if $url_html;
my $slug = $url_html =~ s|.*/(.*)[.]html$|$1|r if $url_html;
my $note_id = "$feed_id:$slug" if $url_html;
# note header
if ($format eq 'html') {
$out .=
''
. qq(')
. qq(
\n)
. "$title\n"
. qq(\n)
. ($url
? qq(\n)
: '')
. (($index and $lang eq 'en')
? qq(\n)
: ($index and $lang eq 'fa')
? qq(\n)
: '')
. qq(\n"
. '';
} elsif ($format eq 'atom' or $format eq 'rss') {
my $atom_updated =
($format eq 'atom') ? 'updated'
: ($format eq 'rss') ? 'atom:updated'
: '';
my $updated =
"<$atom_updated>$upd_iso8601$atom_updated>\n" if $upd;
$out .= ($format eq 'atom') ? qq(
$author
$note_id
$pub_iso8601\n)
. ($updated ? $updated : '') .
qq(
$title
)
: ($format eq 'rss') ? qq(
-
$title
$url_html
$note_id
$pub_rfc5322\n)
. (($updated and $pub ne $upd) ? $updated : '') .
qq()
: '';
}
# note body
$out .= $txt;
# note footer
if ($format eq 'html') {
$out .= '
';
} elsif ($format eq 'atom') {
$out .= "]]>";
} elsif ($format eq 'rss') {
$out .= "]]>";
}
PRINT:
print("$out\n");
STDOUT->flush;