Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure we don't interpret note symbols as section text #685

Merged
merged 2 commits into from
Nov 28, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/importer/AlphaTexImporter.ts
Original file line number Diff line number Diff line change
@@ -1451,6 +1451,10 @@ export class AlphaTexImporter extends ScoreImporter {
}
}

private isNoteText(txt: string) {
return txt === 'x' || txt === '-' || txt === 'r';
}

private note(beat: Beat): boolean {
// fret.string
let isDead: boolean = false;
@@ -1823,7 +1827,7 @@ export class AlphaTexImporter extends ScoreImporter {
let text: string = this._syData as string;
this._sy = this.newSy();
let marker: string = '';
if (this._sy === AlphaTexSymbols.String) {
if (this._sy === AlphaTexSymbols.String && !this.isNoteText((this._syData as string).toLowerCase())) {
marker = text;
text = this._syData as string;
this._sy = this.newSy();
15 changes: 15 additions & 0 deletions test/importer/AlphaTexImporter.test.ts
Original file line number Diff line number Diff line change
@@ -912,4 +912,19 @@ describe('AlphaTexImporterTest', () => {
// success
}
})

function runSectionNoteSymbolTest(noteSymbol:string) {
const score = parseTex(`1.3.4 * 4 | \\section Verse ${noteSymbol}.1 | 2.3.4*4`);

expect(score.masterBars.length).toEqual(3);
expect(score.tracks[0].staves[0].bars[0].voices[0].beats.length).toEqual(4);
expect(score.masterBars[1].section!.text).toEqual('Verse');
expect(score.tracks[0].staves[0].bars[1].voices[0].beats.length).toEqual(1);
}

it('does-not-interpret-note-symbols-on-section', () => {
runSectionNoteSymbolTest('r');
runSectionNoteSymbolTest('-');
runSectionNoteSymbolTest('x');
})
});