From 3bc00e1082e70f520a6f692ce7081f7882710eb3 Mon Sep 17 00:00:00 2001 From: Jayesh Bhoot Date: Sun, 1 Sep 2024 23:50:51 +0530 Subject: [PATCH 1/2] add is_text predicate --- src/plugin_api.ml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/plugin_api.ml b/src/plugin_api.ml index c7eb329..21c1e79 100644 --- a/src/plugin_api.ml +++ b/src/plugin_api.ml @@ -176,6 +176,9 @@ module Html = struct | ElementNode n -> Soup.coerce n | SoupNode n -> Soup.coerce n + let is_text n = + n |> to_general |> Soup.is_text + let to_soup n = match n with | SoupNode n -> n From edc05c79a8d238318781ab4f0449529661e73f68 Mon Sep 17 00:00:00 2001 From: Jayesh Bhoot Date: Sun, 1 Sep 2024 23:51:45 +0530 Subject: [PATCH 2/2] Simplify is_document predicate by just calling lambdasoup's underlying is_document function. --- src/plugin_api.ml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/plugin_api.ml b/src/plugin_api.ml index 21c1e79..2cbe2fb 100644 --- a/src/plugin_api.ml +++ b/src/plugin_api.ml @@ -188,9 +188,7 @@ module Html = struct to_general n |> Soup.is_root let is_document n = - match n with - | SoupNode _ -> true - | _ -> false + to_general n |> Soup.is_document let select soup selector = let* soup = soup in