Description
Symfony version(s) affected
4.0+
Description
When opening a non php file in the profiler the indent is missing.
This was introduced by this commit: symfony/twig-bridge@d8fc719 (PR: #26230)
How to reproduce
Considering any project running at https://127.0.0.1:8000
Non php file: https://127.0.0.1:8000/_profiler/open?file=config/packages/framework.yaml&line=0
PHP file: https://127.0.0.1:8000/_profiler/open?file=src/Kernel.php&line=0
Possible Solution
Removing the ending trim in Symfony\Bundle\WebProfilerBundle\Profiler::fixCodeMarkup()
seems to fix the problem.
Processing can be differentiated according to whether the file is a PHP highlighted file or another type of file (see: https://www.php.net/manual/en/function.highlight-file.php).
A potential improvement would be to no longer highlight the file on the backend, but to transfer this responsibility to a javascript library (ex: https://highlightjs.org/).
Additional Context
No response