FLM Rendering¶
During rendering, two main objects work together:
The render context (
FLMRenderContext) carries the state of the rendering process. It tracks which features are active, manages delayed rendering (for forward references like\ref), and provides a logical-state mechanism that nodes can use to adjust their output depending on nesting depth or other context.For document-mode rendering, the concrete subclass
FLMDocumentRenderContextis used. It adds support for feature render managers, delayed rendering of forward references, and per-render data storage. In standalone mode, a minimalFLMStandaloneModeRenderContextis used instead.The fragment renderer (
FragmentRenderer) is responsible for producing the final output string in a specific format. Each output format (HTML, text, LaTeX, Markdown) has its own fragment renderer subclass. The fragment renderer provides methods for rendering text formatting, headings, lists, math, links, and other structural elements.
The rendering pipeline proceeds as follows:
A
FLMDocumentcreates aFLMDocumentRenderContext(a subclass ofFLMRenderContext) with the active features and fragment renderer.The document’s render callback is invoked, which calls
render()on each fragment.Each node in the fragment’s node tree calls its spec info’s
render()method, which in turn calls methods on the fragment renderer to produce the output.For nodes with delayed rendering (e.g.,
\ref), a placeholder is inserted on the first pass, and the actual content is filled in on subsequent passes.