Convert special characters

This commit is contained in:
the1812 2019-01-17 17:21:24 +08:00
parent 13def457cc
commit 569d134f9c
4 changed files with 23 additions and 6 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -299,7 +299,7 @@ Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
}
const [startTime, endTime] = this.convertTime(xmlDanmaku.time, this.duration(xmlDanmaku));
assDanmakus.push(new AssDanmaku({
content: xmlDanmaku.content,
content: this.convertText(xmlDanmaku.content),
time: startTime,
endTime: endTime,
type: xmlDanmaku.type,
@ -317,6 +317,23 @@ Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
resolution: this.resolution
});
}
convertText(text)
{
const map = {
"{": "",
"}": "",
"&": "&",
"&lt;": "<",
"&gt;": ">",
"&quot;": '"',
"&apos;": "'",
};
for (const [key, value] of Object.entries(map))
{
text = text.replace(new RegExp(key, "g"), value);
}
return text;
}
convertType(danmaku)
{
return this.danmakuStack.push(danmaku).tags;