diff options
| author | Bond_009 <bond.009@outlook.com> | 2023-05-22 22:48:09 +0200 |
|---|---|---|
| committer | Bond_009 <bond.009@outlook.com> | 2023-06-28 17:07:57 +0200 |
| commit | b5f0760db8dba96e9edd67d4b9c914cf25c3d26a (patch) | |
| tree | a60f87f379ddbfe2436d03b3b1a8f48cbc3b7490 /MediaBrowser.MediaEncoding/Subtitles/TtmlWriter.cs | |
| parent | f954dc5c969ef5654c31bec7a81b0b92b38637ae (diff) | |
Use RegexGenerator where possible
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 e5c785bc5..ea45f2070 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>", |
