Use html_to_nodes(html_content) to transform an HTML string into a structured list of nodes (dictionaries and strings) that Telegraph understands.
Constraints:
- Only a specific subset of HTML tags is allowed (defined in
ALLOWED_TAGS). If an unallowed tag is encountered, a NotAllowedTag exception is raised. - The input HTML must be well-formed. If tags are mismatched or unclosed, an
InvalidHTML exception is raised.
Allowed Tags include: a, aside, b, blockquote, br, code, em, figcaption, figure, h3, h4, hr, i, iframe, img, li, ol, p, pre, s, strong, u, ul, video.
from telegraph.utils import html_to_nodes
html = '<p>Hello <b>World</b></p>'
nodes = html_to_nodes(html)
# Resulting nodes will be a list of dictionaries and strings representing the structure.