Koala is a DSL and SVG compiler for structured concept diagrams.
Project description
Koala
🇺🇸 English | 🇪🇸 Español
Koala is a DSL for generating diagrams from structured text.
The project is designed around a simple idea: the same source file should be able to drive multiple layouts and visual styles without rewriting the content itself.
Quick Start
Main entry point:
- cli.py
- installed command:
koala
Install locally in a virtual environment:
python3 -m venv .venv
./.venv/bin/pip install -r requirements.txt
./.venv/bin/pip install -e . --no-build-isolation
If you prefer a user-facing install instead of a repo-local venv:
pipx install .
Basic commands:
koala themes
koala layouts
koala typographies
koala compile docs/examples/tree.txt --layout tree
koala compile docs/examples/radial.txt --layout radial --theme jungle --size square
koala inspect docs/examples/tree.txt
koala validate docs/examples/radial.txt --strict
koala config-path
Available subcommands:
compile: render a source file to SVGinspect: show metadata, warnings, and resolved settingsvalidate: validate parsing and resolved settings; with--strictit fails on warningsthemes: list available themeslayouts: list available layoutstypographies: list available typography presetsconfig-path: show the expected user config path
User config:
- default path:
~/.config/koala/config.toml - fallback path:
~/.koala.toml
Example:
[tool.koala]
default_layout = "tree"
default_theme = "academic"
default_typography = "default"
default_size = "a4_landscape"
default_text_align = "left"
default_show_node_numbers = true
default_output_mode = "next_to_input"
Supported config keys:
default_layoutdefault_themedefault_typographydefault_sizedefault_text_aligndefault_show_node_numbersdefault_output_mode:next_to_input,desktop,cwddefault_output_dir
Output behavior:
- by default, output goes next to the source file and is named
<input_stem>.<layout>.svg --outputwrites to an explicit SVG path--output-dirwrites to a specific folder--desktopwrites to~/Desktopwhen present, otherwise falls back to the input folder
Current capabilities
- Parse hierarchical concept trees from
.txtand.docx - Render the same document as
tree,synoptic,synoptic_boxes, orradial - Apply themes and typography presets
- Select page size from the CLI
- Read optional render metadata directly from the source file with
@... - Fit the final scene into SVG output
Syntax overview
Nodes use hierarchical numbering:
1,2,3are roots1.1,1.2are children of11.1.1is a child of1.10is an optional super-root
Example:
1 DSL Platform
Defines the main concept.
organizes -> 1.1 Core
Contains parser, models, and validations.
renders -> 1.2 Render
Generates SVG output.
Optional semantic kind:
main:: 1 DSL Platform
hl:: 1.2 Users Table
hl:: contains -> 1.2.1 Foreign Key
note:: 1.3 Note
focus:: 1.4 Main Insight
Built-in kinds currently available:
- universal:
note,warn,soft - theme-owned:
main,hl,focus
main is intended mainly for the diagram root. When the root node uses main::, built-in themes give it a more prominent color treatment and a thicker border.
Built-in themes currently available:
defaultterracottajunglefrutalacademic
Optional metadata:
@layout tree
@theme terracotta
@typography default
@text-align justify
@size square
@show-node-numbers false
@output-dir output/metadata_demo
Metadata is optional and follows this precedence:
- explicit CLI flag
- metadata in the source file
- built-in defaults
Node text alignment is now left by default. If you want justified text, use @text-align justify.
For the full syntax, see docs/syntax.md.
CLI Reference
Current page presets:
a4:210 x 297 mma4_landscape:297 x 210 mmsquare:210 x 210 mm
Output:
- by default, next to the source file, named
<input_stem>.<layout>.svg - it can also go to
Desktop, another folder, or an explicit file path via--output
Layouts
Current supported layouts:
tree: top-down hierarchy with adaptive parent widths and page-aware fittingsynoptic: synoptic chart with brackets and no relation labelssynoptic_boxes: synoptic chart with boxes and relation labelsradial: center-out mind-map style layout
For implementation details, see docs/layouts.md.
Architecture
The project is split into three layers:
core/: parsing, DSL models, input loadinglayout/: shared measurement plus one geometry engine per layoutrender/: theme resolution, render context, viewport fitting, and SVG backend
The separation of concerns is:
coreunderstands the languagelayoutcomputes geometry and connector pathsrenderresolves presentation and draws the scene
For the full architecture, see docs/architecture.md.
Authoring tips for better visuals
These suggestions are practical heuristics for getting cleaner diagrams with the current engines.
General
- Keep titles short and concept-oriented; move explanation into body text
- Use relations only when they add value; too many relation labels create noise
- Prefer balanced sibling groups over very uneven branching when possible
- Split very long paragraphs into tighter prose; box measurement is line-based and compact prose produces better wrapping
- Use metadata for layout/theme/size when a file is meant to be rendered in a specific way
tree
- Best for classic hierarchies and explanatory maps
- Works especially well when upper levels are conceptual and lower levels carry detail
- Good fit for
a4_landscapeandsquare - If a parent has many children, keep child titles compact so the tree can stay readable at larger sizes
- If the map is shallow and very wide,
squareoften helps force a denser composition
synoptic
- Best for grouped classifications and outline-like content
- Prefer short titles and very light body text
- Works best when each level behaves like a category refinement
a4_landscapeis currently the safest page size because the internal geometry is still column-oriented- Use fewer relation labels in the source; they are intentionally suppressed in this layout
synoptic_boxes
- Best for left-to-right teaching diagrams or process decompositions
- Keep each sibling set conceptually parallel
- Use short-to-medium body text, not large paragraphs
a4_landscapeis currently the safest page sizesquareis already supported, but there is no dedicated compaction pass yet, so content should be tighter
radial
- Best for central topics with several balanced branches
- Try to keep first-level branches similar in importance and size
- Avoid one giant branch plus many tiny ones if you want a clean circular composition
squareanda4_landscapeusually give the best radial balance- If the root concept is very short and children are rich, radial can use the page very efficiently
Page-size-specific advice
a4
- Better for taller trees or vertically deep hierarchies
- Good when you want more stacked reading rhythm
- Less ideal for wide synoptic structures unless the content is compact
a4_landscape
- Current default
- Best general-purpose preset
- Safest choice for
synopticandsynoptic_boxes - Also strong for medium-width
treedocuments
square
- Best when you want a denser, more centered composition
- Strong option for
radial - Useful for
treewhen the content would otherwise spread too far horizontally - Requires tighter writing for
synopticandsynoptic_boxesuntil those engines get aspect-ratio-specific optimization
Recommended examples
Current status
The project is already useful for:
- rapid concept-map prototyping
- trying multiple layouts from the same content
- testing visual semantics with
kind:: - shipping self-describing demo files through metadata
There is still room to improve:
- layout-specific adaptation for
synopticandsynoptic_boxesunder portrait and square pages - richer DSL syntax
- stronger validations
- automated visual regression checks
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file koala_diagrams-0.1.0.tar.gz.
File metadata
- Download URL: koala_diagrams-0.1.0.tar.gz
- Upload date:
- Size: 39.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
15efcf542b1335a5b5d30a9486b7006a6522e3550b1b1616d79cc4319eb783ab
|
|
| MD5 |
2f4c0224c905c0ed4ed57c304092eda0
|
|
| BLAKE2b-256 |
c43d8589c586ed9b18369491eb11cff8a4b36490272801c42f29c6f411420ec8
|
File details
Details for the file koala_diagrams-0.1.0-py3-none-any.whl.
File metadata
- Download URL: koala_diagrams-0.1.0-py3-none-any.whl
- Upload date:
- Size: 45.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1f0572a12e6a75fea5546ccf740022513b401aa857219c443b1ca6f55278788e
|
|
| MD5 |
5a45772bbd06a1b363ba029b6370b577
|
|
| BLAKE2b-256 |
0830e69c3d78a1c71dac30e25a977a5984b4a0fed2300a14e6c2526e96a00084
|