diff --git a/src/ExportProcessors.mss b/src/ExportProcessors.mss index f4d70d0..04339ef 100644 --- a/src/ExportProcessors.mss +++ b/src/ExportProcessors.mss @@ -292,12 +292,10 @@ function ProcessLyric (lyricobj, objectPositions) { } } - syltext = libmei.GetText(sylel); - - if (utils.Pos('_', syltext) > -1) + if (utils.Pos('_', syl.Text) > -1) { // Syllable elision. split this syllable element by underscore. - syllables = MSplitString(syltext, '_'); + syllables = MSplitString(syl.Text, '_'); sylarray = CreateSparseArray(); // reset the text of the first syllable element to the first half of the syllable. diff --git a/test/mocha/test-arpeggios.js b/test/mocha/test-arpeggios.js index c7dc3dd..dc49177 100644 --- a/test/mocha/test-arpeggios.js +++ b/test/mocha/test-arpeggios.js @@ -8,21 +8,24 @@ describe("Arpeggios", () => { const mei = utils.getTestMeiDom('arpeggios.mei'); it("writes 3 arpeggios in each of the 3 measures", () => { - assert.strictEqual(9, xpath.evaluateXPath('//*:arpeg', mei).length); + assert.strictEqual(xpath.evaluateXPath('//*:arpeg', mei).length, 9); }); it("writes arpeggios with up arrow on beat 2 of each measure", () => { - assert.strictEqual(3, xpath.evaluateXPath( + const upArpeggiosOnBeat2 = xpath.evaluateXPath( '//*:arpeg[@arrow="true"][@tstamp="2"][@order="up"]', mei - ).length); + ); + assert.strictEqual(upArpeggiosOnBeat2.length, 3); }); it("writes arpeggios with down arrow on beat 3 of each measure", () => { - assert.strictEqual(3, xpath.evaluateXPath( + const downArpeggiosOnBeat3 = xpath.evaluateXPath( '//*:arpeg[@arrow="true"][@tstamp="3"][@order="down"]', mei - ).length); + ); + assert.strictEqual(downArpeggiosOnBeat3.length, 3); }); it("writes arrowless arpeggios on beat 4 of each measures", () => { - assert.strictEqual(3, xpath.evaluateXPath( + const arrowlessArpeggionsOnBeat4 = xpath.evaluateXPath( '//*:arpeg[@arrow="false"][@tstamp="4"][not(@order)]', mei - ).length); + ) + assert.strictEqual(arrowlessArpeggionsOnBeat4.length, 3); }); }); diff --git a/test/mocha/test-lyrics.js b/test/mocha/test-lyrics.js index 02cec6f..c4040eb 100644 --- a/test/mocha/test-lyrics.js +++ b/test/mocha/test-lyrics.js @@ -7,7 +7,7 @@ const utils = require('./utils'); function assertAttrOnElements(elements, indices, attName, attValue) { for (const i of indices) { assert.strictEqual( - attValue, elements[i].getAttribute(attName), + elements[i].getAttribute(attName), attValue, 'failed on element index ' + i + ' ("' + elements[i].innerHTML + '")' ); } @@ -18,15 +18,18 @@ describe("Lyrics", () => { const syls = xpath.evaluateXPath('//*:syl', mei); describe("writes an elision", () => { - const elisionSyls = xpath.evaluateXPathToNodes('(//*:note)[1]//*:syl', mei); + const note1 = xpath.evaluateXPathToNodes('(//*:note)[1]', mei)[0]; + const note1Syls = xpath.evaluateXPathToNodes('.//*:syl', note1); it("exports 2 syllables for elisions", () => - assert.strictEqual(2, elisionSyls.length) + assert.strictEqual(note1Syls.length, 2) ); it("sets @con='b' on first syl, but not any others", () => { - assert.strictEqual('b', elisionSyls[0].getAttribute('con')); - assert.strictEqual(1, xpath.evaluateXPathToNodes( - '//*:syl[@con="b"]', mei - ).length); + assert.strictEqual(note1Syls[0].getAttribute('con'), 'b'); + const sylsWithCon = xpath.evaluateXPathToNodes('.//*:syl[@con="b"]', note1); + assert.strictEqual(sylsWithCon.length, 1); + }); + it("creates correct character entities on elisions", function() { + assert.strictEqual(syls[13].firstChild._data, "n'u"); }); }); diff --git a/test/sibmeiTestSibs/lyrics.sib b/test/sibmeiTestSibs/lyrics.sib index d810989..4229cad 100644 Binary files a/test/sibmeiTestSibs/lyrics.sib and b/test/sibmeiTestSibs/lyrics.sib differ