Shinmera / lquery

A Common Lisp library to allow jQuery-like HTML/DOM manipulation.
https://shinmera.github.io/lquery
zlib License
87 stars 8 forks source link

Finding comment strings #18

Closed ispringle closed 6 months ago

ispringle commented 6 months ago

I'm interested in using lquery to find comments inside of html documents and than manipulate/remove/replace those comments based on the inner content of them. I believe lquery is the correct tool among your suite of html/xml related tools for this task and I know that Plump has the ability to recognize comments. I'm struggling to understand how to use lquery to find comments though. I initially assumed that lquery would "just work" with comments, but if that's the case I'm not sure how to go about this.

Given the html document:

<!doctype html>
<html>
<!-- I'm a comment -->
</html>

I'd expect that (lquery:$ *dom* "comment") would return #(#<PLUMP-DOM:COMMENT {...}>) but instead it returns empty #(). I've also tried the literal tag !-- instead of comment but that has the same result. I guess since a comment is not an element it isn't being returned and maybe I need to write a macro to pull this off.

Shinmera commented 6 months ago

CSS selectors don't have a way to select comments. You can use plump:traverse to gather the elements yourself.

ispringle commented 6 months ago

Thank you very much!