From 8d3d8d434170d68b5ba3d415cf110c47dba6ae94 Mon Sep 17 00:00:00 2001 From: Patrick Niebeling Date: Wed, 11 Nov 2026 14:23:10 +0100 Subject: [PATCH] Format slide texts in WhatsApp style Slide descriptions support *bold*, _italic_, ~strikethrough~ and lists with "- " or "* " at the start of a line. FormatHelper renders them for the participant page and the PDF (escaping everything else), Format in plenario.js builds the same DOM for presenter and embed. Participant input stays plain text. Co-Authored-By: Claude Opus 5.5 --- AGENTS.md | 5 ++ src/View/AppView.php | 1 + src/View/Helper/FormatHelper.php | 86 +++++++++++++++++++ templates/Admin/export.php | 2 +- templates/Admin/present.php | 2 +- templates/Embed/view.php | 2 +- templates/Participate/view.php | 6 +- templates/Slides/form.php | 2 + templates/layout/pdf.php | 3 + .../TestCase/View/Helper/FormatHelperTest.php | 59 +++++++++++++ webroot/css/plenario.css | 7 +- webroot/js/plenario.js | 48 ++++++++++- 12 files changed, 215 insertions(+), 8 deletions(-) create mode 100644 src/View/Helper/FormatHelper.php create mode 100644 tests/TestCase/View/Helper/FormatHelperTest.php diff --git a/AGENTS.md b/AGENTS.md index a558a61..88cd67d 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -242,6 +242,11 @@ tests/ PHPUnit; PlenarioTestTrait erzeugt Testdaten, Fixtures nur solange die Abstimmung offen ist. `participate:edit` → `VoteService::editText()`, gleiche Vorbedingungen wie `submit()`, in der Folien-Sperre, legt nie eine neue Antwort an. +- **Formatierung von Folientexten** (nur `description`, nie Eingaben von Teilnehmenden) im WhatsApp-Stil: `*fett*`, + `_kursiv_`, `~durchgestrichen~`, Aufzählung mit `- `/`* ` am Zeilenanfang, Zeilenumbrüche. Zwei gleiche Implementierungen: + `FormatHelper::text()` (PHP: Teilnehmerseite, PDF; escapt alles und erzeugt nur diese Tags) und `Format` in `plenario.js` + (Presenter/Embed; baut DOM-Knoten, kein `innerHTML`). Regeln in beiden gleich halten (Regex `INLINE`/`LIST_ITEM`), + Tests: `FormatHelperTest.php`. - **PDF-Export** (`/admin/{token}/export.pdf`, `admin:export`, `ReportService` + `PdfView`, Dompdf): Ergebnisse aller interaktiven Folien (Inhaltsfolien/YouTube fehlen). Standard ist die Fassung **ohne interne Inhalte**: private Folien (`Slide::isPrivate()`) erscheinen nur mit Teilnehmerzahl. `?internal=1` = vollständige Fassung inkl. diff --git a/src/View/AppView.php b/src/View/AppView.php index 1bfd5dc..9e94463 100644 --- a/src/View/AppView.php +++ b/src/View/AppView.php @@ -37,5 +37,6 @@ class AppView extends View */ public function initialize(): void { + $this->addHelper('Format'); } } diff --git a/src/View/Helper/FormatHelper.php b/src/View/Helper/FormatHelper.php new file mode 100644 index 0000000..e0f24a4 --- /dev/null +++ b/src/View/Helper/FormatHelper.php @@ -0,0 +1,86 @@ + + */ + protected const TAGS = ['*' => 'strong', '_' => 'em', '~' => 's']; + + /** + * Formats a text as HTML: lines become
, consecutive list lines a