Skip to main content
Home

@fs-frost/asu@1.10.0
Built and signed on GitHub Actions

Parser to work with SubStation Alpha Subtitles (SSA/ASS) in TypeScript and JavaScript.

This package works with Cloudflare Workers, Node.js, Deno, Bun, Browsers
This package works with Cloudflare Workers
This package works with Node.js
This package works with Deno
This package works with Bun
This package works with Browsers
JSR Score
76%
Published
2 weeks ago (1.10.0)

asu-regex-js

jsr main

Parser to work with SubStation Alpha Subtitles (SSA/ASS) in TypeScript and JavaScript.

Read the documentation

Try the interactive playground

Installation

Install using JSR (JavaScript Registry)

bunx jsr add @fs-frost/asu

For NPM, Yarn, etc., check out https://jsr.io/@fs-frost/asu.

Install nightly bundles

Nightly bundles for Bun, Node and browser are available on Bundles.

Examples

Check out the tests or the playground for more examples.

Parse a dialogue

import * as asu from "@fs-frost/asu";

// Update font size from 32 to 16
const text = "Dialogue: 0,1:23:45.67,2:34:56.78,Chitanda,actor,12,23,34,fx,{\\pos(182,421)}LINE 1";

const line = asu.parseLine(text);
if (line == null) {
    console.error("invalid line");
    return;
}

line.style = "Oreki";
line.content = "Some {\\i1}other{\\i0} text";

console.log(asu.lineToString(line));
// Dialogue: 0,1:23:45.67,2:34:56.78,Oreki,actor,12,23,34,fx,Some {\i1}other{\i0} text

Set tag

import * as asu from "@fs-frost/asu";

// Update font size from 32 to 16
const text = "{\\be2\\fs32}Kirino-san";
const items = asu.parseContent(text);
asu.setFs(items, 16);

console.log(asu.contentsToString(items));
// {\be2\fs16}Kirino-san

Find tag

import * as asu from "@fs-frost/asu";

// find blur
const text = "{\\blur2\\fs32}Kirino-san";
const items = asu.parseContent(text);
const tagBlur = asu.findBlur(items);
if (tagBlur == null) {
    console.error("blur not found");
    return;
}

tagBlur.value = 4;
console.log(asu.contentsToString(items));
// {\blur4\fs32}Kirino-san

Create tag

import * as asu from "@fs-frost/asu";

// Create pos
const text = "{\\be2\\fs32}Kirino-san";
const items = asu.parseContent(text);
asu.setPos(items, -20, 67.9);

console.log(asu.contentsToString(items));
// {\be2\fs32\pos(-20,67.9)}Kirino-san

Development

Requirements

Install JS dependencies

bun install

Run tests

bun test --coverage

Applications using Asu

Built and signed on
GitHub Actions

New Ticket: Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.

Add Package

deno add jsr:@fs-frost/asu

Import symbol

import * as asu from "@fs-frost/asu";
or

Import directly with a jsr specifier

import * as asu from "jsr:@fs-frost/asu";

Add Package

pnpm i jsr:@fs-frost/asu
or (using pnpm 10.8 or older)
pnpm dlx jsr add @fs-frost/asu

Import symbol

import * as asu from "@fs-frost/asu";

Add Package

yarn add jsr:@fs-frost/asu
or (using Yarn 4.8 or older)
yarn dlx jsr add @fs-frost/asu

Import symbol

import * as asu from "@fs-frost/asu";

Add Package

npx jsr add @fs-frost/asu

Import symbol

import * as asu from "@fs-frost/asu";

Add Package

bunx jsr add @fs-frost/asu

Import symbol

import * as asu from "@fs-frost/asu";