Compile ArchLang → SVG, ASCII, Plan JSON or PNG
compileConverts ArchLang .arch source or Plan JSON into SVG, ASCII, JSON, or PNG floor plans and returns diagnostics to correct errors.
Instructions
Compile ArchLang .arch source (or a Plan-JSON object) to an SVG floor plan, or with format to a plain-text ASCII plan ("txt"), Plan JSON ("json") or an image ("png"). Format "json" returns the plan as an object, with schema naming its JSON Schema; passed back as plan_json it compiles to the same drawing, unless the plan uses a part of the language Plan JSON does not carry (the sheet, styles, curves, roofs, storeys, place, accessibility metadata). Returns the output plus diagnostics; a diagnostic usually carries a byte span with line/col and an E_/W_ code, and often a fix, sometimes one the fix tool can apply. Errors come back as data, never as exceptions: read diagnostics and correct the source. A multi-storey plan (level <n> { … }) returns the lowest storey in output and every storey in pages[] ({ level, name, output }); pass level to render just one. format "png" returns the usual result as text, then the drawing (the lowest storey, or level) as image content, as wide as width says; it needs the optional renderer @resvg/resvg-js, and without it the call returns ok:false with an error saying how to install it.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| level | No | Render only this storey of a multi-storey plan. An undeclared level is an error, not a guess. | |
| width | No | png only (any other format refuses it): the image width in pixels, clamped to 256-4096, and narrower for a tall plan so neither side exceeds 4096; default 1600. | |
| format | No | svg (default), txt (zero-dependency ASCII), json (Plan JSON, the shape `plan_json` takes) or png (an image; needs the optional renderer). | |
| source | No | ArchLang source (a `plan "…" { … }`). Provide this OR plan_json. | |
| overlay | No | Draw an opt-in circulation overlay (SVG only). | |
| plan_json | No | Plan JSON (RPLAN shape) as an alternative to `source`; converted to .arch then compiled. | |
| accessible | No | Emit <title>/<desc>/role/aria accessibility metadata (SVG only). |