mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-11-22 11:12:36 +01:00
Fix for white-space/italic in DCinema SMPTE formats - thx Knut :)
This commit is contained in:
parent
4ddee2fb71
commit
5c8a7bd668
@ -9,6 +9,8 @@
|
|||||||
* Add new shortcut for split + auto-br - thx oep42
|
* Add new shortcut for split + auto-br - thx oep42
|
||||||
* Add "Sort by" in "Batch convert" - thx Masina86
|
* Add "Sort by" in "Batch convert" - thx Masina86
|
||||||
* Add image format RhozetHarmonic (only read) - thx Arianna
|
* Add image format RhozetHarmonic (only read) - thx Arianna
|
||||||
|
* Add "Toggle custom surround text with" shortcut - thx HadiSparrow
|
||||||
|
* Add "Go to next/previous time code from video position" shortcuts - thx faon-92
|
||||||
* IMPROVED:
|
* IMPROVED:
|
||||||
* Update French translation - thx Pierre
|
* Update French translation - thx Pierre
|
||||||
* Update Hungarian translation - thx Zityi
|
* Update Hungarian translation - thx Zityi
|
||||||
@ -43,6 +45,9 @@
|
|||||||
* Fix minor left/right cropping issue in image export - thx nissansz
|
* Fix minor left/right cropping issue in image export - thx nissansz
|
||||||
* Fix possible crash after choosing folder in image export
|
* Fix possible crash after choosing folder in image export
|
||||||
* Fix italic/font issue with DFXP - thx IngunnHelge
|
* Fix italic/font issue with DFXP - thx IngunnHelge
|
||||||
|
* Fix for image export baseline - thx Matt
|
||||||
|
* Fix cash in "Generate blank video"
|
||||||
|
* Fix too many {\an1} in SCC
|
||||||
|
|
||||||
|
|
||||||
3.6.11 (30th January 2023)
|
3.6.11 (30th January 2023)
|
||||||
|
@ -858,6 +858,16 @@ Dialogue: Marked=0,0:00:01.00,0:00:03.00,Default,NTP,0000,0000,0000,!Effect," +
|
|||||||
Assert.IsTrue(text.Contains("<Font Italic=\"yes\" Color=\"FFFF0000\">Red</Font>"));
|
Assert.IsTrue(text.Contains("<Font Italic=\"yes\" Color=\"FFFF0000\">Red</Font>"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void DcinemaSmpteColorAndItalicNoSpaceBeforeAndAfterFont()
|
||||||
|
{
|
||||||
|
var target = new DCinemaSmpte2010();
|
||||||
|
var subtitle = new Subtitle();
|
||||||
|
subtitle.Paragraphs.Add(new Paragraph("<font color=\"#ff0000\"><i>Red</i></font>", 1000, 5000));
|
||||||
|
var text = target.ToText(subtitle, "title");
|
||||||
|
Assert.IsTrue(text.Contains("><Font Italic=\"yes\" Color=\"FFFF0000\">Red</Font><"));
|
||||||
|
}
|
||||||
|
|
||||||
#endregion DCinema smpte (.xml)
|
#endregion DCinema smpte (.xml)
|
||||||
|
|
||||||
#region DCinema interop (.xml)
|
#region DCinema interop (.xml)
|
||||||
|
@ -563,6 +563,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
|||||||
Errors = "Error validating xml via SMPTE-428-7-2007-DCST.xsd: " + exception.Message;
|
Errors = "Error validating xml via SMPTE-428-7-2007-DCST.xsd: " + exception.Message;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return DCinemaSmpte2010.FixDcsTextSameLine(result);
|
return DCinemaSmpte2010.FixDcsTextSameLine(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -575,11 +575,11 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
internal static string FixDcsTextSameLine(string xml)
|
internal static string FixDcsTextSameLine(string xml)
|
||||||
{
|
{
|
||||||
var index = xml.IndexOf("<dcst:Text", StringComparison.Ordinal);
|
var index = xml.IndexOf("<Text", StringComparison.Ordinal);
|
||||||
var endIndex = 1;
|
var endIndex = 1;
|
||||||
while (index > 0 && endIndex > 0)
|
while (index > 0 && endIndex > 0)
|
||||||
{
|
{
|
||||||
endIndex = xml.IndexOf("</dcst:Text>", index, StringComparison.Ordinal);
|
endIndex = xml.IndexOf("</Text>", index, StringComparison.Ordinal);
|
||||||
if (endIndex > 0)
|
if (endIndex > 0)
|
||||||
{
|
{
|
||||||
var part = xml.Substring(index, endIndex - index);
|
var part = xml.Substring(index, endIndex - index);
|
||||||
@ -593,10 +593,24 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
|||||||
part = part.Replace("> <", "><");
|
part = part.Replace("> <", "><");
|
||||||
}
|
}
|
||||||
xml = xml.Remove(index, endIndex - index).Insert(index, part);
|
xml = xml.Remove(index, endIndex - index).Insert(index, part);
|
||||||
index = xml.IndexOf("<dcst:Text", endIndex, StringComparison.Ordinal);
|
index = xml.IndexOf("<Text", endIndex, StringComparison.Ordinal);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
xml = xml
|
||||||
|
.Replace("\n<Font>", "<Font>")
|
||||||
|
.Replace("\r<Font>", "<Font>")
|
||||||
|
.Replace("\n<Font>", "<Font>")
|
||||||
|
.Replace("\r<Font>", "<Font>")
|
||||||
|
|
||||||
|
.Replace("</Font>\r", "</Font>")
|
||||||
|
.Replace("</Font>\n", "</Font>")
|
||||||
|
.Replace("</Font>\r", "</Font>")
|
||||||
|
.Replace("</Font>\n", "</Font>")
|
||||||
|
|
||||||
|
.Replace("</Font> </Text>", "</Font></Text>")
|
||||||
|
;
|
||||||
|
|
||||||
return xml;
|
return xml;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -568,36 +568,8 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
|||||||
Errors = "Error validating xml via SMPTE-428-7-2014-DCST.xsd: " + exception.Message;
|
Errors = "Error validating xml via SMPTE-428-7-2014-DCST.xsd: " + exception.Message;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return FixDcsTextSameLine(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
return DCinemaSmpte2010.FixDcsTextSameLine(result);
|
||||||
/// All space characters present inside the content of a Text element shall be rendered
|
|
||||||
/// </summary>
|
|
||||||
internal static string FixDcsTextSameLine(string xml)
|
|
||||||
{
|
|
||||||
var index = xml.IndexOf("<dcst:Text", StringComparison.Ordinal);
|
|
||||||
var endIndex = 1;
|
|
||||||
while (index > 0 && endIndex > 0)
|
|
||||||
{
|
|
||||||
endIndex = xml.IndexOf("</dcst:Text>", index, StringComparison.Ordinal);
|
|
||||||
if (endIndex > 0)
|
|
||||||
{
|
|
||||||
var part = xml.Substring(index, endIndex - index);
|
|
||||||
if (part.Contains(Environment.NewLine))
|
|
||||||
{
|
|
||||||
part = part.Replace(Environment.NewLine, " ");
|
|
||||||
while (part.Contains(" "))
|
|
||||||
{
|
|
||||||
part = part.Replace(" ", " ");
|
|
||||||
}
|
|
||||||
part = part.Replace("> <", "><");
|
|
||||||
}
|
|
||||||
xml = xml.Remove(index, endIndex - index).Insert(index, part);
|
|
||||||
index = xml.IndexOf("<dcst:Text", endIndex, StringComparison.Ordinal);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return xml;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ValidationCallBack(object sender, ValidationEventArgs e)
|
private void ValidationCallBack(object sender, ValidationEventArgs e)
|
||||||
|
Loading…
Reference in New Issue
Block a user