Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[WebProfilerBundle] Missing indent on non php files opended in the profiler #60835

Open
@phcorp

Description

@phcorp

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions