From dda1966d87ffc88bea11f9efdca6bfe617839e57 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Sat, 30 Nov 2024 12:56:50 -0400 Subject: 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.) --- src/data/language.js | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src') 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])); -- cgit 1.3.0-6-gf8a5