mirror of
https://github.com/p-stream/p-stream.git
synced 2026-04-21 13:12:17 +00:00
remove clean subtitles function
This commit is contained in:
parent
609d4e79cd
commit
fcba122399
1 changed files with 1 additions and 10 deletions
|
|
@ -10,12 +10,6 @@ import { Transition } from "@/components/utils/Transition";
|
||||||
import { usePlayerStore } from "@/stores/player/store";
|
import { usePlayerStore } from "@/stores/player/store";
|
||||||
import { SubtitleStyling, useSubtitleStore } from "@/stores/subtitles";
|
import { SubtitleStyling, useSubtitleStore } from "@/stores/subtitles";
|
||||||
|
|
||||||
// Clean-up function to remove unwanted subtitle tags
|
|
||||||
function cleanSubtitleText(text: string): string {
|
|
||||||
// Remove unwanted tags like \an1, \pos, \i1, etc.
|
|
||||||
return text.replace(/\\[a-zA-Z0-9(),\s\-_]+/g, "").replace(/\}\s*/g, "");
|
|
||||||
}
|
|
||||||
|
|
||||||
const wordOverrides: Record<string, string> = {
|
const wordOverrides: Record<string, string> = {
|
||||||
i: "I",
|
i: "I",
|
||||||
};
|
};
|
||||||
|
|
@ -42,12 +36,9 @@ export function CaptionCue({
|
||||||
.replaceAll(/ i'/g, " I'")
|
.replaceAll(/ i'/g, " I'")
|
||||||
.replaceAll(/\r?\n/g, "<br />");
|
.replaceAll(/\r?\n/g, "<br />");
|
||||||
|
|
||||||
// Clean the subtitle text before sanitizing it
|
|
||||||
const cleanedText = cleanSubtitleText(textWithNewlines);
|
|
||||||
|
|
||||||
// https://www.w3.org/TR/webvtt1/#dom-construction-rules
|
// https://www.w3.org/TR/webvtt1/#dom-construction-rules
|
||||||
// added a <br /> for newlines
|
// added a <br /> for newlines
|
||||||
const html = sanitize(cleanedText, {
|
const html = sanitize(textWithNewlines, {
|
||||||
ALLOWED_TAGS: ["c", "b", "i", "u", "span", "ruby", "rt", "br"],
|
ALLOWED_TAGS: ["c", "b", "i", "u", "span", "ruby", "rt", "br"],
|
||||||
ADD_TAGS: ["v", "lang"],
|
ADD_TAGS: ["v", "lang"],
|
||||||
ALLOWED_ATTR: ["title", "lang"],
|
ALLOWED_ATTR: ["title", "lang"],
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue