etgen.html

See Usage.

Functions

CLASS(*args)

lines2p(lines[, min_height, sep])

Convert the given list of text lines lines into a paragraph (<p>) with one <br> between each line.

table_body_row(*cells, **kw)

table_header_row(*headers, **kw)

to_rst(v[, stripped])

Render the given text v as a reSTructuredText formatted string using etgen.html2rst().

tostring(v, *args, **kw)

Call lxml.etree.tostring() with the following additional rules:

tostring_pretty(*args, **kw)

Classes

Document(title[, stylesheets])

A pythonic representation of a <body> with a <title> and some <head> tags for stylesheets.

Table()

A pythonic representation of a <table> with <head>, <foot> and <body>.

etgen.html.tostring(v, *args, **kw)

Call lxml.etree.tostring() with the following additional rules:

If the value is a generator, convert each item individually and concatenate their HTML.

If the value is not an ElementTree element , just convert it into a str.

etgen.html.to_rst(v, stripped=True)

Render the given text v as a reSTructuredText formatted string using etgen.html2rst().

If v`` is an ElementTree element, parse it first using lxml.etree.fromstring().

If v is a generator, iterate over it recursively.

class etgen.html.Table

Bases: object

A pythonic representation of a <table> with <head>, <foot> and <body>.

class etgen.html.Document(title, stylesheets=None)

Bases: object

A pythonic representation of a <body> with a <title> and some <head> tags for stylesheets.

etgen.html.lines2p(lines, min_height=0, sep=functools.partial(<lxml.builder.ElementMaker object>, 'br'), **attrs)

Convert the given list of text lines lines into a paragraph (<p>) with one <br> between each line. If optional min_height is given, add empty lines if necessary.