From bfe623b4ed0445d31e29f6676f4727c1271a0759 Mon Sep 17 00:00:00 2001 From: bernardhanna Date: Fri, 24 Jul 2026 16:58:32 +0100 Subject: [PATCH] Restore Key one-pagers heading and bold the locale note. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Romanian overrides lost the heading because the supporting-detail copy also mentions “key one-pagers”; detect a real heading instead and make the intro note bold so it stands out on the English page. Co-authored-by: Cursor --- app/TrainingResource.php | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/app/TrainingResource.php b/app/TrainingResource.php index 66d653a93..7ea71a36e 100644 --- a/app/TrainingResource.php +++ b/app/TrainingResource.php @@ -276,10 +276,15 @@ public function renderedPdfLinksSectionForLocale(?string $locale = null): string return ''; } - $noteHtml = ''.e(__('training.discover_digital_key_one_pagers_note')).''; + $noteHtml = ''.e(__('training.discover_digital_key_one_pagers_note')).''; if (str_contains($section, '[[key_one_pagers_locale_note]]')) { - return str_replace('[[key_one_pagers_locale_note]]', $noteHtml, $section); + $section = str_replace('[[key_one_pagers_locale_note]]', $noteHtml, $section); + if ($this->slug === 'discover-digital-programme' && ! $this->hasKeyOnePagersHeading($section)) { + $section = '

Key one-pagers

'.$section; + } + + return $section; } // Discover Digital: inject the note even when locale overrides omit the placeholder. @@ -299,10 +304,15 @@ public function renderedPdfLinksSectionForLocale(?string $locale = null): string } } - if (! str_contains(mb_strtolower($section), 'key one-pagers')) { - return '

Key one-pagers

'.$noteHtml.$section; - } + // Always restore the heading when missing. Do not use a plain-text search for + // "key one-pagers" — the supporting-detail paragraph also mentions that phrase. + return '

Key one-pagers

'.$noteHtml.$section; + } - return $noteHtml.$section; + protected function hasKeyOnePagersHeading(string $html): bool + { + return preg_match('/]*\bid=(["\'])key-one-pagers\1[^>]*>/is', $html) === 1 + || preg_match('/]*>\s*Key one-pagers\s*<\/h2>/is', $html) === 1 + || preg_match('/(?:]*>\s*)?\s*Key one-pagers\s*<\/strong>/is', $html) === 1; } }