Style (rinoh.style)

class rinoh.style.Styled(id=None, style=None, parent=None)

A document element who’s style can be configured.

Parameters

style (str, Style) – the style to associate with this element. If style is a string, the corresponding style is lookup up in the document’s style sheet by means of selectors.

style_class

The Style subclass that corresponds to this Styled subclass.

class rinoh.style.Style(base=None, **attributes)

Dictionary storing style attributes.

The style attributes associated with this Style are specified as class attributes of type Attribute.

Style attributes can also be accessed as object attributes.

hide

Suppress rendering this element

Accepts Bool: true or false

Default: false

Style Sheet

class rinoh.style.StyleSheet(name, matcher=None, base=None, description=None, pygments_style=None, **user_options)

Dictionary storing a collection of related styles by name.

Styles stored in a StyleSheet can refer to their base style by name.

Parameters
  • name (str) – a label for this style sheet

  • matcher (StyledMatcher) – the matcher providing the selectors the styles contained in this style sheet map to. If no matcher is given and base is specified, the base‘s matcher is used. If base is not set, the default matcher is used.

  • base (StyleSheet or str) – the style sheet to extend

  • description (str) – a short string describing this style sheet

  • pygments_style (str) – the Pygments style to use for styling code blocks

get_selector(name)

Find a selector mapped to a style in this or a base style sheet.

Parameters

name (str) – a style name

Returns

Selector – the selector mapped to the style name

Raises

KeyError – if the style name was not found in this or a base style sheet

class rinoh.style.StyleSheetFile(filename, base=None, **kwargs)

Loads styles defined in a .rts file (INI format).

Parameters

filename (str) – the path to the style sheet file

StyleSheetFile takes the same optional arguments as StyleSheet. These can also be specified in the [STYLESHEET] section of the style sheet file. If an argument is specified in both places, the one passed as an argument overrides the one specified in the style sheet file.

class rinoh.style.StyledMatcher(mapping_or_iterable=None, **kwargs)

Dictionary mapping labels to selectors.

This matcher can be initialized in the same way as a dict by passing a mapping, an interable and/or keyword arguments.

update([E, ]**F) → None. Update D from dict/iterable E and F.

If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]