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 @@ -