pre-big change

This commit is contained in:
2026-03-09 18:27:26 +01:00
parent fbc61e9fb2
commit 1312baa41d
14 changed files with 905 additions and 304 deletions

View File

@@ -24,7 +24,9 @@ END_RE = re.compile(r"^\s*end\b")
def format_modelica(text: str) -> str:
lines = text.replace("\t", " ").splitlines()
normalized = text.replace("\r\n", "\n").replace("\r", "\n").replace("\t", " ")
had_trailing_newline = normalized.endswith("\n")
lines = normalized.split("\n")
out = []
indent = 0
@@ -63,7 +65,10 @@ def format_modelica(text: str) -> str:
elif SECTION_RE.match(stripped):
indent += 1
return "\n".join(out) + "\n"
formatted = "\n".join(out)
if had_trailing_newline:
return formatted
return formatted + "\n"
def main():