Headless Server Developer Manual / Version 2401
Table Of ContentsA context defines how to transform a specific element node of a rich text document. For this task it has a number of registered event handlers, which apply to its subnodes.
Rich text processing always starts with a Root Context, where the root tag of the markup is processed. Contexts are stacked, that is when encountering the start of a paragraph, a new context for handling the elements within that paragraph is pushed on top of current context and removed when the paragraph ends.
Defining one or more contexts is achieved with the contexts property, followed by a YAML list of context definitions.
Syntactically, a context definition consists of a context type, a name and various handlers.
Syntax:
contexts: - !context-type name: context-name defaultHandler: !Handler eventMatcher: ... contextHandler: ... outputHandler: ... handlers: - list of additional handlers ... initialContext: - !context-type ...
Example: Define three named contexts and reference context 'root' as initial context.
contexts: - !Context name: headline defaultHandler: !Handler outputHandler: !ElementWriter {writeCharacters: true} handlers: - *text_handlers - !Context name: paragraph defaultHandler: !Handler outputHandler: !ElementWriter {writeCharacters: true} handlers: - *text_handlers - *inline_handlers - &root !RootContext name: root handlers: - *headline_handlers - *block_handlers - *blockquote_handlers initialContext: *root