commit f847c41903390f842e3b4a1b1d7b4c6a99b30327
parent 5a95a2973524305024fb2bd775b447737073d1d5
Author: René Wagner <rwagner@rw-net.de>
Date: Mon, 22 Feb 2021 20:34:19 +0100
convert pre sections to preformatted gemini blocks
preserve whitespaces in item description as they may
serve a purpose.
This will eventually be improved with a more
sophisticated algo that only preverses whitespaces
in non-pre-blocks
closes #8
Diffstat:
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/orrg.pl b/orrg.pl
@@ -26,7 +26,7 @@ if (!defined($ENV{'SERVER_PROTOCOL'}) || $ENV{'SERVER_PROTOCOL'} ne 'GEMINI')
my $query = lc(uri_unescape($ENV{'QUERY_STRING'}));
if ($query eq '' || $query !~ /^(https|gemini)\:\/\//) {
- write_response('INPUT', 'Paste the URI of the rss feed you want to read:', undef);
+ write_response('INPUT', 'Paste the URI of the rss feed you want to read', undef);
}
write_response('SUCCESS', 'text/gemini', create_response($query));
@@ -77,8 +77,9 @@ sub item
$desc =~ s/\<li\>/* /igm;
$desc =~ s/\<h[1-2][^\>]+\>/### /igm;
$desc =~ s/\<br \/\>/\r\n/igm;
+ $desc =~ s/\<pre.*\>/\r\n```\r\n/igm;
+ $desc =~ s/\<\/pre\>/\r\n```\r\n/igm;
$desc = $hs->parse($desc);
- $desc = trim_ws($desc);
}
push @item, (($desc ne '' && $desc ne $title) || $it->pubDate ne '')? '## '. $title : $title;
if ($it->pubDate ne '') {