Skip to content

Commit

Permalink
Migrate st_latex to st_markdown (#8682)
Browse files Browse the repository at this point in the history
## Describe your changes

## GitHub Issue Link (if applicable)

## Testing Plan

- Explanation of why no additional tests are needed
- Unit Tests (JS and/or Python)
- E2E Tests
- Any manual testing needed?

---

**Contribution License Agreement**

By submitting this pull request you agree that all contributions to this
project are made under the Apache 2.0 license.
  • Loading branch information
willhuang1997 committed May 17, 2024
1 parent 9d1913b commit 1b73b44
Show file tree
Hide file tree
Showing 21 changed files with 31 additions and 38 deletions.
37 changes: 0 additions & 37 deletions e2e/scripts/st_latex.py

This file was deleted.

Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions e2e_playwright/st_markdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,3 +179,24 @@ def draw_header_test(join_output):
st.text_input("This is a label", key="2")

"---"

st.latex(r"\LaTeX")

try:
import sympy

a, b = sympy.symbols("a b")
out = a + b
except:
out = "a + b"

st.latex(out)

st.latex(
r"""
a + ar + a r^2 + a r^3 + \cdots + a r^{n-1} =
\sum_{k=0}^{n-1} ar^k =
a \left(\frac{1-r^{n}}{1-r}\right)
""",
help="This is example tooltip displayed on latex.",
)
11 changes: 10 additions & 1 deletion e2e_playwright/st_markdown_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def test_different_markdown_elements_in_one_block_displayed(

markdown_elements = themed_app.get_by_test_id("stMarkdown")

expect(markdown_elements).to_have_count(50)
expect(markdown_elements).to_have_count(53)

# Snapshot one big markdown block containing a variety of elements to reduce number of snapshots
multi_markdown_format_container = markdown_elements.nth(14)
Expand Down Expand Up @@ -197,3 +197,12 @@ def test_help_tooltip_works(app: Page):

expect(tooltip_content).to_be_visible()
expect(tooltip_content).to_have_text("This is a help tooltip!")


def test_latex_elements(themed_app: Page, assert_snapshot: ImageCompareFunction):
expect(themed_app.get_by_test_id("stMarkdown").nth(50)).to_contain_text("LATE​X")
expect(themed_app.get_by_test_id("stMarkdown").nth(51)).to_contain_text("a + b")
latex_elements = themed_app.get_by_test_id("stMarkdown")

for i in range(50, 53):
assert_snapshot(latex_elements.nth(i), name=f"st_latex-{i}")

0 comments on commit 1b73b44

Please sign in to comment.