Markdown#
Overview#
Markdown is a widget to display markdown flavored strings. it inherits from the SepalWidget class.
from pysepal import sepalwidgets as sw
# correct colors for the documentation
# set to dark in SEPAL by default
import ipyvuetify as v
v.theme.dark = False
str_ = """
**I am a title**
I am some regular text
"""
mkd = sw.Markdown(str_)
mkd
/home/docs/checkouts/pysepal/envs/latest/lib/python3.10/site-packages/google/api_core/_python_version_support.py:212: FutureWarning: You are using a non-supported Python version (3.10.20). Google will not post any further updates to google.api_core supporting this Python version. Please upgrade to the latest Python version, or at least Python 3.11, and then update google.api_core. warnings.warn(message, FutureWarning)
Warning
No tabulation must be applied in the multi-line
str.Don’t forget to escape the “`” character, it will be interpreted as code mark
Include multi-line markdown in the translation tool#
If you want to use the translation tool AND create multi-line markdown text you should consider the following method
in en.json use a list in your key with each element of the list corresponding to a line:
{
"_comment": "component/message/en.json",
"multiline_key": [
"this is",
" a multiline",
"key"
]
}
Then In your notebook you can call the key in a markdown widget and display it as multi-line text:
from pysepal import sepalwidgets as sw
# correct colors for the documentation
# set to dark in SEPAL by default
import ipyvuetify as v
v.theme.dark = False
multiline_key = [
"this is",
" a multiline",
"key"
]
mkd = sw.Markdown(' \n'.join(multiline_key))
mkd
Tip
line break in markdown need to be set with 2 blank space to be interpreted.
Note
More information can be found here.