Skip to content

Commit

Permalink
Merge pull request #101 from notengrafik/pr/elision-escaping
Browse files Browse the repository at this point in the history
Escaped characters in elision
  • Loading branch information
ahankinson authored May 28, 2019
2 parents e76bee0 + 922728d commit 37fd1da
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 18 deletions.
6 changes: 2 additions & 4 deletions src/ExportProcessors.mss
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
17 changes: 10 additions & 7 deletions test/mocha/test-arpeggios.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});
17 changes: 10 additions & 7 deletions test/mocha/test-lyrics.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 + '")'
);
}
Expand All @@ -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");
});
});

Expand Down
Binary file modified test/sibmeiTestSibs/lyrics.sib
Binary file not shown.

0 comments on commit 37fd1da

Please sign in to comment.