common_reports.builders.renderers.modern
Modern email view — the branded, email-client-safe style of EmailRenderer.
EmailRenderer(style="modern") builds this. The same Document tree renders
into a centred 640 px column laid out with tables (Gmail, Outlook, Apple Mail,
phones), every style inline on its element so no client can strip the look.
A <style> block adds only extras: dark mode, phone stacking, and brand
styling for trusted raw HTML.
The frame comes from a :class:Brand (masthead crest + wordmark, palette, type,
chart colours); Brand() is unbranded. Tables use the one table engine with
name hints (weights -> %, P&L -> $) that never override an explicit format.
Classes
ModernBlocks
Bases: Renderer
The modern look’s building blocks, shared by the email and the page.
Every component’s markup (text, tables, headline numbers, callouts, status
pills, buttons, charts, layouts), the masthead, footer and style sheet. A
concrete view adds its page shell (finalize) and how figures embed.
Carried state (reset by each render): the section and figure counters,
the disclaimers lifted into the footer and the first paragraph.
Fields and properties declared here; inherited members belong to the bases above.
brand
brand: Brandbuild_figure
def build_figure(figure: Figure) -> Anyrender
def render(document: Document) -> RenderResultvisit_button
def visit_button(node: Button) -> strvisit_callout
def visit_callout(node: Callout) -> strvisit_cell
def visit_cell(node: Cell) -> strvisit_columns
def visit_columns(node: Columns) -> strvisit_divider
def visit_divider(node: Divider) -> strvisit_figure
def visit_figure(node: Figure) -> strvisit_grid
def visit_grid(node: Grid) -> strvisit_heading
def visit_heading(node: Heading) -> strvisit_image
def visit_image(node: Image) -> strvisit_kpis
def visit_kpis(node: Kpis) -> strvisit_row
def visit_row(node: Row) -> strvisit_section
def visit_section(node: Section) -> strvisit_spacer
def visit_spacer(node: Spacer) -> strvisit_status
def visit_status(node: Status) -> strvisit_table
def visit_table(node: Table) -> strvisit_text
def visit_text(node: Text) -> strModernEmailRenderer
Bases: ModernBlocks, EmailRenderer
The branded email view. Build it as EmailRenderer(style="modern").
brand (default NULL_CAPITAL; Brand() for none) draws the masthead,
palette and chart colours. preheader is the inbox preview line (else the
frontmatter preheader, else the first paragraph, else the title).
images defaults to "cid": plots, byte images and the crest become
inline parts on RenderResult.attachments, sent with the HTML.
Carried state (reset by each render): the inline attachments, the
section and figure counters, the disclaimers lifted into the footer and the first
paragraph (preheader fallback).
__init__
def __init__(*, theme: Theme | None = None, title: str | None = None, date: str | None = None, images: str = 'cid', style: str = 'modern', brand: Brand | None = NULL_CAPITAL, preheader: str | None = None, **kw: Any) -> Nonefinalize
def finalize(document: Document, body: str) -> RenderResultFunctions
markdown_lite
def markdown_lite(escaped: str, *, link: str, mono: str) -> str**bold**, *italic*, `code` and [text](https://...) on
already-escaped text. Anything else stays literal.