Skip to content

Commit dfdff78

Browse files
timvinkclaude
andcommitted
Only escape the row index when it is rendered
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent f338ffa commit dfdff78

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

‎src/mkdocs_table_reader_plugin/markdown.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,9 @@ def escape(value):
6565
# Escape a copy, so that a DataFrame passed in by a macros user is left alone
6666
df = df.map(escape)
6767
df.columns = [escape(c) for c in df.columns]
68-
# Row labels and index name too, as they are rendered when index=True.
68+
# Row labels and index name too, when they are rendered (index=True).
6969
# A MultiIndex is rendered as tuple reprs, which escaping cannot fix.
70-
if not isinstance(df.index, pd.MultiIndex):
70+
if markdown_kwargs["index"] and not isinstance(df.index, pd.MultiIndex):
7171
df = df.rename(index=escape).rename_axis(index=escape)
7272

7373
return df.to_markdown(**markdown_kwargs)

0 commit comments

Comments
 (0)