posthtml / posthtml-parser

Parse HTML/XML to PostHTMLTree

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Feature] location property in AST

anikethsaha opened this issue · comments

commented

currently, we don't process any location property for the nodes. It is because htmlparser2 doesn't support it from the core. I have seen some implementation where they are using domhandler to get the raw HTML and add location property in it. The implementation slightly went over my head and I do think it might break our current cast.

As discussed with @Scrum , we need to take a performance factor as well and we should not break implement anything that changes the AST. (we can add it. )

I am trying to implement at least the line property with the current htmlparser2 options but i haven't figure out the way to implement the columns. (still thinking. 🤔 )

I would appreciate a lot if anyone else has better approach without changing much.

I will submit a PoC soon with my changes.

cc @Scrum @cossssmin , thoughts ?

Did you make any progress on this? We need location information to provide nice error messages in Parcel. Happy to help out here if we can!

I will think how to do it optional