w3c / webvtt

WebVTT Standard
https://w3c.github.io/webvtt/
Other
104 stars 40 forks source link

Support character escapes in classes (<c.foo&amp;bar>) #251

Open zcorpan opened 9 years ago

zcorpan commented 9 years ago

https://w3c.github.io/webvtt/#webvtt-start-tag-class-state

WebVTT start tag class state Jump to the entry that matches the value of c: [...] Anything else Append c to buffer and jump to the step labeled next.

Should we support character escapes in classes?

<c.foo&amp;bar>

The class name above is parsed to foo&amp;bar, not foo&bar. i.e. the Selector to match it would be ::cue(.foo\&amp\;bar) and not ::cue(.foo\&bar). I think this is a surprising and unnecessary, I don't see any problem with supporting escapes here as well as in the annotation (which is already supported).

The syntax disallows "&" in classes (so the above is not valid):

https://w3c.github.io/webvtt/#webvtt-cue-span-start-tag

WebVTT cue span start tag has a tag name and either requires or disallows an annotation, and consists of the following components, in the order given:

A U+003C LESS-THAN SIGN character (<). The tag name. Zero or more occurrences of the following sequence: U+002E FULL STOP character (.) One or more characters other than U+0009 CHARACTER TABULATION (tab) characters, U+000A LINE FEED (LF) characters, U+000D CARRIAGE RETURN (CR) characters, U+0020 SPACE characters, U+0026 AMPERSAND characters (&), U+003C LESS-THAN SIGN characters (<), U+003E GREATER-THAN SIGN characters (>), and U+002E FULL STOP characters (.), representing a class that describes the cue span’s significance.

zcorpan commented 9 years ago

https://zcorpan.github.io/live-webvtt-viewer/#vtt=WEBVTT%0A%0A00%3A00%3A00.000+--%3E+00%3A00%3A10.000%0A%3Cc.foo%26amp%3Bbar%3Eclass%3C%2Fc%3E%0A&style=%3A%3Acue(.foo%5C%26amp%5C%3Bbar)+%7B%0Abackground%3Ared%0A%7D%0A%3A%3Acue(.foo%5C%26bar)+%7B%0Acolor%3Alime%0A%7D (background is red in webkit/blink/presto)

zcorpan commented 9 years ago

Depends on: #253

zcorpan commented 9 years ago

Depends on: #266

zcorpan commented 9 years ago

Maybe not change this if we do #270