charted.html package

Submodules

charted.html.element module

class charted.html.element.Circle(*args, **kwargs)

Bases: Element

tag: str = 'circle'
class charted.html.element.Element(*args, **kwargs)

Bases: object

add_child(child: Element) Element

Add a child element to the current element.

Args:

child (Element): The child element to add.

Returns:

Element: The current element instance after adding the child.

add_children(*children: list[Element]) Element

Add multiple child elements to the current element.

Args:

children (Children): An iterable containing the child elements to add.

Returns:

Element: The current element instance after adding the children.

property attributes: str

Generate the attributes passed in as kwargs as a string.

Returns:

str: A string representing HTML attributes in the format “key1=”value1” key2=”value2” …”.

children: list[Element] = []
property children_html: str

Generate HTML for children elements.

Returns:

str: A string containing the HTML markup for all child elements.

class_name: str | None = None
property html: str

Generate HTML markup for the element.

Returns:

str: A string containing the HTML markup for the element.

kwargs: dict[str, str] = {}
tag: str
class charted.html.element.G(*args, **kwargs)

Bases: Element

tag: str = 'g'
class charted.html.element.Path(*args, **kwargs)

Bases: Element

classmethod get_path(x: float, y: float, width: float, height: float) list[str]
tag: str = 'path'
class charted.html.element.Rect(*args, **kwargs)

Bases: Element

tag: str = 'rect'
class charted.html.element.Svg(*args, **kwargs)

Bases: Element

classmethod calculate_viewbox(width: float, height: float) str
kwargs: dict[str, str] = {'xmlns': 'http://www.w3.org/2000/svg'}
tag: str = 'svg'
class charted.html.element.Text(*args, **kwargs)

Bases: Element

tag: str = 'text'

charted.html.formatter module

charted.html.formatter.format_html(html: str, indent: int = 2) str

Pretty format the given HTML string.

Args:

html (str): The HTML string to format. indent (int): The number of spaces to use for indentation.

Returns:

str: The pretty-formatted HTML string.

charted.html.formatter.indent_line(line: str, level: int, indent: int) str

Indent a line based on the current nesting level.

Args:

line (str): The HTML line to indent. level (int): The current level of nesting. indent (int): The number of spaces to use for each level of indentation.

Returns:

str: The indented line.

Module contents