scinfu/SwiftSoup ? reverse-engineered prompt
Reverse engineered prompt
Build me a pure Swift HTML parsing library like SwiftSoup that works on macOS, iOS, tvOS, watchOS, and Linux.
I want it to take HTML or XML from a string, a file, or a URL, figure out the right parser automatically, and give me a clean document object I can query with CSS style selectors. It should let me read text and attributes, walk the DOM, edit elements, and output the updated HTML again.
Please also include a safe way to clean user submitted HTML with a whitelist so unsafe tags and scripts get removed. Support messy real world HTML too, not just perfect markup, and make sure the parsed structure behaves like modern browsers would.
If it helps, look up current Swift Package Manager and platform docs online as needed. Add a few simple examples and tests so it is easy to see how to parse a page, find elements, and modify content.
Are you gonna build this?
make sure you review the code using coderabbit