mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-10-27 22:42:38 +01:00
Add "remove line breaks" to "Batch convert" + "cmd line convert" - thx xmrea :)
This commit is contained in:
parent
2b77d7ed6a
commit
6f5b504209
@ -221,6 +221,7 @@ Note: Do check free disk space.</WaveFileMalformed>
|
||||
<TransportStreamOverrideVideoSize>Override original video size</TransportStreamOverrideVideoSize>
|
||||
<TransportStreamFileNameEnding>File name ending</TransportStreamFileNameEnding>
|
||||
<TransportStreamSettingsButton>TS settings...</TransportStreamSettingsButton>
|
||||
<RemoveLineBreaks>remove line-breaks</RemoveLineBreaks>
|
||||
</BatchConvert>
|
||||
<Beamer>
|
||||
<Title>Beamer</Title>
|
||||
@ -1180,7 +1181,7 @@ Go to "Options -> Settings -> Tools" to enter your Google translate API ke
|
||||
<MergeWithLineBefore>Merge with line before</MergeWithLineBefore>
|
||||
<MergeWithLineAfter>Merge with line after</MergeWithLineAfter>
|
||||
<RemoveFormatting>Remove formatting</RemoveFormatting>
|
||||
<RemoveFormattingAll>Remove all formattings</RemoveFormattingAll>
|
||||
<RemoveFormattingAll>Remove all formatting</RemoveFormattingAll>
|
||||
<RemoveFormattingBold>Remove bold</RemoveFormattingBold>
|
||||
<RemoveFormattingItalic>Remove italic</RemoveFormattingItalic>
|
||||
<RemoveFormattingUnderline>Remove underline</RemoveFormattingUnderline>
|
||||
|
@ -360,7 +360,8 @@ namespace Nikse.SubtitleEdit.Core
|
||||
TransportStreamOverrideYPosition = "Override original Y position",
|
||||
TransportStreamOverrideVideoSize = "Override original video size",
|
||||
TransportStreamFileNameEnding = "File name ending",
|
||||
TransportStreamSettingsButton = "TS settings..."
|
||||
TransportStreamSettingsButton = "TS settings...",
|
||||
RemoveLineBreaks = "remove line-breaks"
|
||||
};
|
||||
|
||||
Beamer = new LanguageStructure.Beamer
|
||||
@ -1693,7 +1694,7 @@ namespace Nikse.SubtitleEdit.Core
|
||||
MergeWithLineBefore = "Merge with line before",
|
||||
MergeWithLineAfter = "Merge with line after",
|
||||
RemoveFormatting = "Remove formatting",
|
||||
RemoveFormattingAll = "Remove all formattings",
|
||||
RemoveFormattingAll = "Remove all formatting",
|
||||
RemoveFormattingItalic = "Remove italic",
|
||||
RemoveFormattingBold = "Remove bold",
|
||||
RemoveFormattingUnderline = "Remove underline",
|
||||
|
@ -604,6 +604,9 @@ namespace Nikse.SubtitleEdit.Core
|
||||
case "BatchConvert/TransportStreamSettingsButton":
|
||||
language.BatchConvert.TransportStreamSettingsButton = reader.Value;
|
||||
break;
|
||||
case "BatchConvert/RemoveLineBreaks":
|
||||
language.BatchConvert.RemoveLineBreaks = reader.Value;
|
||||
break;
|
||||
case "Beamer/Title":
|
||||
language.Beamer.Title = reader.Value;
|
||||
break;
|
||||
|
@ -231,6 +231,7 @@
|
||||
public string TransportStreamOverrideVideoSize { get; set; }
|
||||
public string TransportStreamFileNameEnding { get; set; }
|
||||
public string TransportStreamSettingsButton { get; set; }
|
||||
public string RemoveLineBreaks { get; set; }
|
||||
}
|
||||
|
||||
public class Beamer
|
||||
|
@ -147,6 +147,7 @@ namespace Nikse.SubtitleEdit.Core
|
||||
public bool BatchConvertAutoBalance { get; set; }
|
||||
public bool BatchConvertSetMinDisplayTimeBetweenSubtitles { get; set; }
|
||||
public bool BatchConvertMergeShortLines { get; set; }
|
||||
public bool BatchConvertRemoveLineBreaks { get; set; }
|
||||
public bool BatchConvertMergeSameText { get; set; }
|
||||
public bool BatchConvertMergeSameTimeCodes { get; set; }
|
||||
public bool BatchConvertChangeFrameRate { get; set; }
|
||||
@ -3127,6 +3128,12 @@ $HorzAlign = Center
|
||||
settings.Tools.BatchConvertMergeShortLines = Convert.ToBoolean(subNode.InnerText);
|
||||
}
|
||||
|
||||
subNode = node.SelectSingleNode("BatchConvertRemoveLineBreaks");
|
||||
if (subNode != null)
|
||||
{
|
||||
settings.Tools.BatchConvertRemoveLineBreaks = Convert.ToBoolean(subNode.InnerText);
|
||||
}
|
||||
|
||||
subNode = node.SelectSingleNode("BatchConvertMergeSameText");
|
||||
if (subNode != null)
|
||||
{
|
||||
@ -6465,6 +6472,7 @@ $HorzAlign = Center
|
||||
textWriter.WriteElementString("BatchConvertAutoBalance", settings.Tools.BatchConvertAutoBalance.ToString(CultureInfo.InvariantCulture));
|
||||
textWriter.WriteElementString("BatchConvertSetMinDisplayTimeBetweenSubtitles", settings.Tools.BatchConvertSetMinDisplayTimeBetweenSubtitles.ToString(CultureInfo.InvariantCulture));
|
||||
textWriter.WriteElementString("BatchConvertMergeShortLines", settings.Tools.BatchConvertMergeShortLines.ToString(CultureInfo.InvariantCulture));
|
||||
textWriter.WriteElementString("BatchConvertRemoveLineBreaks", settings.Tools.BatchConvertRemoveLineBreaks.ToString(CultureInfo.InvariantCulture));
|
||||
textWriter.WriteElementString("BatchConvertMergeSameText", settings.Tools.BatchConvertMergeSameText.ToString(CultureInfo.InvariantCulture));
|
||||
textWriter.WriteElementString("BatchConvertMergeSameTimeCodes", settings.Tools.BatchConvertMergeSameTimeCodes.ToString(CultureInfo.InvariantCulture));
|
||||
textWriter.WriteElementString("BatchConvertChangeSpeed", settings.Tools.BatchConvertChangeSpeed.ToString(CultureInfo.InvariantCulture));
|
||||
|
@ -296,7 +296,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
{
|
||||
Text = l.RedoCasing,
|
||||
Checked = Configuration.Settings.Tools.BatchConvertFixCasing,
|
||||
Action = CommandLineConverter.BatchAction.ReDoCasing
|
||||
Action = CommandLineConverter.BatchAction.RedoCasing
|
||||
},
|
||||
new FixActionItem
|
||||
{
|
||||
@ -353,6 +353,12 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
Action = CommandLineConverter.BatchAction.MergeShortLines
|
||||
},
|
||||
new FixActionItem
|
||||
{
|
||||
Text = Configuration.Settings.Language.BatchConvert.RemoveLineBreaks,
|
||||
Checked = Configuration.Settings.Tools.BatchConvertRemoveLineBreaks,
|
||||
Action = CommandLineConverter.BatchAction.RemoveLineBreaks
|
||||
},
|
||||
new FixActionItem
|
||||
{
|
||||
Text = Configuration.Settings.Language.MergeDoubleLines.Title,
|
||||
Checked = Configuration.Settings.Tools.BatchConvertMergeSameText,
|
||||
@ -1073,7 +1079,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
{
|
||||
sub.RemoveEmptyLines(); //TODO: only for image export?
|
||||
}
|
||||
if (IsActionEnabled(CommandLineConverter.BatchAction.ReDoCasing))
|
||||
if (IsActionEnabled(CommandLineConverter.BatchAction.RedoCasing))
|
||||
{
|
||||
_changeCasing.FixCasing(sub, LanguageAutoDetect.AutoDetectGoogleLanguage(sub));
|
||||
_changeCasingNames.Initialize(sub);
|
||||
@ -1090,6 +1096,14 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
}
|
||||
}
|
||||
|
||||
if (IsActionEnabled(CommandLineConverter.BatchAction.RemoveLineBreaks))
|
||||
{
|
||||
foreach (var paragraph in sub.Paragraphs)
|
||||
{
|
||||
paragraph.Text = Utilities.UnbreakLine(paragraph.Text);
|
||||
}
|
||||
}
|
||||
|
||||
if (IsActionEnabled(CommandLineConverter.BatchAction.MergeSameTexts))
|
||||
{
|
||||
var mergedSameTextsSub = MergeLinesSameTextUtils.MergeLinesWithSameTextInSubtitle(sub, true, true, 250);
|
||||
@ -1220,7 +1234,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
private bool AllowImageToImage()
|
||||
{
|
||||
return !IsActionEnabled(CommandLineConverter.BatchAction.BalanceLines) &&
|
||||
!IsActionEnabled(CommandLineConverter.BatchAction.ReDoCasing) &&
|
||||
!IsActionEnabled(CommandLineConverter.BatchAction.RedoCasing) &&
|
||||
!IsActionEnabled(CommandLineConverter.BatchAction.FixCommonErrors) &&
|
||||
!IsActionEnabled(CommandLineConverter.BatchAction.FixRtl) &&
|
||||
!IsActionEnabled(CommandLineConverter.BatchAction.MultipleReplace) &&
|
||||
@ -1844,7 +1858,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
_abort = true;
|
||||
}
|
||||
|
||||
Configuration.Settings.Tools.BatchConvertFixCasing = IsActionEnabled(CommandLineConverter.BatchAction.ReDoCasing);
|
||||
Configuration.Settings.Tools.BatchConvertFixCasing = IsActionEnabled(CommandLineConverter.BatchAction.RedoCasing);
|
||||
Configuration.Settings.Tools.BatchConvertFixCommonErrors = IsActionEnabled(CommandLineConverter.BatchAction.FixCommonErrors);
|
||||
Configuration.Settings.Tools.BatchConvertMultipleReplace = IsActionEnabled(CommandLineConverter.BatchAction.MultipleReplace);
|
||||
Configuration.Settings.Tools.BatchConvertFixRtl = IsActionEnabled(CommandLineConverter.BatchAction.FixRtl);
|
||||
@ -1863,6 +1877,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
Configuration.Settings.Tools.BatchConvertExportCustomTextTemplate = _customTextTemplate;
|
||||
Configuration.Settings.Tools.BatchConvertSaveInSourceFolder = radioButtonSaveInSourceFolder.Checked;
|
||||
Configuration.Settings.Tools.BatchConvertMergeShortLines = IsActionEnabled(CommandLineConverter.BatchAction.MergeShortLines);
|
||||
Configuration.Settings.Tools.BatchConvertRemoveLineBreaks = IsActionEnabled(CommandLineConverter.BatchAction.RemoveLineBreaks);
|
||||
Configuration.Settings.Tools.BatchConvertMergeSameText = IsActionEnabled(CommandLineConverter.BatchAction.MergeSameTexts);
|
||||
Configuration.Settings.Tools.BatchConvertMergeSameTimeCodes = IsActionEnabled(CommandLineConverter.BatchAction.MergeSameTimeCodes);
|
||||
Configuration.Settings.Tools.BatchConvertChangeSpeed = IsActionEnabled(CommandLineConverter.BatchAction.ChangeSpeed);
|
||||
@ -2207,7 +2222,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
break;
|
||||
case CommandLineConverter.BatchAction.RemoveFormatting:
|
||||
break;
|
||||
case CommandLineConverter.BatchAction.ReDoCasing:
|
||||
case CommandLineConverter.BatchAction.RedoCasing:
|
||||
break;
|
||||
case CommandLineConverter.BatchAction.ReverseRtlStartEnd:
|
||||
break;
|
||||
|
@ -35,7 +35,7 @@ namespace Nikse.SubtitleEdit.Logic.CommandLineConvert
|
||||
MergeSameTimeCodes,
|
||||
RemoveTextForHI,
|
||||
RemoveFormatting,
|
||||
ReDoCasing,
|
||||
RedoCasing,
|
||||
ReverseRtlStartEnd,
|
||||
BridgeGaps,
|
||||
MultipleReplace,
|
||||
@ -46,7 +46,8 @@ namespace Nikse.SubtitleEdit.Logic.CommandLineConvert
|
||||
ChangeFrameRate,
|
||||
OffsetTimeCodes,
|
||||
ChangeSpeed,
|
||||
ApplyDurationLimits
|
||||
ApplyDurationLimits,
|
||||
RemoveLineBreaks
|
||||
}
|
||||
|
||||
internal static void ConvertOrReturn(string productIdentifier, string[] commandLineArguments)
|
||||
@ -133,15 +134,16 @@ namespace Nikse.SubtitleEdit.Logic.CommandLineConvert
|
||||
_stdOutWriter.WriteLine(" /multiplereplace (equivalent to /multiplereplace:.)");
|
||||
_stdOutWriter.WriteLine(" The following operations are applied in command line order");
|
||||
_stdOutWriter.WriteLine(" from left to right, and can be specified multiple times.");
|
||||
_stdOutWriter.WriteLine(" /ApplyDurationLimits");
|
||||
_stdOutWriter.WriteLine(" /FixCommonErrors");
|
||||
_stdOutWriter.WriteLine(" /MergeSameTimeCodes");
|
||||
_stdOutWriter.WriteLine(" /MergeSameTexts");
|
||||
_stdOutWriter.WriteLine(" /MergeShortLines");
|
||||
_stdOutWriter.WriteLine(" /ReverseRtlStartEnd");
|
||||
_stdOutWriter.WriteLine(" /RemoveFormatting");
|
||||
_stdOutWriter.WriteLine(" /RemoveTextForHI");
|
||||
_stdOutWriter.WriteLine(" /RedoCasing");
|
||||
_stdOutWriter.WriteLine(" /" + BatchAction.ApplyDurationLimits);
|
||||
_stdOutWriter.WriteLine(" /" + BatchAction.FixCommonErrors);
|
||||
_stdOutWriter.WriteLine(" /" + BatchAction.RemoveLineBreaks);
|
||||
_stdOutWriter.WriteLine(" /" + BatchAction.MergeSameTimeCodes);
|
||||
_stdOutWriter.WriteLine(" /" + BatchAction.MergeSameTexts);
|
||||
_stdOutWriter.WriteLine(" /" + BatchAction.MergeShortLines);
|
||||
_stdOutWriter.WriteLine(" /" + BatchAction.ReverseRtlStartEnd);
|
||||
_stdOutWriter.WriteLine(" /" + BatchAction.RemoveFormatting);
|
||||
_stdOutWriter.WriteLine(" /" + BatchAction.RemoveTextForHI);
|
||||
_stdOutWriter.WriteLine(" /" + BatchAction.RedoCasing);
|
||||
_stdOutWriter.WriteLine();
|
||||
_stdOutWriter.WriteLine(" example: SubtitleEdit /convert *.srt sami");
|
||||
_stdOutWriter.WriteLine(" show this usage message: SubtitleEdit /help");
|
||||
@ -1098,7 +1100,7 @@ namespace Nikse.SubtitleEdit.Logic.CommandLineConvert
|
||||
p.Text = HtmlUtil.RemoveHtmlTags(p.Text, true).Trim();
|
||||
}
|
||||
break;
|
||||
case BatchAction.ReDoCasing:
|
||||
case BatchAction.RedoCasing:
|
||||
using (var changeCasing = new ChangeCasing())
|
||||
{
|
||||
changeCasing.FixCasing(sub, LanguageAutoDetect.AutoDetectGoogleLanguage(sub));
|
||||
@ -1143,6 +1145,12 @@ namespace Nikse.SubtitleEdit.Logic.CommandLineConvert
|
||||
sub.Paragraphs.AddRange(mergedShortLinesSub.Paragraphs);
|
||||
}
|
||||
break;
|
||||
case BatchAction.RemoveLineBreaks:
|
||||
foreach (var p in sub.Paragraphs)
|
||||
{
|
||||
p.Text = Utilities.RemoveLineBreaks(p.Text);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user