Skip to content

Commit

Permalink
feature: iterate backward to get index of first trailing space of a g…
Browse files Browse the repository at this point in the history
…iven column
  • Loading branch information
mecaneer23 committed Jan 28, 2024
1 parent 2fd4e7c commit d22fe5e
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/md_to_py.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,19 @@ def _pad_columns(row: str, widths: tuple[int, ...] | int, delimiter: str = "|")
widths = tuple(repeat(widths, column_count))

count = 0
column = 0
column = -1
backward_count = 1
trailing_space_start = 0
new_row = ""

while count < len(row):
raise NotImplementedError("_pad_columns")
# - iterate backward to get index of first trailing
# space in this column
if row[count] == delimiter and count != 0:
while row[count - backward_count] == " ":
backward_count += 1
trailing_space_start = count - backward_count + 1
print(trailing_space_start)
backward_count = 1
count += 1
# - add or remove trailing spaces based on that value
# (and the value of widths for that column)
# - because we shouldn't modify the arguments, add
Expand Down

0 comments on commit d22fe5e

Please sign in to comment.