Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | 37x 37x 33x 33x 33x | /**
* Checks whether the given HTML string contains a paragraph (<p>) element
*/
export function containsParagraphTag(html: string | null | undefined): boolean {
const input = (html ?? "").toString().trim();
if (input === "") return false;
Eif (typeof DOMParser !== "undefined") {
const doc = new DOMParser().parseFromString(input, "text/html");
return doc.body.querySelector("p") !== null;
}
return /<p\b[^>]*>/i.test(input);
}
export default containsParagraphTag;
|