From c147c6b6526ae3f967090a2c871cd66f010e3fe7 Mon Sep 17 00:00:00 2001 From: Enoch Riese Date: Tue, 18 Apr 2023 16:40:30 -0400 Subject: [PATCH] fix (banner) add text separately from spacers to allow for i18n during rendering --- plugins/plugin-annotations/src/banner.mjs | 10 +++++++--- plugins/plugin-annotations/tests/banner.test.mjs | 8 +++++--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/plugins/plugin-annotations/src/banner.mjs b/plugins/plugin-annotations/src/banner.mjs index 48ca655a468..423749d730c 100644 --- a/plugins/plugin-annotations/src/banner.mjs +++ b/plugins/plugin-annotations/src/banner.mjs @@ -12,8 +12,12 @@ export const bannerMacros = { } so.path.attr('data-text-dy', so.dy).attr('data-text-class', `${so.className} center`) const spacer = ' '.repeat(so.spaces) - let banner = spacer - for (let i = 0; i < so.repeat; i++) banner += so.text + ' '.repeat(so.spaces) - so.path.attr('data-text', banner) + + for (let i = 0; i < so.repeat; i++) { + so.path.attr('data-text', spacer) + so.path.attr('data-text', so.text) + } + + so.path.attr('data-text', spacer) }, } diff --git a/plugins/plugin-annotations/tests/banner.test.mjs b/plugins/plugin-annotations/tests/banner.test.mjs index 48a323df44f..3b9dddd8d60 100644 --- a/plugins/plugin-annotations/tests/banner.test.mjs +++ b/plugins/plugin-annotations/tests/banner.test.mjs @@ -27,7 +27,7 @@ describe('Banner Plugin Tests', () => { pattern.draft() const c = pattern.parts[0].test.paths.example expect(c.attributes.get('data-text')).to.equal( - '            foo            foo            foo            foo            foo            foo            foo            foo            foo            foo            ' + '             foo              foo              foo              foo              foo              foo              foo              foo              foo              foo             ' ) expect(c.attributes.get('data-text-class').trim()).to.equal('center') expect(c.attributes.get('data-text-dy')).to.equal('-1') @@ -56,7 +56,7 @@ describe('Banner Plugin Tests', () => { const pattern = new design() pattern.draft() const c = pattern.parts[0].test.paths.example2 - expect(c.attributes.get('data-text')).to.equal('  foo  foo  ') + expect(c.attributes.get('data-text')).to.equal('   foo    foo   ') }) it('Number of repetitions should be configurable', () => { @@ -82,6 +82,8 @@ describe('Banner Plugin Tests', () => { const pattern = new design() pattern.draft() const c = pattern.parts[0].test.paths.example3 - expect(c.attributes.get('data-text')).to.equal(' foo foo foo foo ') + expect(c.attributes.get('data-text')).to.equal( + '  foo   foo   foo   foo  ' + ) }) })