Skip to main content

svg++ reference renderer

Project description

diagramagic

svg++ reference renderer for humans and LLMs. Feed it svg++ input and it emits plain SVG—no runtime, no exotic format. What is "svg++"? Just something we made up here: it's simply svg plus a few additions to support text layout and templates.

Installation

pip install diagramagic

Note: This package includes a Rust extension for accurate SVG measurement. During installation, the extension will be compiled from source, which requires the Rust toolchain:

# Install Rust (if not already installed)
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

# Then install diagramagic
pip install diagramagic

Installation typically takes 30-60 seconds while the Rust extension compiles.

Quick Start

  • CLI: diagramagic input.svg++ > output.svg
  • Library: from diagramagic import diagramagic
  • Cheat sheet: diagramagic --cheatsheet (or see AGENTS.md)
  • Full spec: PROJECTSPEC.md
  • Tests: python tests/run_tests.py

svg++ basics: wrap your document in <diag:diagram> with the diag: namespace, use <diag:flex> for layout, and diag:wrap="true" on <text> to wrap. Everything compiles to pure SVG 1.1.

Need reusable pieces? Define <diag:template name="card">…</diag:template> once, then drop <diag:instance template="card"> wherever you need consistent cards or packets.

Output defaults to a white canvas; set diag:background="none" (or any color) on <diag:diagram> to change it.

Example:

<diag:diagram xmlns="http://www.w3.org/2000/svg"
              xmlns:diag="https://example.com/diag"
              width="300" height="160">
  <style>
    .card { fill:#fff; stroke:#999; rx:10; ry:10; }
    .title { font-size:16; font-weight:600; }
    .body { font-size:12; }
  </style>

  <diag:flex x="20" y="20" width="260" padding="14" gap="8" background-class="card">
    <text class="title" diag:wrap="false">Hello svg++</text>
    <text class="body" diag:wrap="true">
      This paragraph wraps to the flex width automatically.
    </text>
  </diag:flex>
</diag:diagram>

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

diagramagic-0.1.5.tar.gz (43.8 kB view details)

Uploaded Source

Built Distribution

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

diagramagic-0.1.5-cp311-cp311-macosx_11_0_arm64.whl (985.9 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

File details

Details for the file diagramagic-0.1.5.tar.gz.

File metadata

  • Download URL: diagramagic-0.1.5.tar.gz
  • Upload date:
  • Size: 43.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.5

File hashes

Hashes for diagramagic-0.1.5.tar.gz
Algorithm Hash digest
SHA256 d3eb80115d010e975bb3299742a15faeea4ce0fe90f83b3ea8a90f4c277c7ced
MD5 0759cd972c0c9c26452c6ff2dbf56d8b
BLAKE2b-256 dc30e7d4291323c62a9f12d4c10e0a8e66ee9c3b88e12e7ab51f7cdcce6f0f6d

See more details on using hashes here.

File details

Details for the file diagramagic-0.1.5-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for diagramagic-0.1.5-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 27d5c09b81727b433234a5f33e6b3f3916c7d286a3685c57c3e2c34d2d7429f4
MD5 849988287343637430af76bfb463f61f
BLAKE2b-256 77d1fce3b5a20bcb9f35b0a21955976f28ba1ffb4f9dc28d55b9271551f0b3eb

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