Open darodi opened 2 years ago
While reading this doc I remembered why I use html.unescape
. It's because of the ampersand (&
) and greater-than (>
) escape sequences, not because of tags.
WebVTT styling is a little complex when you take into account the use of identifiers. I was thinking of a solution using an HTML parser.
Thanks for the info.
I'll add a new commit.
For the moment, I'm doing this in webvtt.structures.Caption.replace_color
def replace_color(x, tag, v):
return ("" if tag == "c" else ("<" + tag + ">")) \
+ "<font color=\"" + v + "\">" \
+ x.group(1) \
+ "</font>" \
+ ("" if tag == "c" else ("</" + tag + ">"))
x.group(1)
should be html.unescape(x.group(1))
An input could contain a tag within a tag:
for example: <c.magenta.bg_black><i>Some italic</i> and normal coloured text. By the way, 2 < 3 !</c>
I've made some tests, it is well rendered with this output
<font color="#ff00ff"><i>Some italic</i> and normal coloured text. By the way, 2 < 3 ! </font>
using
input
should give
instead of