-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
fix(html): preserve case-sensitive tag names #5101
fix(html): preserve case-sensitive tag names #5101
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, but maybe switch to https://github.com/Prettyhtml/parse5 will be better, built-in support case insensitivity tags
It seems the fork does not work in the case where Input: <!DOCTYPE html>
<HTML CLASS="no-js mY-ClAsS">
<HEAD>
<META CHARSET="utf-8">
<TITLE>My tITlE</TITLE>
<META NAME="description" content="My CoNtEnT">
</HEAD>
<body>
<P>Hello world!<BR> This is HTML5 Boilerplate.</P>
<SCRIPT>
window.ga = function () { ga.q.push(arguments) }; ga.q = []; ga.l = +new Date;
ga('create', 'UA-XXXXX-Y', 'auto'); ga('send', 'pageview')
</SCRIPT>
<SCRIPT src="https://www.google-analytics.com/analytics.js" ASYNC DEFER></SCRIPT>
</body>
</HTML> Output: before (parse5) / after (@starptech/prettyhtml-parse) |
@ikatyang I don't understand your issue. What's your input and output and how looks your code? |
@ikatyang there are two modes in parse5
in order to check which modes should be used, I'm searching for |
I thought the mode was determined by Here's the repro steps: const text = `
<!DOCTYPE html>
<HTML CLASS="no-js mY-ClAsS">
<HEAD>
<META CHARSET="utf-8">
<TITLE>My tITlE</TITLE>
<META NAME="description" content="My CoNtEnT">
</HEAD>
<body>
<P>Hello world!<BR> This is HTML5 Boilerplate.</P>
<SCRIPT>
window.ga = function () { ga.q.push(arguments) }; ga.q = []; ga.l = +new Date;
ga('create', 'UA-XXXXX-Y', 'auto'); ga('send', 'pageview')
</SCRIPT>
<SCRIPT src="https://www.google-analytics.com/analytics.js" ASYNC DEFER></SCRIPT>
</body>
</HTML>
`;
const parse5 = require("@starptech/prettyhtml-parse");
const htmlparser2TreeAdapter = require("parse5-htmlparser2-tree-adapter");
const ast = parse5.parse(text, {
treeAdapter: htmlparser2TreeAdapter,
sourceCodeLocationInfo: true,
preserveCaseSensitiveTags: true
}); Issues:
|
I think we could switch to the fork in future PRs when the issue is fixed, I'd like to merge this PR first to continue the work. (@StarpTech Could you enable the |
@ikatyang I enabled issues. |
@ikatyang this is actually no issue. You have to parse it with |
Non-HTML tag names are considered case-sensitive.
docs/
directory)