From a82cdb7de59ecb45e292b09a4bb6121c058df740 Mon Sep 17 00:00:00 2001 From: Falko Schindler Date: Mon, 14 Oct 2024 10:31:00 +0200 Subject: [PATCH] Add demo about LaTeX formulas in `ui.markdown` (#3860) As @motorst1 noticed in https://github.com/zauberzeug/nicegui/discussions/696#discussioncomment-10909097, `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 --- .devcontainer/Dockerfile | 1 + development.dockerfile | 2 ++ fly.dockerfile | 2 ++ release.dockerfile | 1 + .../documentation/content/markdown_documentation.py | 12 ++++++++++++ 5 files changed, 18 insertions(+) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index cff50b495..e35defd56 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -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 diff --git a/development.dockerfile b/development.dockerfile index eaa60e344..c4c171090 100644 --- a/development.dockerfile +++ b/development.dockerfile @@ -13,4 +13,6 @@ WORKDIR /app COPY . . RUN poetry install --all-extras +RUN pip install latex2mathml + CMD python3 -m debugpy --listen 5678 main.py diff --git a/fly.dockerfile b/fly.dockerfile index 283057cdf..8357e3b9d 100644 --- a/fly.dockerfile +++ b/fly.dockerfile @@ -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 diff --git a/release.dockerfile b/release.dockerfile index eea0b52fb..125064820 100644 --- a/release.dockerfile +++ b/release.dockerfile @@ -26,6 +26,7 @@ RUN python -m pip install \ itsdangerous \ pytest \ requests \ + latex2mathml \ selenium WORKDIR /app diff --git a/website/documentation/content/markdown_documentation.py b/website/documentation/content/markdown_documentation.py index 2a1b80aeb..28d7532bb 100644 --- a/website/documentation/content/markdown_documentation.py +++ b/website/documentation/content/markdown_documentation.py @@ -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`. ''')