commit
d51a1add86
|
@ -79,9 +79,12 @@ void SongInfoTextView::contextMenuEvent(QContextMenuEvent* e) {
|
||||||
void SongInfoTextView::SetHtml(const QString& html) {
|
void SongInfoTextView::SetHtml(const QString& html) {
|
||||||
QString copy(html.trimmed());
|
QString copy(html.trimmed());
|
||||||
|
|
||||||
// Simplify newlines, and convert them to <p>
|
// Simplify newlines
|
||||||
copy.replace(QRegExp("[\\r\\n]+"), "\n");
|
copy.replace(QRegExp("\\r\\n?"), "\n");
|
||||||
copy.replace(QRegExp("([^>])[\\t ]*\\n"), "\\1<p>");
|
|
||||||
|
// Convert two or more newlines to <p>, convert single newlines to <br>
|
||||||
|
copy.replace(QRegExp("([^>])([\\t ]*\\n){2,}"), "\\1<p>");
|
||||||
|
copy.replace(QRegExp("([^>])[\\t ]*\\n"), "\\1<br>");
|
||||||
|
|
||||||
// Strip any newlines from the end
|
// Strip any newlines from the end
|
||||||
copy.replace(QRegExp("((<\\s*br\\s*/?\\s*>)|(<\\s*/?\\s*p\\s*/?\\s*>))+$"),
|
copy.replace(QRegExp("((<\\s*br\\s*/?\\s*>)|(<\\s*/?\\s*p\\s*/?\\s*>))+$"),
|
||||||
|
|
|
@ -25,9 +25,12 @@ UltimateLyricsLyric::UltimateLyricsLyric(QObject* parent)
|
||||||
void UltimateLyricsLyric::SetHtml(const QString& html) {
|
void UltimateLyricsLyric::SetHtml(const QString& html) {
|
||||||
QString copy(html.trimmed());
|
QString copy(html.trimmed());
|
||||||
|
|
||||||
// Simplify newlines, and convert them to <p>
|
// Simplify newlines
|
||||||
copy.replace(QRegExp("[\\r\\n]+"), "\n");
|
copy.replace(QRegExp("\\r\\n?"), "\n");
|
||||||
copy.replace(QRegExp("([^>])[\\t ]*\\n"), "\\1<p>");
|
|
||||||
|
// Convert two or more newlines to <p>, convert single newlines to <br>
|
||||||
|
copy.replace(QRegExp("([^>])([\\t ]*\\n){2,}"), "\\1<p>");
|
||||||
|
copy.replace(QRegExp("([^>])[\\t ]*\\n"), "\\1<br>");
|
||||||
|
|
||||||
// Strip any newlines from the end
|
// Strip any newlines from the end
|
||||||
copy.replace(QRegExp("((<\\s*br\\s*/?\\s*>)|(<\\s*/?\\s*p\\s*/?\\s*>))+$"),
|
copy.replace(QRegExp("((<\\s*br\\s*/?\\s*>)|(<\\s*/?\\s*p\\s*/?\\s*>))+$"),
|
||||||
|
|
|
@ -223,7 +223,7 @@ QString UltimateLyricsProvider::Extract(const QString& source,
|
||||||
int end_idx = source.indexOf(end, begin_idx);
|
int end_idx = source.indexOf(end, begin_idx);
|
||||||
if (end_idx == -1) return QString();
|
if (end_idx == -1) return QString();
|
||||||
|
|
||||||
return source.mid(begin_idx, end_idx - begin_idx - 1);
|
return source.mid(begin_idx, end_idx - begin_idx);
|
||||||
}
|
}
|
||||||
|
|
||||||
void UltimateLyricsProvider::ApplyExcludeRule(const Rule& rule,
|
void UltimateLyricsProvider::ApplyExcludeRule(const Rule& rule,
|
||||||
|
|
Loading…
Reference in New Issue