···784784let get_id attrs =
785785 List.find_map (function `Id s -> Some s | _ -> None) attrs
786786787787-(** Get class attribute *)
787787+(** Get class attribute as raw string *)
788788let get_class attrs =
789789 List.find_map (function `Class s -> Some s | _ -> None) attrs
790790+791791+(** Get class attribute as list of class names (space-separated) *)
792792+let get_class_list attrs =
793793+ match get_class attrs with
794794+ | Some s -> Datatype.split_on_whitespace s
795795+ | None -> []
790796791797(** Get href attribute *)
792798let get_href attrs =
···859865(** Get all data-* attributes *)
860866let get_all_data attrs =
861867 List.filter_map (function `Data_attr (n, v) -> Some (n, v) | _ -> None) attrs
868868+869869+(** {2 Space-Separated Attribute List Getters} *)
870870+871871+(** Get rel attribute as raw string *)
872872+let get_rel attrs =
873873+ List.find_map (function `Rel s -> Some s | _ -> None) attrs
874874+875875+(** Get rel attribute as list of link types (space-separated) *)
876876+let get_rel_list attrs =
877877+ match get_rel attrs with
878878+ | Some s -> Datatype.split_on_whitespace s
879879+ | None -> []
880880+881881+(** Get headers attribute as raw string *)
882882+let get_headers attrs =
883883+ List.find_map (function `Headers s -> Some s | _ -> None) attrs
884884+885885+(** Get headers attribute as list of IDs (space-separated) *)
886886+let get_headers_list attrs =
887887+ match get_headers attrs with
888888+ | Some s -> Datatype.split_on_whitespace s
889889+ | None -> []
890890+891891+(** Get itemref attribute as raw string *)
892892+let get_itemref attrs =
893893+ List.find_map (function `Itemref s -> Some s | _ -> None) attrs
894894+895895+(** Get itemref attribute as list of IDs (space-separated) *)
896896+let get_itemref_list attrs =
897897+ match get_itemref attrs with
898898+ | Some s -> Datatype.split_on_whitespace s
899899+ | None -> []
900900+901901+(** Get itemprop attribute as raw string *)
902902+let get_itemprop attrs =
903903+ List.find_map (function `Itemprop s -> Some s | _ -> None) attrs
904904+905905+(** Get itemprop attribute as list of property names (space-separated) *)
906906+let get_itemprop_list attrs =
907907+ match get_itemprop attrs with
908908+ | Some s -> Datatype.split_on_whitespace s
909909+ | None -> []
910910+911911+(** Get itemtype attribute as raw string *)
912912+let get_itemtype attrs =
913913+ List.find_map (function `Itemtype s -> Some s | _ -> None) attrs
914914+915915+(** Get itemtype attribute as list of URLs (space-separated) *)
916916+let get_itemtype_list attrs =
917917+ match get_itemtype attrs with
918918+ | Some s -> Datatype.split_on_whitespace s
919919+ | None -> []
920920+921921+(** Get a specific aria-* attribute as list (for space-separated values like aria-labelledby) *)
922922+let get_aria_list name attrs =
923923+ match get_aria name attrs with
924924+ | Some s -> Datatype.split_on_whitespace s
925925+ | None -> []
862926863927(** Find an attribute matching a predicate *)
864928let find f attrs =
+47-1
lib/htmlrw_check/element/attr.mli
···461461(** [get_id attrs] extracts the id attribute value if present. *)
462462463463val get_class : t list -> string option
464464-(** [get_class attrs] extracts the class attribute value if present. *)
464464+(** [get_class attrs] extracts the class attribute value as a raw string. *)
465465+466466+val get_class_list : t list -> string list
467467+(** [get_class_list attrs] extracts the class attribute as a list of class names.
468468+ Returns empty list if not present. Space-separated values are split. *)
465469466470val get_href : t list -> string option
467471(** [get_href attrs] extracts the href attribute value if present. *)
···520524521525val get_all_data : t list -> (string * string) list
522526(** [get_all_data attrs] extracts all data-* attributes. *)
527527+528528+(** {2 Space-Separated Attribute List Getters} *)
529529+530530+val get_rel : t list -> string option
531531+(** [get_rel attrs] extracts the rel attribute value as a raw string. *)
532532+533533+val get_rel_list : t list -> string list
534534+(** [get_rel_list attrs] extracts the rel attribute as a list of link types.
535535+ Returns empty list if not present. Space-separated values are split. *)
536536+537537+val get_headers : t list -> string option
538538+(** [get_headers attrs] extracts the headers attribute value as a raw string. *)
539539+540540+val get_headers_list : t list -> string list
541541+(** [get_headers_list attrs] extracts the headers attribute as a list of IDs.
542542+ Returns empty list if not present. Space-separated values are split. *)
543543+544544+val get_itemref : t list -> string option
545545+(** [get_itemref attrs] extracts the itemref attribute value as a raw string. *)
546546+547547+val get_itemref_list : t list -> string list
548548+(** [get_itemref_list attrs] extracts the itemref attribute as a list of IDs.
549549+ Returns empty list if not present. Space-separated values are split. *)
550550+551551+val get_itemprop : t list -> string option
552552+(** [get_itemprop attrs] extracts the itemprop attribute value as a raw string. *)
553553+554554+val get_itemprop_list : t list -> string list
555555+(** [get_itemprop_list attrs] extracts the itemprop attribute as a list of property names.
556556+ Returns empty list if not present. Space-separated values are split. *)
557557+558558+val get_itemtype : t list -> string option
559559+(** [get_itemtype attrs] extracts the itemtype attribute value as a raw string. *)
560560+561561+val get_itemtype_list : t list -> string list
562562+(** [get_itemtype_list attrs] extracts the itemtype attribute as a list of URLs.
563563+ Returns empty list if not present. Space-separated values are split. *)
564564+565565+val get_aria_list : string -> t list -> string list
566566+(** [get_aria_list name attrs] extracts a specific aria-* attribute as a list.
567567+ Useful for space-separated aria values like aria-labelledby, aria-describedby.
568568+ Returns empty list if not present. *)
523569524570val find : (t -> 'a option) -> t list -> 'a option
525571(** [find f attrs] finds the first attribute matching predicate [f]. *)