styles
¶
These functions provide functionality to format richtext with the styles of the current theme.
New in version 1.2.
Module Functions¶
- styles.as_font(style, text)¶
Format the given text with the given font style.
- Parameters
style (class:string) – Name of the font style to use.
text (class:string) – Text to format.
- Returns
The text with richtext tags.
- styles.as_paragraph(style, text)¶
Format the given text as a paragraph with the given paragraph style.
- Parameters
style (class:string) – Name of the paragraph style to use.
text (class:string) – Text to format.
- Returns
The text with richtext tags.
- styles.as_p_with_attr(style, attributes, text)¶
Format the given text as a paragraph with the given paragraph style and extra attributes.
- Parameters
style (class:string) – Name of the paragraph style to use.
attributes (class:string) – Attributes for the paragraph tag. For possible attributes see the p tag’s documentation.
text (class:string) – Text to format.
- Returns
The text with richtext tags.
Example:
include "scripting/richtext.lua" formatted_text = rt( styles.as_paragraph("wui_text", _("This paragraph is left aligned") ) .. styles.as_p_with_attr("wui_text", "align=center", _("This paragraph is centered") ) )
- styles.open_p(style)¶
Return richtext formatting to start a paragraph with the given paragraph style.
- Parameters
style (class:string) – Name of the paragraph style to use.
- Returns
The richtext formatting that starts a paragraph.
- styles.open_p_with_attr(style, attributes)¶
Return richtext formatting to start a paragraph style with the given style and extra attributes.
- Parameters
style (class:string) – Name of the paragraph style to use.
attributes (class:string) – Attributes for the paragraph tag. For possible attributes see the p tag’s documentation.
- Returns
The richtext formatting that starts the paragraph.
- styles.close_p(style)¶
Return richtext formatting to close a paragraph of the given style.
- Parameters
style (class:string) – Name of the paragraph style to use.
- Returns
The richtext formatting that closes a paragraph.
- styles.as_font_from_p(p_style, text)¶
Format the given text with the font style of the given paragraph style without the paragraph tags.
- Parameters
p_style – Name of the paragraph style to use.
text (class:string) – Text to format.
- Returns
The text with richtext tags.
- styles.color(style_name)¶
Return the given color style in hex format suitable for font tags.
- Parameters
style_name (class:string) – Name of the color style to use.
- Returns
The color as 6 characters hexadecimal RGB value.
- styles.get_size(style_name)¶
Return the given styled size.
- Parameters
style_name (class:string) – Name of the styled size to get.
- Returns
The integer value of the size, or 0 if no styled size is defined with the given style_name.