Range

Overview

Range is a class in Aspose.Html FOSS for Python. Inherits from: AbstractRange.

A contiguous portion of a document tree (WHATWG DOM §5).

This class provides 23 methods for working with Range objects in Python programs. Available methods include: __init__, clone_contents, clone_range, collapse, compare_boundary_points, compare_point, create_contextual_fragment, delete_contents, detach, extract_contents, insert_node, intersects_node, and 11 additional methods. All public members are accessible to any Python application after installing the Aspose.Html FOSS for Python package. Properties: collapsed, common_ancestor_container, end_container, end_offset, start_container, start_offset.

Properties

NameTypeAccessDescription
common_ancestor_container"Node"ReadThe deepest node that contains both boundary points.
start_container"Node"ReadThe node that contains the start of the range.
start_offsetintReadThe offset within start_container.
end_container"Node"ReadThe node that contains the end of the range.
end_offsetintReadThe offset within end_container.
collapsedboolReadTrue if the start and end boundary points are identical.

Methods

SignatureDescription
__init__(owner_document: "Node")Create a collapsed range at (owner_document, 0).
set_start(node: "Node", offset: int)Set the start boundary of the range.
set_end(node: "Node", offset: int)Set the end boundary of the range.
set_start_before(node: "Node")Set the start to the position just before node in its parent.
set_start_after(node: "Node")Set the start to the position just after node in its parent.
set_end_before(node: "Node")Set the end to the position just before node in its parent.
set_end_after(node: "Node")Set the end to the position just after node in its parent.
collapse(to_start: bool)Collapse the range to its start or end boundary point.
select_node(node: "Node")Select node and all its contents.
select_node_contents(node: "Node")Select the contents of node (not the node itself).
extract_contents()"DocumentFragment"Remove and return the selected content as a DocumentFragment.
clone_contents()"DocumentFragment"Return a DocumentFragment with deep copies of the selected content.
delete_contents()Remove the selected content from the document.
insert_node(node: "Node")Insert node at the start of the range.
surround_contents(new_parent: "Node")Surround the range’s contents with new_parent.
clone_range()"Range"Return a new Range with identical boundary points.
detach()Unregister this range from live mutation tracking.
is_point_in_range(node: "Node", offset: int)boolReturn True if (node, offset) falls within the range (inclusive).
compare_point(node: "Node", offset: int)intReturn -1, 0, or 1 comparing (node, offset) against the range.
compare_boundary_points(how: int, source_range: "Range")intCompare this range with source_range using boundary mode how.
create_contextual_fragment(fragment: str)"DocumentFragment"Parse fragment in this range’s start-boundary element context.
intersects_node(node: "Node")boolReturn True if node is partially or fully within the range.
to_string()strReturn the concatenated text content of the range.

See Also