Format slide texts in WhatsApp style
CI / Deploy / test (push) Successful in 1m9s
CI / Deploy / deploy (push) Skipped

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 <noreply@anthropic.com>
This commit is contained in:
gnilebeinandClaude Opus 5.5 committed 2026-11-11 14:23:10 +01:00
1 parent 3465f69bfc
commit 8d3d8d4341
12 files changed
+215 -8

No files matched your search

+6 -1
View File
@@ -377,6 +377,11 @@ textarea { resize: vertical; }
.pulse { width: 18px; height: 18px; border-radius: 50%; background: var(--primary); margin: 0 auto 24px; animation: pulse 1.6s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(75, 63, 224, .5); } 100% { box-shadow: 0 0 0 24px rgba(75, 63, 224, 0); } }
.prose { font-size: 1.1rem; }
/* slide texts with *bold*, _italic_, ~strike~ and lists (FormatHelper / Format in plenario.js) */
.muted.formatted { margin: 1em 0; }
.formatted ul { margin: .3em 0; padding-left: 1.3em; text-align: left; }
.formatted li + li { margin-top: .15em; }
.muted.formatted strong { color: var(--text); }
/* quiz (participant) */
.choice--quiz { border-left-width: 8px; border-left-color: var(--c0); font-size: 1.1rem; }
@@ -663,7 +668,7 @@ body.present {
.stage__status:empty { display: none; }
.stage--closed .stage__status { color: var(--muted); }
.stage__question { font-size: clamp(2rem, 4.5vw, 4rem); margin-bottom: .3em; }
.stage__description { font-size: clamp(1.1rem, 2vw, 1.6rem); color: var(--muted); white-space: pre-line; margin-top: 0; }
.stage__description { font-size: clamp(1.1rem, 2vw, 1.6rem); color: var(--muted); margin: 0 0 1em; }
.stage__media { width: min(100%, calc(62vh * 16 / 9)); margin: 1vh auto 0; }
.stage--video .stage__question { font-size: clamp(1.5rem, 3vw, 2.6rem); }
.stage--video .stage__description { font-size: clamp(1rem, 1.6vw, 1.3rem); }
+47 -1
View File
@@ -42,6 +42,52 @@
return node;
}
/**
* Light formatting of slide texts in WhatsApp style, same rules as App\View\Helper\FormatHelper:
* *bold*, _italic_, ~strikethrough~, lists with "- " or "* " at the start of a line.
* Builds DOM nodes (text via textContent), never HTML strings.
*/
var Format = {
INLINE: /(^|[^\p{L}\p{N}])([*_~])(\S|\S[^\n]*?\S)\2(?=$|[^\p{L}\p{N}])/u,
LIST_ITEM: /^\s*[-*•]\s+(.*)$/u,
TAGS: { '*': 'strong', '_': 'em', '~': 's' },
render: function (container, text) {
container.textContent = '';
var lines = String(text || '').trim().split(/\r\n|\r|\n/);
var list = null;
var lineBefore = false;
lines.forEach(function (line) {
var item = Format.LIST_ITEM.exec(line);
if (item) {
if (!list) {
list = container.appendChild(el('ul'));
}
list.appendChild(el('li', {}, Format.inline(item[1])));
lineBefore = false;
return;
}
if (lineBefore) {
container.appendChild(el('br'));
}
list = null;
Format.inline(line).forEach(function (node) { container.appendChild(node); });
lineBefore = true;
});
},
inline: function (text) {
var m = Format.INLINE.exec(text);
if (!m) {
return text ? [document.createTextNode(text)] : [];
}
var before = text.slice(0, m.index) + m[1];
return (before ? [document.createTextNode(before)] : [])
.concat([el(Format.TAGS[m[2]], {}, Format.inline(m[3]))])
.concat(Format.inline(text.slice(m.index + m[0].length)));
}
};
function csrfToken() {
var meta = document.querySelector('meta[name="csrf-token"]');
return meta ? meta.getAttribute('content') : '';
@@ -1294,7 +1340,7 @@
: (qaStage ? Qa.labels[qaStage]
: (orderRevealed ? 'Auflösung' : (closed ? 'Abstimmung geschlossen' : '')));
q('[data-question]').textContent = slide.question;
q('[data-description]').textContent = slide.description;
Format.render(q('[data-description]'), slide.description);
root.classList.toggle('stage--content', !slide.isInteractive);
root.classList.toggle('stage--video', slide.type === 'youtube');
renderMedia(slide);