dj_angles.htmls

Module Contents

dj_angles.htmls.VOID_ELEMENTS
dj_angles.htmls.get_outer_html(html: str, start_idx: int) dj_angles.tags.Tag | None

Get the outer HTML for just the tag at a given index.

Will not return HTML before the beginning of the tag or after the ending tag.

Example

>>> tag = get_outer_html("<span></span><div dj-if='True'><p>test</p></div><span></span>", 14)
>>> tag.outer_html
"<div dj-if='True'><p>test</p></div>"
Parameters:
  • html (str) – The HTML string to search.

  • start_idx (int, optional) – The index to start searching from.

Returns:

The tag at the given index. The outer HTML is set on tag.outer_html.

Return type:

Tag

dj_angles.htmls.find_character(html: str, start_idx: int, character: str | None = None, character_regex: str | None = None, *, reverse: bool = False) int