diff --git a/aegisub/src/subtitle_format.cpp b/aegisub/src/subtitle_format.cpp index ea74f6c16..2aca78da6 100644 --- a/aegisub/src/subtitle_format.cpp +++ b/aegisub/src/subtitle_format.cpp @@ -417,7 +417,7 @@ void SubtitleFormat::SortLines() { /// @param format /// @param lineEnd /// -void SubtitleFormat::ConvertTags(int format,wxString lineEnd) { +void SubtitleFormat::ConvertTags(int format,const wxString &lineEnd,bool mergeLineBreaks) { using std::list; list::iterator next; for (list::iterator cur=Line->begin();cur!=Line->end();cur++) { @@ -431,7 +431,9 @@ void SubtitleFormat::ConvertTags(int format,wxString lineEnd) { current->Text.Replace(_T("\\h"),_T(" "),true); current->Text.Replace(_T("\\n"),lineEnd,true); current->Text.Replace(_T("\\N"),lineEnd,true); - while (current->Text.Replace(lineEnd+lineEnd,lineEnd,true)) {}; + if (mergeLineBreaks) { + while (current->Text.Replace(lineEnd+lineEnd,lineEnd,true)) {}; + } } } } diff --git a/aegisub/src/subtitle_format.h b/aegisub/src/subtitle_format.h index 7c368a640..f6df35448 100644 --- a/aegisub/src/subtitle_format.h +++ b/aegisub/src/subtitle_format.h @@ -103,7 +103,7 @@ protected: void CreateCopy(); void ClearCopy(); void SortLines(); - void ConvertTags(int format,wxString lineEnd); + void ConvertTags(int format,const wxString &lineEnd,bool mergeLineBreaks=true); //void Merge(bool identical,bool overlaps,bool stripComments,bool stripNonDialogue); void StripComments(); void StripNonDialogue(); diff --git a/aegisub/src/subtitle_format_srt.cpp b/aegisub/src/subtitle_format_srt.cpp index 7bbe08c95..04e308aed 100644 --- a/aegisub/src/subtitle_format_srt.cpp +++ b/aegisub/src/subtitle_format_srt.cpp @@ -184,7 +184,8 @@ found_timestamps: if (text_line.IsEmpty()) { // that's not very interesting... blank subtitle? state = 5; - linebreak_debt = 1; + // no previous line that needs a line break after + linebreak_debt = 0; break; } line->Text.Append(text_line); @@ -197,6 +198,7 @@ found_timestamps: if (text_line.IsEmpty()) { // blank line, next may begin a new subtitle state = 5; + // previous line needs a line break after linebreak_debt = 1; break; } @@ -262,12 +264,12 @@ void SRTSubtitleFormat::WriteFile(wxString _filename,wxString encoding) { StripComments(); // Tags must be converted in two passes // First ASS style overrides are converted to SRT but linebreaks are kept - ConvertTags(2,_T("\\N")); + ConvertTags(2,_T("\\N"),false); // Then we can recombine overlaps, this requires ASS style linebreaks RecombineOverlaps(); MergeIdentical(); // And finally convert linebreaks - ConvertTags(0,_T("\r\n")); + ConvertTags(0,_T("\r\n"),false); // Otherwise unclosed overrides might affect lines they shouldn't, see bug #809 for example // Write lines