Skip to content

Commit

Permalink
Don't fetch compact_tables option for each column
Browse files Browse the repository at this point in the history
  • Loading branch information
hukkin committed Oct 22, 2024
1 parent e7a5a08 commit 00db791
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion mdformat_tables/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ def format_delimiter_cell(index: int, align: str) -> str:

def _render_table(node: RenderTreeNode, context: RenderContext) -> str:
"""Render a `RenderTreeNode` of type "table"."""
compact_tables = context.options["mdformat"].get("compact_tables", False)
# gather rendered cell content into row * column array
rows: List[List[str]] = []
align: List[List[str]] = []
Expand All @@ -92,7 +93,7 @@ def _render_table(node: RenderTreeNode, context: RenderContext) -> str:

def _calculate_width(col_idx: int) -> int:
"""Work out the widths for each column."""
if context.options["mdformat"].get("compact_tables", False):
if compact_tables:
return 0
return max(3, *(wcswidth(row[col_idx]) for row in rows))

Expand Down

0 comments on commit 00db791

Please sign in to comment.