Skip to content

Commit

Permalink
refactor: remove unnecessary locals
Browse files Browse the repository at this point in the history
  • Loading branch information
KyleKing committed Feb 7, 2024
1 parent 394d3ba commit d91472c
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions mdformat_tables/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,19 @@ def _to_string(
def join_row(items: Union[Iterable[str], Sequence[str]]) -> str:
return "| " + " | ".join(items) + " |"

def format_delimeter_row(index: int, align: str) -> str:
left = ":" if align in ("<", "^") else "-"
middle = "-" * max(0, widths[index] - 2)
right = ":" if align in (">", "^") else "-"
delim = left + middle + right
def format_delimiter_cell(index: int, align: str) -> str:
delim = (
(":" if align in ("<", "^") else "-")
+ ("-" * max(0, widths[index] - 2))
+ (":" if align in (">", "^") else "-")
)
return ":-:" if delim == "::" else delim

header = join_row(
f"{{:{al or '<'}{widths[i]}}}".format(text)
for i, (text, al) in enumerate(zip(rows[0], align[0]))
)
delimiter = join_row((format_delimeter_row(i, al) for i, al in enumerate(align[0])))
delimiter = join_row((format_delimiter_cell(i, al) for i, al in enumerate(align[0])))
rows = [
join_row(
f"{{:{al or '<'}{widths[i]}}}".format(text)
Expand Down

0 comments on commit d91472c

Please sign in to comment.