mirror of
https://github.com/keymanapp/keyman.git
synced 2026-09-24 08:37:42 +00:00
fix(developer): ignore excess whitespace in <row keys> attribute
Cherry-pick-of: #12468 Fixes: #12449
This commit is contained in:
parent
13c80d53c2
commit
df1ec2fe94
3 changed files with 44 additions and 1 deletions
|
|
@ -63,7 +63,7 @@ export class LayrCompiler extends SectionCompiler {
|
|||
for (const layer of layers.layer) {
|
||||
const rows = layer.row.map((row) => {
|
||||
const erow: LayrRow = {
|
||||
keys: row.keys.split(' ').map((id) => sections.strs.allocString(id)),
|
||||
keys: row.keys.trim().split(/[ \t]+/).map((id) => sections.strs.allocString(id)),
|
||||
};
|
||||
return erow;
|
||||
});
|
||||
|
|
|
|||
18
developer/src/kmc-ldml/test/fixtures/sections/layr/row-keys-whitespace.xml
vendored
Normal file
18
developer/src/kmc-ldml/test/fixtures/sections/layr/row-keys-whitespace.xml
vendored
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<keyboard3 xmlns="https://schemas.unicode.org/cldr/45/keyboard3" locale="mt" conformsTo="45">
|
||||
<info name="keys-minimal"/>
|
||||
|
||||
<keys>
|
||||
<key id="grave" output="🪦" />
|
||||
<key id="mistake" output="oops" />
|
||||
</keys>
|
||||
|
||||
<layers formId="us">
|
||||
<layer id="base">
|
||||
<row keys=" grave mistake" />
|
||||
<row keys=" grave mistake " />
|
||||
</layer>
|
||||
</layers>
|
||||
|
||||
</keyboard3>
|
||||
|
|
@ -129,5 +129,30 @@ describe('layr', function () {
|
|||
]);
|
||||
},
|
||||
},
|
||||
{
|
||||
subpath: 'sections/layr/row-keys-whitespace.xml',
|
||||
callback(sect) {
|
||||
const layr = <Layr> sect;
|
||||
assert.ok(layr);
|
||||
assert.equal(compilerTestCallbacks.messages.length, 0);
|
||||
|
||||
assert.equal(layr.lists?.length, 1);
|
||||
const list0 = layr.lists[0];
|
||||
assert.ok(list0);
|
||||
assert.equal(list0.layers.length, 1);
|
||||
assert.equal(list0.hardware.value, 'us');
|
||||
const layer0 = list0.layers[0];
|
||||
assert.ok(layer0);
|
||||
assert.equal(layer0.rows.length, 2);
|
||||
assert.equal(layer0.id.value, 'base');
|
||||
assert.equal(layer0.mod, constants.keys_mod_none);
|
||||
for(const row of layer0.rows) {
|
||||
assert.ok(row);
|
||||
assert.equal(row.keys.length, 2);
|
||||
assert.equal(row.keys[0]?.value, 'grave');
|
||||
assert.equal(row.keys[1]?.value, 'mistake');
|
||||
}
|
||||
},
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue