great-tables
great-tables copied to clipboard
Does not render table markdown correctly when columns are formatted with GT.fmt_markdown
trafficstars
Description
Does not render table markdown correctly when columns are formatted with GT.fmt_markdown
Reproducible example
import pandas as pd
from great_tables import GT, md
from faker import Faker
import random
fake = Faker()
markdown_syntax = [
"# Heading 1",
"## Heading 2",
"### Heading 3",
"This is *italic* text.",
"This is **bold** text.",
"A [Click me](https://posit-dev.github.io/great-tables/articles/intro.html).",
"- List item 1\n- List item 2\n- List item 3",
"1. Ordered item 1\n2. Ordered item 2\n3. Ordered item 3",
"```python\nprint('Hello, World!')\n```",
"""
| Column 1 | Column2 |
| ----------- | ----------- |
| Row 1 Column 1 | Row 1 Column 2 |
| Row 2 Column 1 | Row 2 Column 2 |
""",
"😅",
"I need to highlight these ==very important words==.",
"H~2~O",
"X^2^",
"- [x] Write the press release",
"",
"",
"",
"""
> Blockquotes can be nested. Add a >> in front of the paragraph you want to nest.
>
>> Blockquotes can be nested. Add a >> in front of the paragraph you want to nest.
""",
"""
1. First item
2. Second item
3. Third item
1. Indented item
2. Indented item
4. Fourth item
""",
]
df = pd.DataFrame({'rendered markdown': markdown_syntax})
df['unrendered markdown'] = df['rendered markdown']
df['name'] = [fake.name() for _ in range(len(df))]
df['email'] = [fake.email() for _ in range(len(df))]
df['age'] = [fake.random_int(18, 99) for _ in range(len(df))]
df['is student'] = [fake.boolean() for _ in range(len(df))]
df['grade'] = [random.choice(['A', 'B', 'C', 'D', 'F']) for _ in range(len(df))]
df['gpa'] = [random.uniform(2.0, 4.0) for _ in range(len(df))]
df['date joined'] = [fake.date_this_decade() for _ in range(len(df))]
df_sorted_desc = df.sort_values(by='grade', ascending=True)
(
GT(df_sorted_desc,rowname_col="name", groupname_col="grade")
.fmt_markdown(columns="rendered markdown")
.fmt_date(columns="date joined", date_style="m_day_year")
.tab_spanner(
label=md("<b><i>Personal Information</b></i>"),
columns=["name", "email", "age", "grade", "gpa"],
)
.fmt_number(columns=["gpa"], decimals=2)
.tab_stubhead(label="Students grouped by their grades")
)
Observe the cell where table markdown is rendered
Expected result
Should render table markdown as a table.
Development environment
- Operating System: macOS
- great_tables Version: 0.1.1