Skip to content

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: Brand

build_figure

def build_figure(figure: Figure) -> Any

render

def render(document: Document) -> RenderResult

visit_button

def visit_button(node: Button) -> str

visit_callout

def visit_callout(node: Callout) -> str

visit_cell

def visit_cell(node: Cell) -> str

visit_columns

def visit_columns(node: Columns) -> str

visit_divider

def visit_divider(node: Divider) -> str

visit_figure

def visit_figure(node: Figure) -> str

visit_grid

def visit_grid(node: Grid) -> str

visit_heading

def visit_heading(node: Heading) -> str

visit_image

def visit_image(node: Image) -> str

visit_kpis

def visit_kpis(node: Kpis) -> str

visit_row

def visit_row(node: Row) -> str

visit_section

def visit_section(node: Section) -> str

visit_spacer

def visit_spacer(node: Spacer) -> str

visit_status

def visit_status(node: Status) -> str

visit_table

def visit_table(node: Table) -> str

visit_text

def visit_text(node: Text) -> str

ModernEmailRenderer

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) -> None

finalize

def finalize(document: Document, body: str) -> RenderResult

Functions

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.