From e7a5a088bc467e381ce7e5c643d7737abce9528b Mon Sep 17 00:00:00 2001 From: Taneli Hukkinen <3275109+hukkin@users.noreply.github.com> Date: Tue, 22 Oct 2024 09:53:34 +0300 Subject: [PATCH] Remove global variable --- mdformat_tables/plugin.py | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/mdformat_tables/plugin.py b/mdformat_tables/plugin.py index 8c4a91a..7b69a2c 100644 --- a/mdformat_tables/plugin.py +++ b/mdformat_tables/plugin.py @@ -6,9 +6,6 @@ from mdformat.renderer.typing import Postprocess, Render from wcwidth import wcswidth -_COMPACT_TABLES = False -"""user-specified flag for toggling compact tables.""" - def add_cli_options(parser: argparse.ArgumentParser) -> None: """Add options to the mdformat CLI, to be stored in `mdit.options["mdformat"]`.""" @@ -23,9 +20,6 @@ def update_mdit(mdit: MarkdownIt) -> None: """Update the parser, e.g. by adding a plugin: `mdit.use(myplugin)`""" mdit.enable("table") - global _COMPACT_TABLES - _COMPACT_TABLES = mdit.options["mdformat"].get("compact_tables", False) - def _lpad(text: str, width: int) -> str: indent = width - wcswidth(text) @@ -98,7 +92,7 @@ def _render_table(node: RenderTreeNode, context: RenderContext) -> str: def _calculate_width(col_idx: int) -> int: """Work out the widths for each column.""" - if _COMPACT_TABLES: + if context.options["mdformat"].get("compact_tables", False): return 0 return max(3, *(wcswidth(row[col_idx]) for row in rows))