Commit 61c735cd authored by Eric Jiang's avatar Eric Jiang
Browse files

Don't remove consecutive spaces in SRT subtitles

The Kdenlive UI allows you to add multiple spaces between words in
subtitles. This displays correctly in the UI and is preserved when
saving the SRT file, but the spaces are removed when opening the SRT
file.

Changing line.simplified() to line.trimmed() seems to fix the round-trip
issue.

BUG: 457878
parent 3d7c851e
Pipeline #221466 failed with stage
in 2 minutes and 48 seconds
......@@ -180,7 +180,7 @@ void SubtitleModel::importSubtitle(const QString &filePath, int offset, bool ext
QRegExp rx("([0-9]{1,2}):([0-9]{2})");
QLatin1Char separator = filePath.endsWith(".sbv") ? QLatin1Char(',') : QLatin1Char(' ');
while (stream.readLineInto(&line)) {
line = line.simplified();
line = line.trimmed();
// qDebug()<<"Turn: "<<turn;
// qDebug()<<"Line: "<<line<<"\n";
if (!line.isEmpty()) {
......
1
00:00:05,600 --> 00:00:10,600
three spaces
......@@ -127,6 +127,14 @@ TEST_CASE("Read subtitle file", "[Subtitles]")
REQUIRE(subtitleModel->rowCount() == 0);
}
SECTION("Preserve multiple spaces in subtitles")
{
QString subtitleFile = sourcesPath + "/dataset/multiple-spaces.srt";
subtitleModel->importSubtitle(subtitleFile);
const QList<SubtitledTime> allSubs = subtitleModel->getAllSubtitles();
CHECK(allSubs.at(0).subtitle().toStdString() == "three spaces");
}
binModel->clean();
pCore->m_projectManager = nullptr;
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment