1
0
Fork 0

CLI: Add 'via2json' subcommand (#16468)

This commit is contained in:
Erovia 2022-03-24 20:13:40 +00:00 committed by GitHub
parent f7a5ec2483
commit efc9c525b1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 176 additions and 2 deletions

View file

@ -146,7 +146,13 @@ class KeymapJSONEncoder(QMKJSONEncoder):
if key == 'JSON_NEWLINE':
layer.append([])
else:
layer[-1].append(f'"{key}"')
if isinstance(key, dict):
# We have a macro
# TODO: Add proper support for nicely formatting keymap.json macros
layer[-1].append(f'{self.encode(key)}')
else:
layer[-1].append(f'"{key}"')
layer = [f"{self.indent_str*indent_level}{', '.join(row)}" for row in layer]