Skip to content

Commit

Permalink
Add demo about LaTeX formulas in ui.markdown (#3860)
Browse files Browse the repository at this point in the history
As @motorst1 noticed in
#696 (comment),
`ui.markdown` can display LaTeX formulas. This PR adds a demo with notes
about required packages.

Open tasks:

- [x] add latex2mathml to release.dockerfile? (and somewhere else?)
- [x] raise markdown2 requirement to version >=2.5? --> No, we leave it
as it is.

---------

Co-authored-by: Rodja Trappe <[email protected]>
  • Loading branch information
falkoschindler and rodja authored Oct 14, 2024
1 parent 70d442f commit a82cdb7
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ ENV CHROME_BINARY_LOCATION=/usr/bin/chromium
RUN pip install -U pip && pip install poetry==$POETRY_VERSION
COPY pyproject.toml poetry.lock README.md ./
RUN poetry install --all-extras --no-root
RUN pip install latex2mathml

USER $USERNAME

Expand Down
2 changes: 2 additions & 0 deletions development.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,6 @@ WORKDIR /app
COPY . .
RUN poetry install --all-extras

RUN pip install latex2mathml

CMD python3 -m debugpy --listen 5678 main.py
2 changes: 2 additions & 0 deletions fly.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ COPY pyproject.toml poetry.lock* ./

RUN poetry install --no-root --extras "plotly matplotlib highcharts sass"

RUN pip install latex2mathml

ADD . .

# ensure unique version to not serve cached and hence potentially wrong static files
Expand Down
1 change: 1 addition & 0 deletions release.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ RUN python -m pip install \
itsdangerous \
pytest \
requests \
latex2mathml \
selenium

WORKDIR /app
Expand Down
12 changes: 12 additions & 0 deletions website/documentation/content/markdown_documentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,18 @@ def markdown_tables():
''', extras=['tables'])


@doc.demo('LaTeX formulas', '''
By activating the "latex" extra, you can use LaTeX formulas.
This requires markdown2 version >=2.5 as well as latex2mathml to be installed.
''')
def markdown_latex():
ui.markdown(r'''
Euler's identity:
$$e^{i\pi} = -1$$
''', extras=['latex'])


@doc.demo('Change Markdown content', '''
You can change the content of a Markdown element by setting its `content` property or calling `set_content`.
''')
Expand Down

0 comments on commit a82cdb7

Please sign in to comment.