rsspls
rsspls copied to clipboard
Allow the summary selector to match multiple elements
All matched elements are used to generate the item description.
Closes #44
@doekman any chance you can test this out to see if it works for you?
I got Rust running on my computer. The whole process is friction free (wouldn't expect that from rust, LOL).
The results from all found nodes is included, but they always seems to appear in the DOM order. I would like when I change the order of the selectors, the found elements are also included in this order.
In my example: on the original website, an item first shows an image, and below the image are the title and play dates of the movie. I want to show the play dates first in the summary, and after that the image.
So summary = "img, div" should return <img/><div>...</div> and summary = "div, img" should return <div>...</div><img/>.
Thanks for testing. I really appreciate that. For the comma based CSS syntax I don't have any control over the order they're matched, since it's done by a library and the behaviour matches browser behaviour. I expect that it traverses the DOM tree and checks if the selector matches (regardless of selector order), yielding matching elements as they are found.
I think in order to support what you need the summary value will need to be able to accept a string or an array of strings so something like:
summary = ["div", "img"]
and rsspls will make a pass through the document for each selector in the order they're defined.
I pushed another commit that allows using an array of selectors. @doekman does this allow you to achieve what you wanted? In your original example from #44 this would be specified as:
summary = ["div.jss61", "div img"]
Yes, works nicely. I also like the solution by using an array of selectors!