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.5.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.5-py3-none-any.whl (51.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: koala_diagrams-1.2.5.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.5.tar.gz
Algorithm Hash digest
SHA256 7401eee119ecd3e72c878c6be006fb96ae4f45bcf6ec7f407a3b606ade4d9afe
MD5 0f154727c5ce6065e478b6aed55b7b7d
BLAKE2b-256 c5143263748c38deb3fac4f2316d8cc0840cf3c567e5b2715b9c83057147a4dd

See more details on using hashes here.

File details

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

File metadata

  • Download URL: koala_diagrams-1.2.5-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.5-py3-none-any.whl
Algorithm Hash digest
SHA256 de58ba4a16c7fde68f81f1c5162d1c992d4c21105dac2d0b24fc2e7c00984707
MD5 964ff0703c0dcdbc2b806fa64451620c
BLAKE2b-256 395f2b25bc6a40fbaef2d2593a9d74da9692dacb32d0099e88a7e8b4b9d39d51

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