adjunct.html¶
HTML parsing and serialisation support.
Element
dataclass
¶
A HTML element.
Attributes:
| Name | Type | Description |
|---|---|---|
tag |
str | None
|
the tag name |
attrs |
dict
|
the tag's attributes |
children |
list
|
the child elements of the element |
serialize(dest=None)
¶
Serialise the element to a file-like object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dest
|
TextIO | None
|
the file-like object to serialise the document to; if this is
|
None
|
Returns:
| Type | Description |
|---|---|
TextIO
|
A file-like object containing the serialised element. |
make(tag, attrs, *, close=None)
¶
Helper for quickly constructing a HTML tag.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tag
|
str
|
tag name |
required |
attrs
|
Mapping[str, str | None]
|
attributes to apply to the tag |
required |
close
|
bool | None
|
set to |
None
|
Returns:
| Type | Description |
|---|---|
str
|
the tag |