aeidon.Markup

Source: aeidon/markup.py

Anchestors: aeidon.singleton.Singleton, builtins.object

class aeidon.Markup

Base class for text markup.

Markup conversions between different formats are done via an internal format, which has the following BBcode-style tags with angle brackets. Conversions are best done via the _decode_* and _encode_* methods rather than hard-coding internal tags in regular expression substitutions.

  • <b>...................</b>
  • <i>...................</i>
  • <u>...................</u>
  • <color=#RRGGBB>...</color>
  • <font=NAME>........</font>
  • <size=POINTS>......</size>

Markup is effectively equivalent to a format with no markup and can therefore be merely subclassed with a pass-statement by formats that do not implement any markup. The caller of any tagging methods, e.g. bolden(), must be prepared to handle NotImplementedError.

Methods

Markup.bolden(text, bounds=None)

Return bolded text.

Markup.clean(text)

Return text with less ugly markup.

Subclasses can implement this to, for example, remove redundant markup, finetune tag positioning or to join or split tags; in general, whatever that changes the style of the markup but not that of the text.

Markup.colorize(text, color, bounds=None)

Return text colorized to hexadecimal value.

Markup.decode(text)

Return text with markup converted from this to internal format.

Markup.encode(text)

Return text with markup converted from internal to this format.

Markup.fontify(text, font, bounds=None)

Return text changed to font.

Markup.italicize(text, bounds=None)

Return italicized text.

Markup.scale(text, size, bounds=None)

Return text scaled to size.

Markup.underline(text, bounds=None)

Return underlined text.