SDL: examples: Handle newlines in README.txt better.

From 47429227ab05311b7c5457dad2e748d68097da5f Mon Sep 17 00:00:00 2001
From: "Ryan C. Gordon" <[EMAIL REDACTED]>
Date: Fri, 6 Dec 2024 13:25:06 -0500
Subject: [PATCH] examples: Handle newlines in README.txt better.

---
 build-scripts/build-web-examples.pl | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/build-scripts/build-web-examples.pl b/build-scripts/build-web-examples.pl
index 8c9e8a7b7e9f2..211682e10ad0b 100755
--- a/build-scripts/build-web-examples.pl
+++ b/build-scripts/build-web-examples.pl
@@ -167,18 +167,24 @@ sub handle_example_dir {
     my $onmouseoverdst = "$dst/$onmouseoverfname";
 
     my $description = '';
+    my $has_paragraph = 0;
     if (open(my $readmetxth, '<', "$examples_dir/$category/$example/README.txt")) {
         while (<$readmetxth>) {
             chomp;
             s/\A\s+//;
             s/\s+\Z//;
-            if ($_ eq '') {
-                $description .= "\n<br/>\n<br/>\n";
+            if (($_ eq '') && ($description ne '')) {
+                $has_paragraph = 1;
             } else {
+                if ($has_paragraph) {
+                    $description .= "\n<br/>\n<br/>\n";
+                    $has_paragraph = 0;
+                }
                 $description .= "$_ ";
             }
         }
         close($readmetxth);
+        $description =~ s/\s+\Z//;
     }
 
     do_mkdir($dst);