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

Or with pipx:

pipx install koala-diagrams

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.6.tar.gz (40.9 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.6-py3-none-any.whl (51.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: koala_diagrams-1.2.6.tar.gz
  • Upload date:
  • Size: 40.9 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.6.tar.gz
Algorithm Hash digest
SHA256 4aaf75e675561ea0efc7eacaa0a591ff5b16fa2762f30f79f10369ad202c4768
MD5 35ac8f2b8bfe6ee7ea84d3aab13fe63d
BLAKE2b-256 af3333a1c1aa0a6cfe0b177bf7454d5f8bbe6e98b06c022f6e5da1bd3655e66a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: koala_diagrams-1.2.6-py3-none-any.whl
  • Upload date:
  • Size: 51.5 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.6-py3-none-any.whl
Algorithm Hash digest
SHA256 30fe524321d77fcc6fd04b1c5164dff30596c7478149564a0963f5cf09b323bd
MD5 6f709c0b86baad5a167d63813324bce7
BLAKE2b-256 1976efa81827347972e6c41d51b1ef38db68d46bae81b8012401b0a3c94abc4a

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