From: David Polakovic Date: Sun, 8 Mar 2026 13:08:13 +0000 (+0100) Subject: feat: Added script for parsing blog contents to RSS. X-Git-Tag: 1.2.0 X-Git-Url: https://git.dpolakovic.space/?a=commitdiff_plain;h=HEAD;p=dpolakovic-space feat: Added script for parsing blog contents to RSS. --- diff --git a/Scripts/Rsser/rsser.pl b/Scripts/Rsser/rsser.pl new file mode 100644 index 0000000..f6b427c --- /dev/null +++ b/Scripts/Rsser/rsser.pl @@ -0,0 +1,49 @@ +#!/usr/bin/perl +use strict; +use warnings; + +# Check if filename argument is provided +if (@ARGV != 1) { + print "perl script.pl yourfile.txt > output.txt\n"; + exit 1; +} + +my $filename = $ARGV[0]; + +# Read the entire file +open(my $fh, '<', $filename) or die "Cannot open file '$filename': $!\n"; +my $content = do { local $/; <$fh> }; +close($fh); + +# Replace with +$content =~ s///g; +$content =~ s/<\/i>/<\/em>/g; + +# Replace with +$content =~ s///g; +$content =~ s/<\/b>/<\/strong>/g; + +# Delete opening tags only (keep content, delete closing tags) +$content =~ s/]*>//g; + +# Delete remaining tags (in case there are unmatched ones) +$content =~ s/<\/div>//g; + +# Delete
and
tags +$content =~ s/
//g; +$content =~ s/<\/center>//g; + +# Replace * with just the asterisks +$content =~ s/(\*+)<\/a>/$1/g; + +# Replace multiple whitespaces with single space +$content =~ s/\s+/ /g; + +# Put everything on a single line (remove newlines) +$content =~ s/\n/ /g; + +# Trim leading and trailing whitespace +$content =~ s/^\s+|\s+$//g; + +# Print the result +print $content . "\n"; \ No newline at end of file