Erkenne Text mit H1, H2 oder div am Anfang als HTML statt als Klartext
CI Feature / test (push) Successful in 7m47s
Deploy Test / test (push) Successful in 8m9s
Deploy Test / deploy (push) Successful in 44s

Ein Fließtext, dessen HTML mit <h2> begann, wurde als Klartext des Altbestands gelesen
und mit sichtbaren Tags ausgegeben (Website und Vorschau). Die Bereinigung bildet H1/H2
auf H3 ab, kam aber nie zum Zug. isHtml kennt nun h1, h2 und div am Textanfang.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
LarsandClaude Sonnet 5.5 committed 2026-12-01 10:43:04 +01:00
1 parent 9e8d0020b3
commit 7f9534d289
6 files changed
+49 -1

No files matched your search

+4 -1
View File
@@ -32,6 +32,9 @@ final class FormattedText
/** Blockelemente, mit denen gespeichertes HTML beginnt. */
private const BLOCKS = ['p', 'h3', 'h4', 'h5', 'h6', 'ul', 'ol', 'blockquote', 'table', 'img'];
/** Zusätzlich zu den Blöcken erkennt der Textanfang h1, h2 und div als HTML; die Bereinigung bildet sie auf h3 und p ab (mapLegacyTags). */
private const START_TAGS = ['h1', 'h2', 'div'];
/** Angaben der Redaktion, die formatiert gespeichert werden. Suchbegriffe, Titel und Teaser bleiben Klartext. */
public const FIELDS = ['summary', 'description'];
@@ -59,7 +62,7 @@ final class FormattedText
/** Wird der Wert als HTML gelesen (sonst als Klartext des Altbestands)? */
public static function isHtml(?string $value): bool
{
return preg_match('/^\s*<(?:'.implode('|', self::BLOCKS).')[\s>\/]/i', (string) $value) === 1;
return preg_match('/^\s*<(?:'.implode('|', [...self::BLOCKS, ...self::START_TAGS]).')[\s>\/]/i', (string) $value) === 1;
}
/**