Write apps in Markdown
This guide addresses how to write Panel apps inside Markdown files.
Panel applications can be written as Python scripts (.py
), notebooks (.ipynb
) and also Markdown files (.md
). This is particularly useful when writing applications that serve both as documentation and as an application, e.g. when writing a demo.
To begin simply create a Markdown file with the .md
file extension, e.g. app.md
. Once created give your app a title:
Before adding any actual content add a code block with any imports your application needs. The code block should have one of two type declarations, either python
or {pyodide}
. The latter is useful if you also want to use the Sphinx Pyodide integration. In this case we will simply declare a python
code block that imports Panel and calls the extension with a specific template:
Once we have initialized the extension any subsequent Markdown will be rendered as part of the application, e.g. we can put some description in our application. If you also want to render some Python code without having Panel interpret it as code, use .py
as the language declaration:
Now we can add some actual Panel contents, again inside a python
code block:
To put it all together, here is what our app looks like:
:::{card} app.md
:::
Then, from the command line, launch a server with: