diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2024-11-30 12:56:50 -0400 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2024-11-30 13:10:19 -0400 |
commit | dda1966d87ffc88bea11f9efdca6bfe617839e57 (patch) | |
tree | 8cee0f9618b85cae037802f93dcd3fbe07ffbd8d /src | |
parent | 69bccc5b3339f943fb60256827933682d8e3afe9 (diff) |
language: unflattenLanguageSpec: no lonely '_' keys
This might be a crude implementation, but keeps language results from including {_: 'some string...'} objects that don't have any other keys, even when preventing so causes a mismatch with the reference spec/layout. (Of course, the "mismatch" is only presentationally and not semantically, and we already make other presentational differences because we output JSON and not YAML in this function.)
Diffstat (limited to 'src')
-rw-r--r-- | src/data/language.js | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/data/language.js b/src/data/language.js index a149e19f..f91e123d 100644 --- a/src/data/language.js +++ b/src/data/language.js @@ -110,6 +110,12 @@ export function unflattenLanguageSpec(flat, reference) { return {[firstKey]: result}; } + const resultKeys = Object.keys(result); + if (resultKeys.length === 1 && resultKeys[0] === '_') { + delete ownNode[firstKey]; + return {[firstKey]: result._}; + } + if (refKeys.length > 1) { return withEntries(result, entries => entries.map(([key, value]) => [`${firstKey}.${key}`, value])); |