butterfansubs / aegsc

A compiler for aegs Aegisub karaoke templates
MIT License
1 stars 0 forks source link

aegsc: Aegisub Script Compiler

A compiler for aegs files, which allow karaoke templates (and possibly other ASS-based formats) to be written in a nicely formatted way. The compiler is available as a command line utility and as a Node library.

The aegs format used by this compiler is based on the format developed by DCTewi with a number of extensions.

Installation

To install the command line utility:

npm install --global github:butterfansubs/aegsc

If you do not wish to install Node separately, binaries with a Node runtime bundled are available on the Releases page. These can be run directly with no installation necessary.

To install the library as a dependency in a Node project:

npm install --save github:butterfansubs/aegsc

Node 14 or higher is supported.

Usage

Command Line

The command line utility processes aegsc data from stdin and sends the compiled output to stdout.

The shell's redirect operators may be used to send input and output from and to files if desired:

aegsc < input.aegs > output.txt

No flags or arguments are recognized at this time.

The input can use Unix (LF) or DOS/Windows (CRLF) line endings. The obsolete Classic Mac (CR) line endings are currently not supported. The output uses the system's line endings.

Library

The compiler may be imported as a CommonJS module:

const { compile } = require('aegsc');

const output = compile(input);

The compiler is also available as an ES module:

import { compile } from 'aegsc';

const output = compile(input);

Note that when used as a library, the input must be converted to use Unix (LF) line endings prior to being passed to the compiler. In addition, Unix line endings are used in the output.

The aegs format

The aegs format used by this compiler is described in the test/fixures/format-tutorial.aegs file. A real-world example can be found in the test/fixtures/real-world-example.aegs file. The expected output for both files can be found in their respective .out files in the same directory.

Major extensions to DCTewi's original format include (but are not limited to):

License

This project is licensed under the MIT license. See the LICENSE file for details.