diff options
| author | Bond-009 <bond.009@outlook.com> | 2023-07-06 19:56:00 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-07-06 19:56:00 +0200 |
| commit | b95fa294c9e896349c528c032508b9c714c13395 (patch) | |
| tree | 7b85758236caae303e54814f6a13051a3218b60e /MediaBrowser.MediaEncoding/Subtitles/TtmlWriter.cs | |
| parent | fb9412b65a569f06364ba77841a287c23d142f73 (diff) | |
| parent | 83d6f21fd021c66ab3b1f6501ecdfd016fee540f (diff) | |
Merge pull request #9799 from Bond-009/genregex
Diffstat (limited to 'MediaBrowser.MediaEncoding/Subtitles/TtmlWriter.cs')
| -rw-r--r-- | MediaBrowser.MediaEncoding/Subtitles/TtmlWriter.cs | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/MediaBrowser.MediaEncoding/Subtitles/TtmlWriter.cs b/MediaBrowser.MediaEncoding/Subtitles/TtmlWriter.cs index e5c785bc57..ea45f2070a 100644 --- a/MediaBrowser.MediaEncoding/Subtitles/TtmlWriter.cs +++ b/MediaBrowser.MediaEncoding/Subtitles/TtmlWriter.cs @@ -9,8 +9,11 @@ namespace MediaBrowser.MediaEncoding.Subtitles /// <summary> /// TTML subtitle writer. /// </summary> - public class TtmlWriter : ISubtitleWriter + public partial class TtmlWriter : ISubtitleWriter { + [GeneratedRegex(@"\\n", RegexOptions.IgnoreCase)] + private static partial Regex NewLineEscapeRegex(); + /// <inheritdoc /> public void Write(SubtitleTrackInfo info, Stream stream, CancellationToken cancellationToken) { @@ -38,7 +41,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles { var text = trackEvent.Text; - text = Regex.Replace(text, @"\\n", "<br/>", RegexOptions.IgnoreCase); + text = NewLineEscapeRegex().Replace(text, "<br/>"); writer.WriteLine( "<p begin=\"{0}\" dur=\"{1}\">{2}</p>", |
