Note
This page is a reference documentation. It only explains the class signature, and not how to use it. Please refer to the user guide for the big picture.
brainprep.reporting.html_reporting.HTMLReport¶
- class brainprep.reporting.html_reporting.HTMLReport(html, width=800, height=800)[source]¶
Bases:
objectRender and manage HTML content for display in web pages or Jupyter notebooks.
This class encapsulates HTML content and provides utilities for rendering it inline (e.g., in Jupyter), resizing the display area, and exporting to an HTML file. It supports iframe embedding and integrates with notebook display protocols.
The different rendering are available as follows:
print the object to get the content of the web page.
from a Jupyter notebook, the plot will be displayed inline if this object is the output of a cell.
use
save_as_htmlto save it as an html file.use
get_iframeto have it wrapped in an iframe.
- Parameters:
- htmlstr
The HTML content to be rendered.
- widthint
Width of the display area in pixels. Default 800.
- heightint
Height of the display area in pixels. Default 800.
Examples
>>> html = "<h1>Hello, world!</h1>" >>> report = HTMLReport(html) >>> print(report) <h1>Hello, world!</h1> >>> report.save_as_html("/tmp/output.html")
- get_iframe(width, height)[source]¶
Get the document wrapped in an inline frame.
- Parameters:
- width: int | None
Width of the inline frame. Default None.
- height: int | None
Height of the inline frame. Default None.
- Returns:
- wrapped: str
Raw HTML code for the inline frame.
Notes
Useful for inserting the document content in another HTML page, i.e. in a Jupyter notebook.