diff --git a/lib/chord_pro.rb b/lib/chord_pro.rb index 14f6935..b5be80c 100644 --- a/lib/chord_pro.rb +++ b/lib/chord_pro.rb @@ -16,7 +16,7 @@ module ChordPro MEASURES_REGEX = %r{([\[[\w#b\/]+\]\s]+)[|]*}i CHORDS_REGEX = %r{\[([\w#b\/]+)\]?}i COMMENT_REGEX = /\{(?:c|comment|comment_italic|ci|comment_box|cb):([^$]*)\}/ - SANITIZE_REGEX = /\{end_of_chorus|eoc|end_of_verse|eov|end_of_tab|eot|end_of_tab|eog|end_of_grid|colb\}/ + SANITIZE_REGEX = /\{end_of_chorus|eoc|end_of_verse|eov|eob|end_of_bridge|end_of_tab|eot|end_of_tab|eog|end_of_grid|colb\}/ class << self def parse(lines) @@ -133,6 +133,7 @@ def section_name_by_directive(text) return "Chorus" if /soc|start_of_chorus|chorus/.match?(text) return "Verse" if /sov|start_of_verse/.match?(text) return "Tab" if /sot|start_of_tab/.match?(text) + return "Bridge" if /sob|start_of_bridge/.match?(text) "Grid" if /sot|start_of_grid/.match?(text) end end diff --git a/spec/song_pro_spec.rb b/spec/chord_pro_spec.rb similarity index 95% rename from spec/song_pro_spec.rb rename to spec/chord_pro_spec.rb index 372e320..4e129f4 100644 --- a/spec/song_pro_spec.rb +++ b/spec/chord_pro_spec.rb @@ -52,16 +52,22 @@ {start_of_verse} {start_of_chorus: Chorus 1} {start_of_chorus} +{start_of_bridge} +{start_of_bridge: Bridge 2} +{sob} {chorus} {chorus:Final} ') - expect(song.sections.size).to eq 6 + expect(song.sections.size).to eq 9 expect(song.sections[0].name).to eq "Verse 1" expect(song.sections[1].name).to eq "Verse" expect(song.sections[2].name).to eq "Chorus 1" expect(song.sections[3].name).to eq "Chorus" - expect(song.sections[4].name).to eq "Chorus" - expect(song.sections[5].name).to eq "Final" + expect(song.sections[4].name).to eq "Bridge" + expect(song.sections[5].name).to eq "Bridge 2" + expect(song.sections[6].name).to eq "Bridge" + expect(song.sections[7].name).to eq "Chorus" + expect(song.sections[8].name).to eq "Final" end end @@ -208,7 +214,7 @@ expect(song.title).to eq "Bad Moon Rising" expect(song.artist).to eq "Creedence Clearwater Revival" expect(song.capo).to eq "1" - expect(song.sections.size).to eq 9 + expect(song.sections.size).to eq 10 expect(song.custom[:difficulty]).to eq "Easy" expect(song.custom[:spotify_url]) .to eq "https://open.spotify.com/track/20OFwXhEXf12DzwXmaV7fj?si=cE76lY5TT26fyoNmXEjNpA" diff --git a/spec/fixtures/bad-moon-rising.html b/spec/fixtures/bad-moon-rising.html index 8e2bd9b..e1d8171 100644 --- a/spec/fixtures/bad-moon-rising.html +++ b/spec/fixtures/bad-moon-rising.html @@ -1 +1 @@ -

Bad Moon Rising

Creedence Clearwater Revival

Capo
1
Intro
D
A
G
D
D
Verse 1
D
I see a
A
bad
G
moon a-
D
rising
D
I see
A
trouble
G
on the
D
way
D
I see
A
earth-
G
quakes and
D
lightnin'
D
I see
A
bad
G
times to-
D
day
Riff
|-3---5-|
|---4---|
Chorus
G
Don't go 'round tonight
It's
D
bound to take your life
A7
There's a
G
bad moon on the
D
rise
Verse 2
D
I hear
A
hurri-
G
canes a-
D
blowing
D
I know the
A
end is
G
coming
D
soon
D
I fear
A
rivers
G
over
D
flowing
D
I hear the
A
voice of
G
rage and
D
ruin
Chorus
Solo
D
A
G
D
D
D
A
G
D
D
G
G
D
D
A7
G
D
D
Verse 3
D
I hope you
A
got your
G
things to-
D
gether
D
Hope you are
A
quite pre-
G
pared to
D
die
D
Look's like we're
A
in for
G
nasty
D
weather
D
One eye is
A
taken
G
for an
D
eye
Chorus
Oh
G
don't go 'round tonight
It's
D
bound to take your life
A7
There's a
G
bad moon on the
D
rise
A7
There's a
G
bad moon on the
D
rise
+

Bad Moon Rising

Creedence Clearwater Revival

Capo
1
Intro
D
A
G
D
D
Verse 1
D
I see a
A
bad
G
moon a-
D
rising
D
I see
A
trouble
G
on the
D
way
D
I see
A
earth-
G
quakes and
D
lightnin'
D
I see
A
bad
G
times to-
D
day
Riff
|-3---5-|
|---4---|
Chorus
G
Don't go 'round tonight
It's
D
bound to take your life
A7
There's a
G
bad moon on the
D
rise
Verse 2
D
I hear
A
hurri-
G
canes a-
D
blowing
D
I know the
A
end is
G
coming
D
soon
D
I fear
A
rivers
G
over
D
flowing
D
I hear the
A
voice of
G
rage and
D
ruin
Chorus
Bridge
D
A
G
D
D
D
A
G
D
D
G
G
D
D
A7
G
D
D
Solo
D
A
G
D
D
D
A
G
D
D
G
G
D
D
A7
G
D
D
Verse 3
D
I hope you
A
got your
G
things to-
D
gether
D
Hope you are
A
quite pre-
G
pared to
D
die
D
Look's like we're
A
in for
G
nasty
D
weather
D
One eye is
A
taken
G
for an
D
eye
Chorus
Oh
G
don't go 'round tonight
It's
D
bound to take your life
A7
There's a
G
bad moon on the
D
rise
A7
There's a
G
bad moon on the
D
rise
diff --git a/spec/fixtures/bad-moon-rising.pro b/spec/fixtures/bad-moon-rising.pro index a0f5714..a2644b7 100644 --- a/spec/fixtures/bad-moon-rising.pro +++ b/spec/fixtures/bad-moon-rising.pro @@ -35,6 +35,13 @@ It's [D]bound to take your life {chorus} +{start_of_bridge} +| [D] | [A] [G] | [D] | [D] | +| [D] | [A] [G] | [D] | [D] | +| [G] | [G] | [D] | [D] | +| [A7] | [G] | [D] | [D] | +{end_of_bridge} + {start_of_grid: Solo} | [D] | [A] [G] | [D] | [D] | | [D] | [A] [G] | [D] | [D] |