Skip to main content

Module shared_utils

Module shared_utils 

Source
Expand description

Convenience re-exports of DOM helpers for post-processing extracted content.

These are a stable, curated subset of the internal utility library.

Functions§

apply
Apply func(node, selector) to every descendant of root_node that matches any selector in selectors. Each selector’s matches are visited in reverse document order (safe for detach). Invalid CSS selectors are silently skipped.
contains_single_tag_in_element
Returns true if the passed node contains only single node that matches the tag_name, false otherwise
move_children
Move every child node of from (in order) to be the last children of to. After the call, from has no children.
normalize_text
Collapse every run of two or more whitespace characters in src into a single ASCII space.
replace_relative_urls_with_absolute
Rewrite all relative URLs in <a>, <img>, <picture>, <figure>, <video>, <audio>, and <source> elements under node to absolute URLs using doc_uri and the optional <base href> path.
word_count
Count the number of whitespace-delimited tokens in text.