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.3.tar.gz (37.7 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.3-py3-none-any.whl (48.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: koala_diagrams-1.2.3.tar.gz
  • Upload date:
  • Size: 37.7 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.3.tar.gz
Algorithm Hash digest
SHA256 31aeace149f3290d0fa86a5ba7ba317c15c283fabbb6b425bd009e808f1c3d5b
MD5 85d30a9f03726cf6ffd29cab9469d57a
BLAKE2b-256 a8000f120983b79bf830875fbb45ab77dd1bb235170cb3b5ffd8f8d722ef61a2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: koala_diagrams-1.2.3-py3-none-any.whl
  • Upload date:
  • Size: 48.1 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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 dde6b6592f72dbba8f66a4bbda9b7c300b57ab33e4138334901027a0b1a1c569
MD5 20cf4d18c8f80138e5a948caab5d52fc
BLAKE2b-256 2b7d83b0b565a083f587e32ec9cb9a43427b6da83f08b3880af216c5955c730b

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