Skip to content

Commit

Permalink
Prevent double-escaping of XML entities in elision lyrics
Browse files Browse the repository at this point in the history
  • Loading branch information
th-we committed Mar 25, 2019
1 parent 1009f45 commit 922728d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 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
12 changes: 8 additions & 4 deletions test/mocha/test-lyrics.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,19 @@ 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(elisionSyls.length, 2)
assert.strictEqual(note1Syls.length, 2)
);
it("sets @con='b' on first syl, but not any others", () => {
assert.strictEqual(elisionSyls[0].getAttribute('con'), 'b');
const sylsWithCon = xpath.evaluateXPathToNodes('//*:syl[@con="b"]', mei);
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");
});
});

describe("wordpos", () => {
Expand Down
Binary file modified test/sibmeiTestSibs/lyrics.sib
Binary file not shown.

0 comments on commit 922728d

Please sign in to comment.