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

feat(format/html): opt out of formatting for pre, script and style tags #4729

Conversation

dyc3
Copy link
Contributor

@dyc3 dyc3 commented Dec 12, 2024

Summary

This makes it so pre, script, and style tags are not formatted.

The pre tag is for "preformatted text": https://developer.mozilla.org/en-US/docs/Web/HTML/Element/pre . I went ahead and also excluded script and style tags too since we don't have embedded formatting, and the current formatting completely mangles and unformats js and css in those tags.

closes #4021

Test Plan

Added a snapshot test, and ran it against prettier tests.

@github-actions github-actions bot added A-Formatter Area: formatter L-HTML Language: HTML labels Dec 12, 2024
Copy link
Member

@ematipico ematipico left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just bike-shedding regarding the variant, but the code is good and we can merge it anytime

crates/biome_formatter/src/format_element/tag.rs Outdated Show resolved Hide resolved
Copy link

codspeed-hq bot commented Dec 12, 2024

CodSpeed Performance Report

Merging #4729 will not alter performance

Comparing 09-18-feat_format_html_opt_out_of_formatting_for_script_and_style_tags (f7e3116) with main (2a098f9)

Summary

✅ 97 untouched benchmarks

@dyc3 dyc3 force-pushed the 09-18-feat_format_html_opt_out_of_formatting_for_script_and_style_tags branch from 68d784a to f7e3116 Compare December 12, 2024 18:04
@dyc3 dyc3 merged commit c2dda66 into main Dec 12, 2024
12 checks passed
@dyc3 dyc3 deleted the 09-18-feat_format_html_opt_out_of_formatting_for_script_and_style_tags branch December 12, 2024 19:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Formatter Area: formatter L-HTML Language: HTML
Projects
None yet
Development

Successfully merging this pull request may close these issues.

📝 Contents of <pre> elements should not be formatted
2 participants