pyorg.convert.html.element module

class pyorg.convert.html.element.HtmlElement(tag, children=None, attrs=None, inline=False, post_ws=False)[source]

Bases: object

Lightweight class to represent an HTML element.

tag

HTML tag name (minus angle brackets).

Type:str
children

List of child elements (HtmlElement or strings).

Type:list
attrs

Mapping from attributes names (strings) to values (strings or bools).

Type:dict
inline

Whether to render children in an inline context. If False each child will be rendered on its own line. If True whitespace will only be added before/after children according to the post_ws attribute of the child.

Type:bool
classes

List of class names present in the “class” attribute. Assignable property.

Type:list
post_ws

Whether to add whitespace after the tag when rendering in an inline context.

Type:bool
add_class(classes)[source]
classes
class pyorg.convert.html.element.TextNode(text, post_ws=False)[source]

Bases: object

Text node to be used within HTML.

text

Wrapped text.

Type:str
post_ws

Whether to add whitespace after the tag when rendering in an inline context.

Type:bool
pyorg.convert.html.element.html_to_string(elem, **kwargs)[source]
pyorg.convert.html.element.write_html(stream, elem, indent='\t', inline=False)[source]