style(themes): compact TOML formatting and lift semantic colors
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
import os
|
||||
import tomllib
|
||||
from pathlib import Path
|
||||
|
||||
def compact_toml(path: Path):
|
||||
with open(path, "rb") as f:
|
||||
data = tomllib.load(f)
|
||||
|
||||
lines = []
|
||||
# Write top level fields
|
||||
if "name" in data: lines.append(f'name = "{data["name"]}"')
|
||||
if "syntax_palette" in data: lines.append(f'syntax_palette = "{data["syntax_palette"]}"')
|
||||
if "description" in data: lines.append(f'description = "{data["description"]}"')
|
||||
lines.append("")
|
||||
|
||||
# Write colors table
|
||||
if "colors" in data:
|
||||
lines.append("[colors]")
|
||||
colors = data["colors"]
|
||||
# Find max key length for alignment
|
||||
max_key = max(len(k) for k in colors.keys()) if colors else 0
|
||||
|
||||
# Sort keys to keep it predictable
|
||||
for k in sorted(colors.keys()):
|
||||
v = colors[k]
|
||||
# Format as compact array [R, G, B]
|
||||
val_str = f"[{v[0]:3}, {v[1]:3}, {v[2]:3}]"
|
||||
lines.append(f"{k:<{max_key}} = {val_str}")
|
||||
|
||||
path.write_text("\n".join(lines) + "\n", encoding="utf-8")
|
||||
print(f"Compacted {path}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
for f in Path("themes").glob("*.toml"):
|
||||
compact_toml(f)
|
||||
Reference in New Issue
Block a user