Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Template panel does not render <script> tag correctly #2041

Closed
thesayfulla opened this issue Dec 15, 2024 · 2 comments · Fixed by #2043
Closed

Template panel does not render <script> tag correctly #2041

thesayfulla opened this issue Dec 15, 2024 · 2 comments · Fixed by #2043

Comments

@thesayfulla
Copy link
Contributor

thesayfulla commented Dec 15, 2024

Issue:

There is an issue with rendering <script></script> tags in the template panel. The template source incorrectly removes spaces(tabs) within the script tags, which causes the content to render incorrectly.

395896872-7a1a32bc-4a85-45c3-8497-b9fe04c561d7

Expected Behavior:

The <script></script> tags should render correctly with all spaces(tabs) intact, allowing for proper functionality.

@matthiask
Copy link
Member

We're using pygments for the highlighting (if it's available!)

It seems that we're not applying the appropriate style to whitespace elements (.w) in our homegrown CSS (why do we even have our own CSS for highlighting when we could just be using pygment styles?)

matthiask added a commit to matthiask/django-debug-toolbar that referenced this issue Dec 16, 2024
@thesayfulla
Copy link
Contributor Author

thesayfulla commented Dec 16, 2024

We're using pygments for the highlighting (if it's available!)

It seems that we're not applying the appropriate style to whitespace elements (.w) in our homegrown CSS (why do we even have our own CSS for highlighting when we could just be using pygment styles?)

I've updated the code as follows:

source = mark_safe(f"<code>{source}</code>")

file: debug_toolbar/panels/templates/views.py#L60

Result:

Screenshot 2024-12-16 at 17 37 46

What do you think about implementing it this way?

@matthiask If this approach looks good to you, I'll create a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants