I've been trying to parse Angular Templates into AST using the parse5 lib, since it has everything I need. But there's a problem - when parsing HTML, it seems like the lib makes everything lowercase.
Example:
tagName: 'span',
attrs: [
{ name: '*ngif', value: 'true' },
]
*ngIf
has become *ngif
. That of course is a problem
Is there a way to avoid this? To tell parse5 to not make everything lowercase?
There is no way to make Parse5 case sensitive, since it converts everything to lower case. But you can use PostHTML instead for this purpose, here is playground, so such code:
<p *ngIf=true>My first paragraph.</p>
Can be converted to:
<h2 *ngIf="true">My first paragraph.</h2>
With help of:
export default function(tree) {
tree.match({ tag: "p" }, node => {
node.tag = 'h2';
return node;
});
}