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

🐛 HTML: Parser needs to be able to accept lone < and > in <pre> tags #4833

Open
1 task done
dyc3 opened this issue Jan 4, 2025 · 3 comments
Open
1 task done
Labels
A-Parser Area: parser L-HTML Language: HTML S-Bug-confirmed Status: report has been confirmed as a valid bug

Comments

@dyc3
Copy link
Contributor

dyc3 commented Jan 4, 2025

Environment information

playground

What happened?

https://biomejs.dev/playground/?bracketSameLine=true&files.main.html=PABmAGkAZwB1AHIAZQAgAHIAbwBsAGUAPQAiAGkAbQBnACIAIABhAHIAaQBhAC0AbABhAGIAZQBsAGwAZQBkAGIAeQA9ACIAYwBvAHcALQBjAGEAcAB0AGkAbwBuACIAPgAKACAAIAA8AHAAcgBlAD4ACgBfAF8AXwBfAF8AXwBfAF8AXwBfAF8AXwBfAF8AXwBfAF8AXwBfAF8AXwBfAF8AXwBfAF8AXwAKADwAIABJACcAbQAgAGEAbgAgAGUAeABwAGUAcgB0ACAAaQBuACAAbQB5ACAAZgBpAGUAbABkAC4AIAA%2BAAoALQAtAC0ALQAtAC0ALQAtAC0ALQAtAC0ALQAtAC0ALQAtAC0ALQAtAC0ALQAtAC0ALQAtAC0ACgAgACAAIAAgACAAXAAgACAAIABeAF8AXwBeAAoAIAAgACAAIAAgACAAXAAgACAAKABvAG8AKQBcAF8AXwBfAF8AXwBfAF8ACgAgACAAIAAgACAAIAAgACAAIAAoAF8AXwApAFwAIAAgACAAIAAgACAAIAApAFwALwBcAAoAIAAgACAAIAAgACAAIAAgACAAIAAgACAAIAB8AHwALQAtAC0ALQB3ACAAfAAKACAAIAAgACAAIAAgACAAIAAgACAAIAAgACAAfAB8ACAAIAAgACAAIAB8AHwACgBfAF8AXwBfAF8AXwBfAF8AXwBfAF8AXwBfAF8AXwBfAF8AXwBfAF8AXwBfAF8AXwBfAF8AXwAKACAAIAA8AC8AcAByAGUAPgAKACAAIAA8AGYAaQBnAGMAYQBwAHQAaQBvAG4AIABpAGQAPQAiAGMAbwB3AC0AYwBhAHAAdABpAG8AbgAiAD4ACgAgACAAIAAgAEEAIABjAG8AdwAgAHMAYQB5AGkAbgBnACwAIAAiAEkAJwBtACAAYQBuACAAZQB4AHAAZQByAHQAIABpAG4AIABtAHkAIABmAGkAZQBsAGQALgAiACAAVABoAGUAIABjAG8AdwAgAGkAcwAgAGkAbABsAHUAcwB0AHIAYQB0AGUAZAAgAHUAcwBpAG4AZwAgAHAAcgBlAGYAbwByAG0AYQB0AHQAZQBkACAAdABlAHgAdAAgAGMAaABhAHIAYQBjAHQAZQByAHMALgAKACAAIAA8AC8AZgBpAGcAYwBhAHAAdABpAG8AbgA%2BAAoAPAAvAGYAaQBnAHUAcgBlAD4A

This snippet is from a prettier test.

Expected result

Should parse successfully. Solution should be pretty easy, we should treat pre the same as we treat script and style currently.

Code of Conduct

  • I agree to follow Biome's Code of Conduct
@dyc3 dyc3 added A-Parser Area: parser S-Bug-confirmed Status: report has been confirmed as a valid bug L-HTML Language: HTML labels Jan 4, 2025
@nhedger
Copy link
Member

nhedger commented Jan 4, 2025

Aren't these meant to be escaped?

If you have to display reserved characters such as <, >, &, and " within the <pre> tag, the characters must be escaped using their respective character references.

https://developer.mozilla.org/en-US/docs/Web/HTML/Element/pre

Not sure how strict browsers are about this one though.

@dyc3
Copy link
Contributor Author

dyc3 commented Jan 4, 2025

Nope, not for pre tags, browsers don't complain about it: https://codepen.io/dyc3/pen/KwPyrXO This could be something we lint for eventually though.

@nhedger
Copy link
Member

nhedger commented Jan 5, 2025

It seems that browsers are quite forgiving on this aspect.

Running the snippet through an HTML5 validator raises the issue, but I think you're right, and we should follow what browsers do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Parser Area: parser L-HTML Language: HTML S-Bug-confirmed Status: report has been confirmed as a valid bug
Projects
None yet
Development

No branches or pull requests

2 participants