Skip to content

Commit

Permalink
Merge 2b14375 into e9c4a4a
Browse files Browse the repository at this point in the history
  • Loading branch information
no-chris committed Jan 25, 2024
2 parents e9c4a4a + 2b14375 commit c0fd1fe
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 31 deletions.
1 change: 0 additions & 1 deletion packages/chord-mark/src/parser/lineTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
*/
export default {
CHORD: 'chord',
CHORD_LINE_REPEATER: 'chordLineRepeater',
EMPTY_LINE: 'emptyLine',
KEY_DECLARATION: 'keyDeclaration',
LYRIC: 'lyric',
Expand Down
9 changes: 8 additions & 1 deletion packages/chord-mark/src/parser/songLinesFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,14 @@ export default function songLinesFactory() {

const currentSectionContent = remainingLines
.slice(0, nextSectionIndex !== -1 ? nextSectionIndex : undefined)
.filter((line) => !(isTimeSignature(line) || isEmptyLine(line))); //todo: add key definition line type as well
.filter(
(line) =>
!(
isTimeSignature(line) ||
isKeyDeclaration(line) ||
isEmptyLine(line)
)
);

return currentSectionContent.length === 0;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,45 @@ verseLine`;
expect(toText(rendered)).toBe(expected);
});

test('should not copy trailing directives lines', () => {
const input = `#v
verse
verse
3/4
key C
#c
chorus
chorus
#v
5/4
key A
#o
outro`;
const expected = `Verse 1
verse
verse
3/4
key: C
Chorus
chorus
chorus
Verse 2
verse
verse
5/4
key: A
Outro
outro`;
const rendered = renderSongText(input, { expandSectionCopy: true });
expect(toText(rendered)).toBe(expected);
});

test('should not repeat chords when autoRepeatChords === false', () => {
const input = `#v
A B
Expand Down Expand Up @@ -1066,35 +1105,6 @@ describe('Keys, accidental & transpose', () => {
'|Am7 |D7 |G |% |\n' +
'myVerse\n',
],
[
'',
'key A\n' +
'#c\n' +
'A\n' +
'_Chorus in A\n' +
'key C\n' +
'#v\n' +
'Am\n' +
'_Verse in C\n' +
'#c\n' +
'_Chorus in C\n' +
'#v\n' +
'_Verse in C',
'key: A\n' +
'Chorus 1\n' +
'|A |\n' +
' Chorus in A\n' +
'key: C\n' +
'Verse 1\n' +
'|Am |\n' +
' Verse in C\n' +
'Chorus 2\n' +
'|C |\n' +
' Chorus in C\n' +
'Verse 2\n' +
'|Am |\n' +
' Verse in C',
],
])('%s', (title, song, expected, options = {}) => {
test('renders with correct accidental', () => {
const rendered = renderSongText(song, {
Expand Down

0 comments on commit c0fd1fe

Please sign in to comment.