Skip to content

Fix lyrics formatting #21

Description

@tgambet

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions