HtmlReportRenderer

class HtmlReportRenderer(ctx: RenderContext = RenderContext(), cssPath: Path? = null, css: String? = null) : AbstractReportVisitor(source)

A ReportVisitor that renders a ReportNode tree to a self-contained HTML file.

Structure:

  • <html><head> — inline REPORT_CSS + Lets-Plot CDN <script> (emitted once)

  • <body> — content; <h1> document title

  • <details open><summary> — collapsible sections (nested sections indent)

  • <footer> — generated timestamp

Node rendering:

The Lets-Plot CDN <script> is emitted exactly once inside <head> so all embedded plot fragments can share it. Plots beyond RenderContext.maxPlotsPerSection per section are replaced with a <p class="plot-omitted"> notice.

All mutable state uses the my prefix per KSL coding conventions.

CSS selection (evaluated in priority order):

  1. cssPath non-null → <link rel="stylesheet" href="..."> is emitted; no inline <style> block

  2. css non-null → the supplied string is inlined in a <style> block

  3. Both null (default) → REPORT_CSS is inlined in a <style> block

Parameters

ctx

the render context supplying output paths and formatting preferences

cssPath

path to an external CSS file; when non-null a <link> tag is emitted and css is ignored

css

inline CSS string to embed in a <style> block; only used when cssPath is null; when both are null REPORT_CSS is used

Constructors

Link copied to clipboard
constructor(ctx: RenderContext = RenderContext(), cssPath: Path? = null, css: String? = null)

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
open override fun enterDocument(node: ReportNode.Document)
Link copied to clipboard
open override fun enterSection(node: ReportNode.Section)
Link copied to clipboard
open override fun exitDocument(node: ReportNode.Document)
Link copied to clipboard
open override fun exitSection(node: ReportNode.Section)
Link copied to clipboard
fun result(): String

Returns the accumulated HTML report as a String.

Link copied to clipboard

Writes the accumulated HTML to a temporary file in RenderContext.outputDir and opens it in the system default browser. Returns the File that was created.

Link copied to clipboard
open override fun visit(node: ReportNode.DataTable)
open override fun visit(node: ReportNode.Heading)
open override fun visit(node: ReportNode.PageBreak)
open override fun visit(node: ReportNode.Paragraph)
open override fun visit(node: ReportNode.PlotNode)
open override fun visit(node: ReportNode.RawText)
open override fun visit(node: ReportNode.StatPropertyTable)
open override fun visit(node: ReportNode.StatTable)
open override fun visit(node: ReportNode.WeightedStatTable)
Link copied to clipboard
fun writeToFile(path: Path): File

Writes the accumulated report to a file at path and returns a File reference.