html.py

HTML utilities for mdpo.

mdpo.html.get_html_attrs_tuple_attr(attrs, attrname)

Returns the value of an attribute from an attributes tuple.

Given a list of tuples returned by an attrs argument value from html.parser.HTMLParser.handle_starttag() method, and an attribute name, returns the value of that attribute.

Parameters
Returns

Value of the attribute, if found, otherwise None.

Return type

str

mdpo.html.html_attrs_tuple_to_string(attrs)

Converts a set of HTML attributes tuple to an HTML string.

Converts all HTML attributes returned by html.parser.HTMLParser.handle_starttag() attrs value into their original HTML representation.

Parameters

attrs (list) – List of attributes, each item being a tuple with two values, the attribute name as the first and the value as the second.

Returns

HTML attributes string ready to be used inside a HTML tag.

Return type

str