Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for header fields. #6

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

silviapfeiffer
Copy link
Member

We don't actually parse VTT header fields, but we ignore them for now.
Fixes #5

Now, a file without any blank lines is perfectly valid, so we will never get an error for missing a blank line after the headers. Instead, just look-ahead if after the next blank line is a cue line to stop parsing blank lines.

We don't actually parse VTT header fields, but we ignore them for now.
Fixes w3c#5
@annevk
Copy link
Member

annevk commented Oct 12, 2014

If they are not actually being validated, is this useful?

@silviapfeiffer
Copy link
Member Author

Yes, because now the parser won't fail VTT files with extra lines at the top. This makes it spec compliant.

@annevk
Copy link
Member

annevk commented Oct 13, 2014

But this is also a validator. And since some of those lines have normative effect as @foolip pointed out, don't we want something more?

@silviapfeiffer
Copy link
Member Author

Until we all agree to support Regions, there's nothing normative to parse.

@foolip
Copy link
Member

foolip commented Oct 13, 2014

I can't quite figure out how many lines this patch skips, but it doesn't seem to match http://dev.w3.org/html5/webvtt/#webvtt-file-structure since it doesn't check for ":" anywhere. I guess there is invalid markup which is now silently skipped over?

@silviapfeiffer
Copy link
Member Author

I was only taking a first step in making it conformant to http://dev.w3.org/cvsweb/html5/webvtt/Overview.html?rev=1.62;content-type=text%2Fhtml#syntax , which is Ian's old spec. The new spec indeed requires header lines to have the "name : value" structure. I'm happy to extend the patch with that.

@foolip
Copy link
Member

foolip commented Oct 13, 2014

That spec you linked to says:

  1. The string "WEBVTT".
  2. Optionally, either a U+0020 SPACE character or a U+0009 CHARACTER TABULATION (tab) character followed by any number of characters that are not U+000A LINE FEED (LF) or U+000D CARRIAGE RETURN (CR) characters.
  3. Two or more WebVTT line terminators.

That doesn't allow for any extra lines at all.

@foolip
Copy link
Member

foolip commented Oct 13, 2014

In a browser, there's no reason to bother with these lines unless one supports regions. If this were my validator, I'd either want full regions support or none at all. But it's not.

@silviapfeiffer
Copy link
Member Author

@foolip I misread the old spec, sorry. I seemed to remember it skipping lines. I'll add the parsing as you suggest. (Just not tonight).

@foolip
Copy link
Member

foolip commented Oct 14, 2014

What you remember is probably the parser, which does skip lines.

@annevk
Copy link
Member

annevk commented Oct 14, 2014

So it seems not everyone is interested in shipping regions. I'm not sure I would accept a patch for the validator until that is resolved somehow.

@silviapfeiffer
Copy link
Member Author

@annevk right, not everyone wants regions, but everyone skips those extra lines, which is what my current patch does.

@annevk
Copy link
Member

annevk commented Oct 15, 2014

It's not clear to me that consensus has shifted to make that actually conforming. There's a lot of things that are ignored or processed in a certain way that are still not acceptable from a conformance perspective.

@silviapfeiffer
Copy link
Member Author

Firefox, Chrome, Safari, Opera ignore them. Only IE doesn't and that's because it's not been updated in a while.

@annevk
Copy link
Member

annevk commented Oct 15, 2014

Okay, but should those lines be flagged as being in error since they are not comments? That's what I was getting at mainly.

@silviapfeiffer
Copy link
Member Author

OK, I have added error handling for metadata headers. Anything that doesn't have a ":" will be flagged as an error. Also, lines that have a time spec in them raise an error that cues need to be separated from metadata headers. This should match the spec: http://dev.w3.org/html5/webvtt/#webvtt-file-structure

@annevk
Copy link
Member

annevk commented Oct 18, 2014

Thanks @silviapfeiffer. I'm still a bit concerned as I haven't heard from implementers that they want to pursue this direction of the format. E.g. are implementers planning on exposing this metadata through an API? @foolip per #6 (comment) seems against it and he's a co-editor of the specification...

@foolip
Copy link
Member

foolip commented Oct 18, 2014

As far as I know no browser has shipped regions yet. I currently have no plan to work on regions in Blink, but can't predict what happens if someone else does the work and sends an Intent to Ship.

Anyway, if you want to support regions in the validator, I'd recommend warning about any metadata header except "Region". Otherwise you won't notice the typo "Regoin" etc.

@silviapfeiffer
Copy link
Member Author

It was behind a flag in Chrome - has it been ripped out? Safari has released it - I can test in it in version 7.1 though it does seem buggy. Apple have also released them in QuickTime players and AVFoundation. I think they're doing this to be able to claim full compliance with US law.

@foolip
Copy link
Member

foolip commented Oct 19, 2014

It's still behind a flag in Chromium. You're right that Safari does expose VTTRegion, which is news to me. That makes the case for supporting it in the validator a lot stronger.

@zcorpan
Copy link
Member

zcorpan commented Apr 21, 2015

Allowing Region: headers only as the patch seems to do now seems like the right thing since it's in the spec and is implemented in at least Safari. But it should actually validate the headers, not allow any value.

Also it would make sense to fully support regions, including the region cue setting.

@zcorpan
Copy link
Member

zcorpan commented Oct 4, 2018

I learned the other day that STYLE blocks are being implemented in webkit.

@goatandsheep
Copy link

now that there are no conflicts, can this be merged?

@annevk
Copy link
Member

annevk commented Sep 21, 2019

What's the state of implementations?

@zcorpan
Copy link
Member

zcorpan commented Sep 21, 2019

I believe regions are implemented in webkit, chromium & gecko, and style is implemented in webkit, chromium has an "intent to implement", I haven't seen anything for style in gecko.

@zcorpan
Copy link
Member

zcorpan commented Sep 21, 2019

It looks like this PR is using the old region syntax. The new syntax uses blocks instead of "headers".

@silviapfeiffer
Copy link
Member Author

This PR definitely needs an update to the latest spec.

@silviapfeiffer
Copy link
Member Author

Forgot to send this: https://www.w3.org/wiki/TimedText/WebVTT_Implementation_Report best review of what's implemented and what's not

emmanent added a commit to kapwing/webvtt.js that referenced this pull request Jul 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support for metadata headers
5 participants