fix(frontend): align search and header components with reference

This commit is contained in:
kate522 committed 2026-10-29 22:21:01 +08:00
1 parent 4c13ef478c
commit 542daca457
34 files changed
+803 -705

No files matched your search

+11 -2
View File
@@ -111,8 +111,17 @@ if (!function_exists('aksrt_renderer_highlight_text')) {
if (!$words) {
return esc_html($text);
}
$pattern = '/' . implode('|', array_map(static fn(string $word): string => preg_quote($word, '/'), $words)) . '/iu';
return (string) preg_replace($pattern, '<span class="focus-color">$0</span>', esc_html($text));
$pattern = '/(' . implode('|', array_map(static fn(string $word): string => preg_quote($word, '/'), $words)) . ')/iu';
$parts = preg_split($pattern, $text, -1, PREG_SPLIT_DELIM_CAPTURE);
if (!is_array($parts)) {
return esc_html($text);
}
$html = '';
foreach ($parts as $index => $part) {
$escaped = esc_html($part);
$html .= ($index % 2) === 1 ? '<b class="focus-color">' . $escaped . '</b>' : $escaped;
}
return $html;
}
}