@markdy/core
The parser and AST types for MarkdyScript — a DSL for describing 2D animated scenes.
Features
- Zero runtime dependencies — pure TypeScript, no DOM or platform APIs
- Single-pass parser — line-by-line state machine with strict
ParseErrordiagnostics - Rich type system —
var,def,seqexpanded at parse time for composable scene authoring - Isomorphic — runs in Node.js, Deno, Bun, edge runtimes, and the browser
Installation
pnpm add @markdy/core
Package position (text)
@markdy/core
-> parser + AST types (no DOM, no runtime deps)
-> foundation for renderer, CLI, language server, and integrations
Output preview
Usage
import { parse, ParseError } from "@markdy/core";
import type { SceneAST } from "@markdy/core";
const source = `
scene width=600 height=300 bg=white
actor label = text("Hello") at (50, 130) size 40 opacity 0
@0.3: label.fade_in(dur=0.6)
`;
try {
const ast: SceneAST = parse(source);
console.log(ast.meta); // { width: 600, height: 300, fps: 30, bg: "white", duration: 0.9 }
console.log(ast.actors); // { label: { type: "text", args: ["Hello"], x: 50, y: 130, ... } }
console.log(ast.events); // [{ time: 0.3, actor: "label", action: "fade_in", ... }]
} catch (e) {
if (e instanceof ParseError) {
console.error(`Line ${e.line}: ${e.message}`);
}
}
Exports
| Export | Type | Description |
|---|---|---|
parse |
(source: string) => SceneAST |
Parse MarkdyScript source into an AST |
ParseError |
class | Error with .line number for diagnostics |
SceneAST |
type | Complete scene representation |
SceneMeta |
type | Scene configuration (width, height, bg, etc.) |
AssetDef |
type | Asset declaration (image or icon) |
ActorDef |
type | Actor declaration (type, position, modifiers) |
TimelineEvent |
type | Timeline event (time, actor, action, params) |
TemplateDef |
type | User-defined actor template |
SequenceDef |
type | User-defined animation sequence |
Documentation
- Syntax Reference — complete DSL language spec
- Tutorial — step-by-step guide
- Agent Guide — structured reference for AI/LLM code generation
- Architecture — parser internals and design decisions