class documentation
class ZMSTextformat(object): (source)
Constructor: ZMSTextformat(id, ob, manage_lang)
Represent one text-format definition and provide rendering helpers.
A text format defines the outer tag, optional inner sub-tag, additional HTML attributes, editor-availability flag, and usage categories.
| Method | __init__ |
Initialize the text-format object from its persisted configuration mapping. |
| Method | get |
Return the raw HTML attribute string for the outer tag. |
| Method | get |
Return the management label shown for this text format. |
| Method | get |
Return the closing HTML tag for the configured outer tag. |
| Method | get |
Return a management-preview HTML snippet for this text format. |
| Method | get |
Return the text-format identifier. |
| Method | get |
Return whether this format is available in rich-text editing. |
| Method | get |
Build the opening HTML tag for this text format. |
| Method | get |
Return the optional sub-tag used for line-level wrapping. |
| Method | get |
Return the outer HTML tag used for rendering. |
| Method | get |
Return the usage categories where this format is offered. |
| Method | parse |
Parse the raw attribute string into (name, value) tuples. |
| Method | render |
Render input text according to this text format definition. |
| Method | set |
Set the raw HTML attribute string for the outer tag. |
| Method | set |
Set the management label shown for this text format. |
| Method | set |
Set the text-format identifier. |
| Method | set |
Set the rich-text-editor availability flag. |
| Method | set |
Set the optional sub-tag used for line-level wrapping. |
| Method | set |
Set the outer HTML tag used for rendering. |
| Method | set |
Set the usage categories where this format is offered. |
| Class Variable | get |
Undocumented |
| Class Variable | get |
Undocumented |
| Class Variable | get |
Undocumented |
| Class Variable | get |
Undocumented |
| Class Variable | get |
Undocumented |
| Class Variable | get |
Undocumented |
| Class Variable | get |
Undocumented |
| Class Variable | get |
Undocumented |
| Class Variable | get |
Undocumented |
| Class Variable | get |
Undocumented |
| Class Variable | parse |
Undocumented |
| Class Variable | render |
Undocumented |
| Instance Variable | attrs |
Undocumented |
| Instance Variable | display |
Undocumented |
| Instance Variable | id |
Undocumented |
| Instance Variable | richedit |
Undocumented |
| Instance Variable | subtag |
Undocumented |
| Instance Variable | tag |
Undocumented |
| Instance Variable | usage |
Undocumented |
Initialize the text-format object from its persisted configuration mapping.
| Parameters | |
| id:str | Text-format identifier. |
| ob:dict | Persisted format definition containing keys like display, tag, subtag, attrs, optional richedit, and optional usage. |
| manage | Language used to select the display label. |
Return a management-preview HTML snippet for this text format.
| Returns | |
| str | HTML preview showing opening tag, sample content, and closing tag. |
Build the opening HTML tag for this text format.
| Parameters | |
| id:str or None | Optional DOM id attribute for the opening tag. |
| clazz:str or None | Optional CSS class attribute for the opening tag. |
| Returns | |
| str | Opening tag HTML or an empty string when no outer tag is defined. |
Parse the raw attribute string into (name, value) tuples.
| Returns | |
| list | List of parsed attribute-name/value tuples. |
def renderText(self, context, text, id=None, clazz=None, encoding='utf-8', errors='strict'):
(source)
¶
Render input text according to this text format definition.
The method wraps transformed text with opening/closing tags generated by this format. Line handling is delegated to br_quote.
| Parameters | |
| context:object | Rendering context passed to br_quote. |
| text:str or bytes | Input text or bytes to render. |
| id:str or None | Optional DOM id for the opening tag. |
| clazz:str or None | Optional CSS class for the opening tag. |
| encoding:str | Character encoding used when decoding byte strings. |
| errors:str | Error handling mode for byte decoding. |
| Returns | |
| str | Rendered HTML fragment. |