speirling / songbook

CakePHP+jQuery system for managing song lyrics and chords.
2 stars 0 forks source link

The bass note of chords isn't always being styled #77

Closed speirling closed 6 years ago

speirling commented 7 years ago

See https://fps.epeelo.com:9134/songbook/songs/view/735 Only the last chord+bassnote in each line is properly styled. Maybe a regex error?

speirling commented 6 years ago

The fault is in the html structure, so presumably regex problem

speirling commented 6 years ago

src/Controller/SongsController.php view method $song['content'] = StaticFunctionController::convert_song_content_to_HTML($song['content'], $song['base_key'], $key, $capo);

src/Controller/StaticFunctionController.php convert_song_content_to_HTML method


        //anything in square brackets is taken to be a chord and should be processed to create chord html
        $contentHTML = preg_replace_callback('/\[(.*?)\]/', 'self::chord_replace_callback', $contentHTML);
        //if there's a bass modifier, give it its own html
        $contentHTML = preg_replace('#<span class="chord">([^<]*?)/([^<]*?)</span>#','<span class="chord">$1<span class="bass_note_modifier separator">/</span><span class="bass_note_modifier note">$2</span></span>', $contentHTML);

Maybe the bass modifier should be part of the chord html subroutine?

speirling commented 6 years ago

fixed in commit c034fdd0b2b7893199c365472a7f20e585039fc2