]> git.xolatile.top Git - emil-xolatile.top.git/commitdiff
--
authorEmil Williams <emilemilemil@cock.li>
Mon, 4 Aug 2025 22:55:05 +0000 (22:55 +0000)
committerEmil Williams <emilemilemil@cock.li>
Mon, 4 Aug 2025 22:55:05 +0000 (22:55 +0000)
bloog/bloog.pl

index 6f18172b5c362582e822537d48e22d517f554899..794f79d1e0ce6d58a83f9d9d91c5cc832bf0fb40 100755 (executable)
@@ -49,6 +49,16 @@ sub substreq {
 }
 
 sub html_write {
+    sub chucked {
+        my $buffer = $_[0];
+        my @paragraph = @{$_[1]};
+        unless (substr($buffer, 0, 1) eq '<' and raw) {
+            push(@paragraph, "<p>\n" . $buffer . "</p>\n");
+        } else {
+            push(@paragraph, $buffer);
+        }
+        return \@paragraph;
+    }
     my ($dref, $fh) = @_;
     %d = %$dref;
     my @paragraph;
@@ -58,11 +68,7 @@ sub html_write {
     while (my $line = <$fh>) {
         chomp(my $short = $line);
         if ($short eq '' && not $pre && not $raw) {
-            unless (substr($buffer, 0, 1) eq '<' and raw) {
-                push(@paragraph, "<p>\n" . $buffer . "</p>\n");
-            } else {
-                push(@paragraph, $buffer);
-            }
+            @paragraph = @{chucked($buffer, \@paragraph)};
             $raw = 0;
             $buffer = '';
         } elsif (substreq($short, '#+BEGIN_SRC')) {
@@ -78,15 +84,7 @@ sub html_write {
             $buffer .= $line;
         }
     }
-    # I dare not use a function
-    # I dare not use a goto (deprecated in 5.42, fuck you too)
-    # I am cucked forever and ever to to duplicate code
-    unless (substr($buffer, 0, 1) eq '<' and raw) {
-        push(@paragraph, "<p>\n" . $buffer . "</p>\n");
-    } else {
-        push(@paragraph, $buffer);
-    }
-
+    @paragraph = @{chucked($buffer, \@paragraph)};
     $d{'paragraph'} = \@paragraph;
     my $content;
     $template->process('article.html', \%d, \$content)