INNER CODE UNIT · Python
fix_indentation_manually
magicsword-io/LOLRMM · bin/fix_yaml_formatting.py:8
def fix_indentation_manually(content):
lines = content.split("\n")
fixed_lines = []
# Stack of (dash_indent, expected_continuation_indent) for nested lists
list_stack = []
last_key_indent = (
None # Track the indent of the last key that might have a list under it
)
# Track indent adjustments: {original_indent: adjusted_indent}
dash_adjustments = {}
for i, line in enumerate(lines):
# Empty lines or comments
if not line or not line.strip() or line.strip().startswith("#"):
fixed_lines.append(line)
last_key_indent = None
continue