Skip to content

A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.

Enable python-markdown tables extension (#294)

Akshay Agrawal307b3057b13b
diff --git a/frontend/src/css/table.css b/frontend/src/css/table.css
index 7e7112b7a8..d07bb51fd8 100644
--- a/frontend/src/css/table.css
+++ b/frontend/src/css/table.css
@@ -1,3 +1,4 @@
+.markdown table,
table.dataframe {
border: none;
border-collapse: collapse;
@@ -9,6 +10,7 @@ table.dataframe {
overflow: auto;
}
+.markdown table thead,
table.dataframe thead {
border-bottom: 1px solid;
vertical-align: bottom;
@@ -16,18 +18,24 @@ table.dataframe thead {
@apply border-foreground;
}
+.markdown table tbody tr:nth-child(odd),
table.dataframe tbody tr:nth-child(odd) {
background: var(--lime-2);
}
+.markdown table tbody tr:nth-child(even),
table.dataframe tbody tr:nth-child(even) {
@apply bg-card;
}
+.markdown table tbody tr:hover,
table.dataframe tbody tr:hover {
background: var(--yellow-5);
}
+.markdown table tr,
+.markdown table th,
+.markdown table td,
table.dataframe tr,
table.dataframe th,
table.dataframe td {
@@ -41,6 +49,7 @@ table.dataframe td {
font-size: 0.875rem;
}
+.markdown table th,
table.dataframe th {
font-weight: bold;
}
diff --git a/marimo/_output/md.py b/marimo/_output/md.py
index 2d4d944b8a..21c7b167b0 100644
--- a/marimo/_output/md.py
+++ b/marimo/_output/md.py
@@ -38,6 +38,8 @@ def _md(text: str, apply_markdown_class: bool = True) -> Html:
extensions=[
# Syntax highlighting
"codehilite",
+ # Markdown tables
+ "tables",
# LaTeX
"pymdownx.arithmatex",
# Subscripts and strikethrough
diff --git a/marimo/_smoke_tests/md_table.py b/marimo/_smoke_tests/md_table.py
new file mode 100644
index 0000000000..e24cde1719
--- /dev/null
+++ b/marimo/_smoke_tests/md_table.py
@@ -0,0 +1,42 @@
+# Copyright 2023 Marimo. All rights reserved.
+import marimo
+
+__generated_with = "0.1.42"
+app = marimo.App()
+
+
+def __():
+ import marimo as mo
+ return mo,
+
+
+def __(mo):
+ mo.md(
+ """
+ First Header | Second Header
+ ------------- | -------------
+ Content Cell | Content Cell
+ $f(x)$ | Content Cell
+ """
+ )
+ return
+
+
+def __(mo):
+ mo.md(
+ """
+ | Tables | Are | Cool |
+ | ------------- |:-------------:| -----:|
+ | col 3 is | right-aligned | $1600 |
+ | col 2 is | centered | $12 |
+ | zebra stripes | are neat | $1 |
+ """
+ )
+ return
+
+
+if __name__ == "__main__":
+ app.run()