Markdown is a lightweight markup language that allows you to include formatted text in your report, and can be access through dp.Text
, or by passing in a string directly.
import datapane as dpdp.Report(dp.Text("__My awesome markdown__"))# or dp.Report("__My awesome markdown__")
To include multi-line text and formatting the words, use triple-quoted string, e.g. """Some words"""
import datapane as dpmd = """Quas *diva coeperat usum*; suisque, ab alii, prato. Et cornua frontes puerum,referam vocassent **umeris**. Dies nec suorum alis adstitit, *temeraria*,anhelis aliis lacunabant quoque adhuc spissatus illum refugam perterrita insonus. Facturus ad montes victima fluctus undae Zancle et nulli; frigida me.Regno memini concedant argento Aiacis terga, foribusque audit Persephoneserieque, obsidis cupidine qualibet Exadius.utf_torrent_flash = -1;urlUpnp -= leakWebE - dslam;skinCdLdap += sessionCyberspace;var ascii = address - software_compile;webFlaming(cable, pathIllegalHtml);## Quo exul exsecrere cuique non alti caerulaque*Optatae o*! Quo et callida et caeleste amorem: nocet recentibus causamque.- Voce adduntque- Divesque quam exstinctum revulsus- Et utrique eunti- Vos tantum quercum fervet et nec- Eris pennis maneas quam"""report = dp.Report(md)report.publish(name = 'markdown')
Check here for more information on how to format your text with markdown.
If your report is text-heavy (such as an blogpost) and it contains multiple other blocks, creating a list of strings and blocks in Python can be cumbersome. To solve this, Datapane provides a format
option, which allows you to write a single block of Markdown (either in your report, or in a separate file), and intersperse it with other blocks.
To do this, use double braces to specify where you want your other blocks to appear throughout your text.
import seaborn as snsimport altair as altimport datapane as dpmd = """For example, if we want to visualize the number of people in each class within the interval we select a point chart between age and fare, we could do something like this.{{plot}}Altair allows you to create some extremely interactive plots which do on-the-fly calculations — without even requiring a running Python server!"""titanic = sns.load_dataset("titanic")points = alt.Chart(titanic).mark_point().encode(x='age:Q',color='class:N',y='fare:Q',).interactive().properties(width='container')dp.Report(dp.Text(md).format(plot=points)).publish(name='altair_example')
Alternatively, you can write your article or post in your favourite markdown editor, and pass it in as a file.
import datapane as dp...dp.Report(dp.Text(file="./my_blogpost.md").format(plot=points))
The code block allows you to embed syntax highlighted source code into your report. This block currently supports Python and JavaScript.
import datapane as dpcode = '''function foo(n) {return foo(n + 1)}'''dp.Report(dp.Code(code=code,language="javascript")).publish(name='code')
The HTML block allows you to add raw HTML to your report, allowing for highly customized components, such as your company's brand, logo, and more.
The HTML component is sandboxed and cannot execute JavaScript.
import datapane as dphtml = """<html><style type='text/css'>@keyframes example {0% {color: #EEE;}25% {color: #EC4899;}50% {color: #8B5CF6;}100% {color: #EF4444;}}#container {background: #1F2937;padding: 10em;}h1 {color:#eee;animation-name: example;animation-duration: 4s;animation-iteration-count: infinite;}</style><div id="container"><h1> Welcome to my Report </h1></div></html>"""dp.Report(dp.HTML(html)).publish(name='docs_html', open=True)