Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/fs-frost/asu-regex-js
Parser to work with SubStation Alpha Subtitles (SSA/ASS) in TypeScript and JavaScript.
https://github.com/fs-frost/asu-regex-js
aegisub fansub subtitles
Last synced: 19 days ago
JSON representation
Parser to work with SubStation Alpha Subtitles (SSA/ASS) in TypeScript and JavaScript.
- Host: GitHub
- URL: https://github.com/fs-frost/asu-regex-js
- Owner: FS-Frost
- Created: 2024-05-10T02:54:23.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2024-08-06T02:48:50.000Z (6 months ago)
- Last Synced: 2024-08-06T05:53:14.426Z (6 months ago)
- Topics: aegisub, fansub, subtitles
- Language: TypeScript
- Homepage: https://jsr.io/@fs-frost/asu
- Size: 2.88 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# asu-regex-js
![jsr](https://jsr.io/badges/@fs-frost/asu)
![main](https://github.com/FS-Frost/asu-regex-js/actions/workflows/main.yml/badge.svg)Parser to work with SubStation Alpha Subtitles (SSA/ASS) in TypeScript and JavaScript.
[Read the documentation](https://fs-frost.github.io/asu-regex-js/docs)
[Try the interactive playground](https://fs-frost.github.io/asu-regex-js)
## Installation
### Install using JSR (JavaScript Registry)
```sh
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](https://fs-frost.github.io/asu-regex-js/bundles/).
## Examples
Check out the [tests](https://github.com/FS-Frost/asu-regex-js/blob/main/src/asu.test.ts) or the [playground](https://fs-frost.github.io/asu-regex-js) for more examples.
### Parse a dialogue
```ts
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
```ts
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```ts
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
```ts
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
- [Bun (JavaScript runtime)](https://bun.sh/)
### Install JS dependencies
```sh
bun install
```### Run tests
```sh
bun test --coverage
```# Applications using Asu
- [Asu for SyncRajo Fansub](https://github.com/FS-Frost/asu-web)
- [Asu Playground](https://fs-frost.github.io/asu-regex-js)