wmllint: automatically remove {MAGENTA_IS_THE_TEAM_COLOR}

This commit is contained in:
Elvish_Hunter 2021-12-03 11:51:27 +01:00
parent 4bf0476b95
commit 35676b08b1
2 changed files with 17 additions and 0 deletions

View file

@ -17,6 +17,7 @@
### WML Engine
### Miscellaneous and Bug Fixes
* Password storage was fixed to work with multiple accounts (PR #6290)
* wmllint now automatically removes {MAGENTA_IS_THE_TEAM_COLOR}.
## Version 1.16.1
### Add-ons server

View file

@ -2681,6 +2681,22 @@ def hack_syntax(filename, lines):
in_side_one_tag = False
side_one_tag_needs_side_one = True
break
# handle removal of {MAGENTA_IS_THE_TEAM_COLOR}
for i, line in enumerate(lines):
if "no-syntax-rewrite" in line:
break
m = re.match(r"(\s*)\{MAGENTA_IS_THE_TEAM_COLOR\}(.*)", line)
if m:
new_line = m.group(1) + m.group(2).lstrip()
if new_line.isspace():
# only empty spaces, make the line blank
# don't remove the line to not alter the other for cycles
lines[i] = "\n"
else:
# keep indentation and comments
lines[i] = new_line + "\n"
print('"{}", line {}: removed MAGENTA_IS_THE_TEAM_COLOR'.format(filename,
i+1))
# More syntax transformations would go here.
return lines