diff --git a/developer/src/kmc-ldml/src/compiler/visual-keyboard-compiler.ts b/developer/src/kmc-ldml/src/compiler/visual-keyboard-compiler.ts index 7783d42405..7a4d5d37f0 100644 --- a/developer/src/kmc-ldml/src/compiler/visual-keyboard-compiler.ts +++ b/developer/src/kmc-ldml/src/compiler/visual-keyboard-compiler.ts @@ -135,7 +135,9 @@ export class LdmlKeyboardVisualKeyboardCompiler { private getDisplayFromKey(keydef: KMXPlus.KeysKeys, source: KMXPlus.KMXPlusData) { const display = source.disp?.disps?.find(d => d.id.value == keydef.id.value || d.to.value == keydef.to.value); - return display?.display.value ?? keydef.to.value; + const value = display?.display.value ?? keydef.to.value; + // strip markers from the output (these are valid in keydef.to, but not in display.display, nor in kvk) + return value.replaceAll(/\uffff\u0008./g, ''); } private translateLayerModifiersToVisualKeyboardShift(modifiers: number): VisualKeyboard.VisualKeyboardShiftState { diff --git a/developer/src/kmc-ldml/test/disp.tests.ts b/developer/src/kmc-ldml/test/disp.tests.ts index 36f08f2780..31d79ac5e2 100644 --- a/developer/src/kmc-ldml/test/disp.tests.ts +++ b/developer/src/kmc-ldml/test/disp.tests.ts @@ -56,7 +56,13 @@ describe('disp', function () { assert.equal(disp?.baseCharacter?.value, 'x'); assert.ok(disp?.disps); }); - + it('should compile disp without converting markers', async function() { + let disp = await loadSectionFixture(DispCompiler, 'sections/disp/not-a-marker.xml', compilerTestCallbacks) as Disp; + assert.equal(compilerTestCallbacks.messages.length, 0); + assert.ok(disp?.disps); + assert.equal(disp.disps.length, 1); + assert.equal(disp.disps[0].display?.value, '\\m{hat}'); + }); it('should reject duplicate tos', async function() { let disp = await loadSectionFixture(DispCompiler, 'sections/disp/invalid-dupto.xml', compilerTestCallbacks) as Disp; assert.isNull(disp); diff --git a/developer/src/kmc-ldml/test/fixtures/sections/disp/not-a-marker.xml b/developer/src/kmc-ldml/test/fixtures/sections/disp/not-a-marker.xml new file mode 100644 index 0000000000..5ff7196e30 --- /dev/null +++ b/developer/src/kmc-ldml/test/fixtures/sections/disp/not-a-marker.xml @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/developer/src/kmc-ldml/test/visual-keyboard-compiler.tests.ts b/developer/src/kmc-ldml/test/visual-keyboard-compiler.tests.ts index 25e3abb47b..77a8482090 100644 --- a/developer/src/kmc-ldml/test/visual-keyboard-compiler.tests.ts +++ b/developer/src/kmc-ldml/test/visual-keyboard-compiler.tests.ts @@ -184,6 +184,26 @@ describe('visual-keyboard-compiler', function() { assert.equal(vk.keys[0].text, '2'); }); + it('should strip markers from key.output', async function() { + const xml = stripIndent` + + + + + + + + + + + `; + + const vk = await loadVisualKeyboardFromXml(xml, 'test'); + + assert.equal(vk.keys.length, 1); + assert.equal(vk.keys[0].text, '12'); // marker stripped from `12` + }); + it('should read string variables in display.display', async function() { const xml = stripIndent`