From 57c50015ce6952cd2d697a02e738e04c5e2c2bc6 Mon Sep 17 00:00:00 2001
From: Philip Kaludercic <philip.kaludercic@fau.de>
Date: Mon, 15 Jan 2024 14:21:20 +0100
Subject: [PATCH] Allow for sources to be given anywhere in the first line

---
 gen.pl | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/gen.pl b/gen.pl
index 92da06e..a35cba4 100755
--- a/gen.pl
+++ b/gen.pl
@@ -74,11 +74,17 @@ while (<>) {
     undef $media;
     undef %last_option;
     undef @options;
-  } elsif (/^([01])(.*?)(?:\(([^()]*)\))?$/) {
+  } elsif (/^([01])(.*?)$/) {
     $single_choice = $1;
 
     $question = $2;
     chomp $question;
+
+    if ($question =~ /\(([^()]*)\)/) {
+      $source = $1;
+      $question =~ s/\Q($source)\E//;
+      chomp $source;
+    }
   } elsif (/^[|](.+)/) {
     if ($last_option{"option"}) {
       $last_option{"option"} .= $1;
-- 
GitLab