estnltk.prettyprinter.prettyprinter module

Estnltk prettyprinter module. Deals with rendering Text instances as HTML.

class estnltk.prettyprinter.prettyprinter.PrettyPrinter(**kwargs)[source]

Class for formatting Text instances as HTML & CSS.

Methods

render(text[, add_header]) Render the HTML.
aesthetics

Mapping of aesthetics mapped to layers.

css
Returns:

str

The CSS.

render(text, add_header=False)[source]

Render the HTML.

Parameters:

add_header: boolean (default: False)

If True, add HTML5 header and footer.

Returns:

str

The rendered HTML.

values

Mapping of aesthetic values.

Assert that PrettyPrinter arguments are correct.

Raises:

ValueError

In case there are unknown arguments or a single layer is mapped to more than one aesthetic.

estnltk.prettyprinter.prettyprinter.parse_arguments(kwargs)[source]

Function that parses PrettyPrinter arguments. Detects which aesthetics are mapped to which layers and collects user-provided values.

Parameters:

kwargs: dict

The keyword arguments to PrettyPrinter.

Returns:

dict, dict

First dictionary is aesthetic to layer mapping. Second dictionary is aesthetic to user value mapping.