Skip to content

Latest commit

 

History

History
executable file
·
113 lines (77 loc) · 2.68 KB

README.md

File metadata and controls

executable file
·
113 lines (77 loc) · 2.68 KB

VTTlint

A linter for the WebVTT specification with hinting based on common closed captioning standards.

Use

  1. Clone or download to local directory:
$ git clone https://github.com/mafachu/vttlint.git
  1. Install dependencies:
$ npm install

API

vttlint is a function that takes a file and returns an array of errors.

var vttlint = require('vttlint'),
    errors = vttlint('file.vtt');

// errors:
//
// [{ reason: 'Captions should have a minimum duration of 1.333 seconds.',
//    cue: 
//     { identifier: '',
//       start: 32.5,
//       end: 33.5,
//       text: '<v Neil deGrasse Tyson><i>Laughs</i>',
//       styles: 'align:left size:50%',
//       index: 12 } }]

vttlint takes an optional second argument that allows you to disable or override certain checks.

You can disable checking for minimum duration like this:

var errors = vttlint('file.vtt', { mindur: false });

CLI

You can use vttlint as a command-line tool by installing it globally:

$ npm install -g

vttlint takes a file and prints errors to stdout:

$ vttlint file.vtt
cue 12: Captions should have a minimum duration of 1.333 seconds.

1 error

You can override specific checks like this:

$ vttlint file.vtt --mindur 1

Or exclude checks like this:

$ vttlint file.vtt --mindur false

Options

mindur

Captions should have a minimum duration of X seconds. Default is 1.333.

maxdur

Captions should have a maximum duration of X seconds. Default is 6.

Planned Options

maxlines

See Issue #8. It is preferred that there are no more than X lines per caption. Default is 2.

rate

See Issue #17. Presentation rate should not to exceed X words per minute (wpm). Accepts any positive integer. Default is 140. Also accepts:

  • "lower": 130 wpm
  • "middle": 140 wpm
  • "upper": 160 wpm

sync

See Issue #50. Simultaneous captions should be synchronized.

clear

See Issue #51. Captions should start at least 0.001 seconds after preceding caption.

maxwords

See Issue #52. Captions should have no more than X words before manual line break. Default TBD.

Resources

License

MIT