Skip to main content

Koala is a DSL and SVG compiler for structured concept diagrams.

Project description

Koala

Koala is a DSL for generating diagrams from structured text.

Write once, render in multiple layouts.

GitHub Repository Español

Quick Example

Write this:

@theme jungle

main:: 1 Biology
Study of life.

hl:: contains -> 1.1 Cell
Basic unit of life.

1.2 Genetics
Study of heredity.

Then run:

koala compile example.txt --layout tree

Result

Koala diagram example

Installation

Install from PyPI:

pip install koala-diagrams==1.2.1

Or with pipx:

pipx install koala-diagrams==1.2.1

Usage

CLI

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

Python

import koala

file_result = koala.compile(
    "docs/examples/radial.txt",
    layout="radial",
    theme="academic",
    size="square",
)

svg_result = koala.render_text(
    """
    1 Central Topic
    Main explanation.

    1.1 First Branch
    Supporting detail.
    """,
    layout="tree",
    theme="frutal",
)

source_path = koala.save_text(
    "1 Root\nBody.\n",
    "docs/examples/inline_demo",
)

print(file_result.output_svg)
print(svg_result.svg)
print(source_path)

Library API summary:

  • koala.compile(path, **config) or koala.compile_file(path, **config): source file to .svg
  • koala.render_text(text, **config): Koala DSL text to in-memory SVG via result.svg
  • koala.save_text(text, output, **config): raw Koala DSL text to .txt
  • koala.compile_text(text, **config): legacy helper that still writes .svg to disk

RenderResult now always includes the serialized SVG in result.svg. result.output_svg is only populated when the operation writes a file.

In general, avoid embedding @show-node-numbers in document metadata. Prefer CLI flags, library arguments, or user config defaults unless a file really needs to be self-descriptive about numbering.

DSL Syntax

Koala uses a simple line-based DSL:

[kind::] [relation ->] number title

Example:

1 Main Concept
contains -> 1.1 Child Node
hl:: 1.2 Highlighted Node

Features

  • Simple hierarchical DSL
  • Multiple layouts (tree, radial, synoptic)
  • Theme system
  • CLI and Python API
  • SVG output to disk or in memory

Multiple Layouts

Tree, radial, and synoptic layouts from the same source.

Radial example

Philosophy

Koala is built around a simple idea:

The same source file should be able to drive multiple layouts and visual styles without rewriting the content.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

koala_diagrams-1.2.4.tar.gz (40.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

koala_diagrams-1.2.4-py3-none-any.whl (51.2 kB view details)

Uploaded Python 3

File details

Details for the file koala_diagrams-1.2.4.tar.gz.

File metadata

  • Download URL: koala_diagrams-1.2.4.tar.gz
  • Upload date:
  • Size: 40.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for koala_diagrams-1.2.4.tar.gz
Algorithm Hash digest
SHA256 e76f4d66df93ca80ecb6a376975c3dc07bec6154d1ad0bfc5990d8987e8e8652
MD5 4acd0cdd4b7142e2cef5be7ee81a2915
BLAKE2b-256 e2803d70ffeaef23b2e3c6d5a044c1261012e4b8bd019a5f020e37385f81f434

See more details on using hashes here.

File details

Details for the file koala_diagrams-1.2.4-py3-none-any.whl.

File metadata

  • Download URL: koala_diagrams-1.2.4-py3-none-any.whl
  • Upload date:
  • Size: 51.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for koala_diagrams-1.2.4-py3-none-any.whl
Algorithm Hash digest
SHA256 e0539b9b8e7afa65f44a69d6a8af1d98c88994b0d6dbeed7aa7278be5a89ab72
MD5 3d5365ea220d4e128d1a436fae200b99
BLAKE2b-256 4ffe9ffad108dc48b90aee63e72ad172424ca03748ed7713ab6c3c0ad955dc42

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page