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

Fix lyrics formatting #21

Open
tgambet opened this issue Dec 15, 2018 · 0 comments
Open

Fix lyrics formatting #21

tgambet opened this issue Dec 15, 2018 · 0 comments

Comments

@tgambet
Copy link

tgambet commented Dec 15, 2018

You could improve the following formatting logic :

alltomp3/index.js

Lines 75 to 80 in 7129f17

html = _.trim(html.text());
html = html.replace(/\r\n\n/g, '\n');
html = html.replace(/\t/g, '');
html = html.replace(/\n\r\n/g, '\n');
html = html.replace(/ +/g, ' ');
html = html.replace(/\n /g, '\n');

With :

html = html.text()
    .replace(/\r\n/g, '\n') // windows to linux new line style
    .replace(/\t/g, '') // no tabs
    .replace(/ +/g, ' ') // whitespaces
    .split('\n').map(line => line.trim()).join('\n') // trim every line
    .replace(/\n{3,}/g, '\n\n'); // no more than two new lines in a row

This would fix the formatting issues seen on lyrics.ovh.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant