| | $delim = $pattern[0]; |
| | $inner = substr($pattern, 1, strrpos($pattern, $delim) - 1); |
| | - // Fix: Use $name for the capture group instead of hardcoding 'punctuation' |
| | $patterns[] = "(?P<$name>$inner)"; |
| | } |
| | |
| | - // Fix: Move punctuation outside the loop as a global fallback |
| | $patterns[] = "(?P<punctuation>[\\{\\}\\(\\)\\[\\]\\;\\,])"; |
| | $combined = '/' . implode('|', $patterns) . '/msu'; |
 |
| | |
| | foreach ($parts as $part) { |
| | - if (str_starts_with($part, '$')) { |
| | - $output .= '<span class="hl-variable">' . htmlspecialchars($part) . '</span>'; |
| | + if (str_starts_with($part, '${') && str_ends_with($part, '}')) { |
| | + $inner = substr($part, 2, -1); |
| | + $output .= '<span class="hl-interp-punct">${</span>'; |
| | + $output .= '<span class="hl-variable">' . htmlspecialchars($inner) . '</span>'; |
| | + $output .= '<span class="hl-interp-punct">}</span>'; |
| | + } elseif (str_starts_with($part, '$')) { |
| | + $output .= '<span class="hl-interp-punct">$</span>'; |
| | + $output .= '<span class="hl-variable">' . htmlspecialchars(substr($part, 1)) . '</span>'; |
| | } else { |
| | $output .= htmlspecialchars($part); |