Shopify / theme-check

The Ultimate Shopify Theme Linter
Other
337 stars 95 forks source link

Fix Liquid in HTML parsing #505

Closed charlespwd closed 2 years ago

charlespwd commented 2 years ago

We had issues with our parsing hack. When the liquid had new lines in it, the #{id}######## hack messed with the line numbers.

Also learned today that the HTML parser doesn't provide an accurate .to_html value. It is built and not what we provided in the source. Therefore the two are not equal. The only way to find the source markup is to look for the tag starting at that line in the source itself. Which we do in this PR.

Also implemented start/end position methods for the HtmlNode while we're at it.

Also added tests for HtmlNode#markup,#line_number and position methods.

Fixes #502