cutlass - JS library for ASS subtitles
cutlass is a Node.js module / JavaScript library for parsing and dealing with ASS subtitles.
Installation
Installation is simple with npm:
$ npm install cutlass
Basic Info and Examples
cutlass exports an object with four classes: Script, Event, Style and Color. The one you usually want to deal with is Script, which represents a whole ASS script. (For more detailed info about the classes and the functions and properties they export, refer to src/parser.ls
for the time being.)
var ass = ;var rawAss1 = "..." // pretend this is a full ASS script read from diskvar rawAss2 = "..." // this too var script1 = rawAss1; // sort the script by event start timescript1; // get the script as raw ASSvar rawScript1 = script1; var script2 = rawAss2; // for this script, we want to move all lines with the style "Sign" to the top.// `script.events` is a plain JS array, so we can use them our purpose here.var signs = ;var dialogue = ;for var i = 0 len = script2eventslength; i < len; ++i var line = script2eventsi; if linestyle === "Sign" signs; else dialogue; script2events = signs; // get the script as ASSvar rawScript2 = script2;