diff --git a/src/Twig/AppRuntime.php b/src/Twig/AppRuntime.php
index 203e71d..7cfad54 100644
--- a/src/Twig/AppRuntime.php
+++ b/src/Twig/AppRuntime.php
@@ -214,7 +214,8 @@ class AppRuntime implements RuntimeExtensionInterface
return '';
}
- $items = explode(PHP_EOL, $content);
+ // any line break, as textareas submit \r\n; blank lines (the default benefits end with one) are no items
+ $items = array_filter(array_map('trim', preg_split('/\R/', $content)), fn (string $item) => '' !== $item);
$list = '
';
foreach ($items as $item) {
diff --git a/tests/Twig/Nl2ListTest.php b/tests/Twig/Nl2ListTest.php
new file mode 100644
index 0000000..1bd94ee
--- /dev/null
+++ b/tests/Twig/Nl2ListTest.php
@@ -0,0 +1,38 @@
+assertSame(
+ '',
+ $this->createRuntime()->nl2List("Unterkunft\n\nSkipass\n")
+ );
+ }
+
+ public function testWindowsLineBreaksSplitCleanly(): void
+ {
+ $this->assertSame(
+ '- Anreise im E&P Reisebus
- Verpflegung
',
+ $this->createRuntime()->nl2List("Anreise im E&P Reisebus\r\nVerpflegung\r\n")
+ );
+ }
+
+ private function createRuntime(): AppRuntime
+ {
+ $reflection = new \ReflectionClass(AppRuntime::class);
+
+ return $reflection->newInstanceWithoutConstructor();
+ }
+}