Skip to main content

Safe, deterministic MDX rendering powered by a Rust core with batteries-included Python bindings

Project description

Dinja Logo

Documentation Python Rust GitHub stars License

Dinja

Safe, deterministic MDX rendering powered by a Rust core with batteries-included Python bindings.

Links

Installation

Target Command
Python package uv add dinja
Rust crate cargo add dinja-core

Usage

Rust

use dinja_core::service::{RenderService, RenderServiceConfig};

fn main() -> anyhow::Result<()> {
    let config = RenderServiceConfig::default();
    let service = RenderService::new(config)?;

    let html = service.render_string("example.mdx", "# Hello **dinja**")?;
    println!("{html}");
    Ok(())
}

Python

from dinja import Renderer, Input, Settings

# Create a renderer instance (engine loads once)
renderer = Renderer()

# Render MDX content with type-safe dataclasses
result = renderer.render(
    Input(
        mdx={"example.mdx": "---\ntitle: Demo\n---\n# Hello **dinja**"},
        settings=Settings(output="html", minify=True, engine="base"),
    )
)

entry = result["files"]["example.mdx"]

if entry["status"] == "success":
    rendered = entry["result"]
    metadata = rendered.get("metadata", {})
    print("title:", metadata.get("title"))
    print("html:", rendered.get("output"))
else:
    print("error:", entry.get("error"))

# Reuse the same instance for multiple renders with different modes
result1 = renderer.render(
    Input(
        mdx={"page1.mdx": "# Page 1"},
        settings=Settings(output="html"),
    )
)

result2 = renderer.render(
    Input(
        mdx={"page2.mdx": "# Page 2"},
        settings=Settings(output="schema"),
    )
)

rendered["output"] contains HTML, JavaScript, or schema code depending on settings.output.

More examples live in python-bindings/examples/.

License

BSD 3-Clause. See LICENSE.

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

dinja-0.2.2.tar.gz (87.2 kB view details)

Uploaded Source

Built Distributions

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

dinja-0.2.2-cp313-abi3-win_amd64.whl (16.9 MB view details)

Uploaded CPython 3.13+Windows x86-64

dinja-0.2.2-cp313-abi3-manylinux_2_34_x86_64.whl (19.6 MB view details)

Uploaded CPython 3.13+manylinux: glibc 2.34+ x86-64

dinja-0.2.2-cp313-abi3-macosx_11_0_arm64.whl (17.7 MB view details)

Uploaded CPython 3.13+macOS 11.0+ ARM64

dinja-0.2.2-cp313-abi3-macosx_10_12_x86_64.whl (18.5 MB view details)

Uploaded CPython 3.13+macOS 10.12+ x86-64

File details

Details for the file dinja-0.2.2.tar.gz.

File metadata

  • Download URL: dinja-0.2.2.tar.gz
  • Upload date:
  • Size: 87.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for dinja-0.2.2.tar.gz
Algorithm Hash digest
SHA256 32a24dd23e6e8087ea9b59e2112201fb0cc389f70eecbf806b1f4c447f58a1b6
MD5 f2c393085d6812b3fd99489284529231
BLAKE2b-256 d1db981d1ec7e093a8285102d8d1dfe760d9a2da72774081636f2c9dccbe3800

See more details on using hashes here.

Provenance

The following attestation bundles were made for dinja-0.2.2.tar.gz:

Publisher: publish-python-manual.yml on hlop3z/dinja

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file dinja-0.2.2-cp313-abi3-win_amd64.whl.

File metadata

  • Download URL: dinja-0.2.2-cp313-abi3-win_amd64.whl
  • Upload date:
  • Size: 16.9 MB
  • Tags: CPython 3.13+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for dinja-0.2.2-cp313-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 d18f9f7c681ac096db83175508a76d773d423d8880ba1357223188166f86557f
MD5 8560835900fd88679d6c614a1ae086fb
BLAKE2b-256 0447bc385f3b3f5a7aadd1f04209b63b871f4c18174171a06077a68ef86ee59f

See more details on using hashes here.

Provenance

The following attestation bundles were made for dinja-0.2.2-cp313-abi3-win_amd64.whl:

Publisher: publish-python-manual.yml on hlop3z/dinja

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file dinja-0.2.2-cp313-abi3-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for dinja-0.2.2-cp313-abi3-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 3ff44eb28b4a511219c5d87fe09844f4c1a23a34cd9de86394a5bf9b9f518e54
MD5 0c797d1f108e2045b50e464bf26b8e6c
BLAKE2b-256 5e29897f50d44d373d6a1471c589f2715dab1c07369ddeaded6b6ecff96c22b0

See more details on using hashes here.

Provenance

The following attestation bundles were made for dinja-0.2.2-cp313-abi3-manylinux_2_34_x86_64.whl:

Publisher: publish-python-manual.yml on hlop3z/dinja

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file dinja-0.2.2-cp313-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for dinja-0.2.2-cp313-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7c6f0a3c44accc0d1c1a57a529c7ff9f6009b6c74a858fcc18e46ee0b239a34b
MD5 ae56fe28ba458ca22e1786fff1d6826f
BLAKE2b-256 22a8f59bfc9f1e6b50b73f6cbbf1ecc7c936ac38b66c59636370f009b2ee1fc1

See more details on using hashes here.

Provenance

The following attestation bundles were made for dinja-0.2.2-cp313-abi3-macosx_11_0_arm64.whl:

Publisher: publish-python-manual.yml on hlop3z/dinja

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file dinja-0.2.2-cp313-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for dinja-0.2.2-cp313-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 31db47e344cc2b21b859f2f214c98138c9e1eb059b9ca14c5638e4ed66ae19db
MD5 b5185a960c9f7fb085da953c44729f1a
BLAKE2b-256 8ebd0058c98edc9b3b21ed1ac9a922d252f0c028c86fb045aa4044594c3f697a

See more details on using hashes here.

Provenance

The following attestation bundles were made for dinja-0.2.2-cp313-abi3-macosx_10_12_x86_64.whl:

Publisher: publish-python-manual.yml on hlop3z/dinja

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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