Closed huseeiin closed 1 month ago
i feel like this is stupid now. i will close. mods can reopen if they wish to
why stupid?
why stupid?
because what i wanted also wasn't supported in another HTMLRewriter implementation, https://www.npmjs.com/package/htmlrewriter, so i didn't think bun should go out of its way to change the spec.
div:first-of-type works fine unless you want the div to also have a class like .activity-descp:first-of-type better reproduction, htmlrewriter and cheerio:
import { load } from "cheerio";
const res = await fetch(
"https://www.twstalker.com/jarredsumner/status/1844638476853301535"
);
const html = await res.text();
new HTMLRewriter()
.on(".activity-descp:first-of-type", {
element(e) {
// it logs nothing
console.log(e);
},
})
.transform(html);
const $ = load(html);
// it works
console.log($(".activity-descp").text());
What is the problem this feature would solve?
much like cheerio first() selector:
What is the feature you are proposing to solve the problem?
get only the first element and ignore the rest
What alternatives have you considered?
i tried div:first-of-type it didn't work