I'm looking for a proper html-parser that can handle Liquid templates without messing them up. *A way to load a piece of html code (that might be mixed with Liquid syntax and other stuff), look for tags/attributes/selectors, maybe modify a few things and then save it, while keeping it valid (or untouched where I didn't touch). It could be either php (preferred) or Python, as long as it's reliable and doing the job. It seems that both php's "DOMDocument" and Python's "BeautifulSoup" are messing with the final output, so unless there's a way to configure them to work with it - I'll probably need something else. *Currently I'm using Regex or other search/replace techniques, but still researching for better solutions. -- Any idea or suggestion would be appreciated. Thanks!