A few very minor fixes (command line conversion + fix common errors)

git-svn-id: https://subtitleedit.googlecode.com/svn/trunk@931 99eadd0c-20b8-1223-b5c4-2a2b2df33de2
This commit is contained in:
niksedk 2012-01-14 17:53:57 +00:00
parent ba6c1f7c6d
commit e891e6b350
2 changed files with 28 additions and 17 deletions

View File

@ -1843,16 +1843,11 @@ namespace Nikse.SubtitleEdit.Forms
if (prev != null)
prevText = Utilities.RemoveHtmlTags(prev.Text);
bool isPrevEndOfLine = IsPrevoiusTextEndOfParagraph(prevText);
if (!text.StartsWith("www.") &&
firstLetter != firstLetter.ToUpper() &&
!"0123456789".Contains(firstLetter) &&
prevText.Length > 1 &&
!prevText.EndsWith("...") &&
(prevText.EndsWith(".") ||
prevText.EndsWith("!") ||
prevText.EndsWith("?") ||
prevText.EndsWith(":") ||
prevText.EndsWith(";")))
isPrevEndOfLine)
{
bool isMatchInKnowAbbreviations = _autoDetectGoogleLanguage == "en" &&
(prevText.EndsWith(" o.r.") ||
@ -1900,17 +1895,11 @@ namespace Nikse.SubtitleEdit.Forms
string oldText = p.Text;
string firstLetter = text.Substring(0, 1);
string prevText = Utilities.RemoveHtmlTags(arr[0]);
bool isPrevEndOfLine = IsPrevoiusTextEndOfParagraph(prevText);
if (!text.StartsWith("www.") &&
firstLetter != firstLetter.ToUpper() &&
!prevText.EndsWith("...") &&
prevText.Length > 1 &&
!"0123456789".Contains(firstLetter) &&
(prevText.EndsWith(".") ||
prevText.EndsWith("!") ||
prevText.EndsWith("?") ||
prevText.EndsWith(":") ||
prevText.EndsWith(";")))
isPrevEndOfLine)
{
bool isMatchInKnowAbbreviations = _autoDetectGoogleLanguage == "en" &&
(prevText.EndsWith(" o.r.") ||
@ -1964,6 +1953,23 @@ namespace Nikse.SubtitleEdit.Forms
LogStatus(_language.StartWithUppercaseLetterAfterParagraph, fixedStartWithUppercaseLetterAfterParagraphTicked.ToString());
}
private static bool IsPrevoiusTextEndOfParagraph(string prevText)
{
bool isPrevEndOfLine = prevText.Length > 1 &&
!prevText.EndsWith("...") &&
(prevText.EndsWith(".") ||
prevText.EndsWith("!") ||
prevText.EndsWith("?") ||
prevText.EndsWith(":") ||
prevText.EndsWith(";"));
if (isPrevEndOfLine && prevText.Length > 5 && prevText.EndsWith(".") &&
prevText[prevText.Length - 3] == '.' &&
Utilities.GetLetters(true, true, false).Contains(prevText[prevText.Length - 2].ToString()))
isPrevEndOfLine = false;
return isPrevEndOfLine;
}
private void FixStartWithUppercaseLetterAfterPeriodInsideParagraph()
{
string fixAction = _language.StartWithUppercaseLetterAfterPeriodInsideParagraph;

View File

@ -521,12 +521,17 @@ namespace Nikse.SubtitleEdit.Forms
Subtitle newSub = new Subtitle();
foreach (Paragraph p in sub.Paragraphs)
{
if (p.Extra == className)
if (p.Extra.ToLower().Trim() == className.ToLower().Trim())
newSub.Paragraphs.Add(p);
}
if (newSub.Paragraphs.Count > 0 && newSub.Paragraphs.Count < sub.Paragraphs.Count)
{
outputFileName = FormatOutputFileNameForBatchConvert(fileName + "_" + className, sf.Extension);
string s = fileName;
if (s.LastIndexOf('.') > 0)
s = s.Insert(s.LastIndexOf('.'), "_" + className);
else
s += "_" + className + format.Extension;
outputFileName = FormatOutputFileNameForBatchConvert(s , sf.Extension);
System.IO.File.WriteAllText(outputFileName, newSub.ToText(sf), targetEncoding);
}
}