Use built-in transforms in JustHTML
mainJustHTML uses a pipeline of transforms passed to the JustHTML constructor to modify the HTML tree in memory. Transforms can be categorized into built-in high-level transforms, core selector-based transforms, and advanced building blocks for custom pipelines.
Built-in Transforms
Linkify(...): Converts URLs/emails in text nodes to<a>elements.CollapseWhitespace(...): Normalizes whitespace in text nodes.Sanitize(...): Runs a security-focused sanitization pipeline.PruneEmpty(...): Recursively removes empty elements.Stage([...]): Splits transforms into explicit passes.
Core Selector Transforms
These target specific elements using selectors:
SetAttrs(selector, attributes=None, **attrs): Overwrites attributes.Drop(selector): Removes nodes and their children.Unwrap(selector): Removes the tag but keeps the children.Escape(selector): Turns tags into escaped text but keeps children.Empty(selector): Removes all children of the matching element.Edit(selector, func): Executes custom logic on matching nodes.