Call from another language
Problem. You are not writing Rust — you want to parse Aozora notation from Go, Java, Python, JavaScript, Ruby, PHP, or something further down the long tail.
One parser, many front doors
There is exactly one parser. Every binding funnels the same source text through the same lexer and emits the same HTML, the same canonical serialise, and the same wire-envelope JSON — byte-identical across every language. So the decision is not “which binding is more correct”; it is “which fits the language and runtime I already have.” Choosing a binding is the full decision table; this recipe is the short jump list.
Pick your language
-
JavaScript / TypeScript (browser, Node, Deno, edge) →
aozora-wasm. Awasm-bindgenDocumentclass; runs client-side and at the edge, distributed on npm. -
Python →
aozora-py. An in-process PyO3 native module built with maturin:from aozora_py import Document doc = Document("|青梅《おうめ》") print(doc.to_html()) # <ruby>青梅<rt>おうめ</rt></ruby> -
Go →
aozora-go. A pure-Go wazero host overaozora.wasm— no cgo, no C toolchain:go get github.com/P4suta/aozora-go -
C / C++ / Zig / any FFI-capable native language → the
aozora-ffiC ABI: an opaque handle plus JSON over a stable C header (aozora.h). -
Java, PHP, Ruby, .NET, Elixir, Haskell, … the long tail → the
aozora-extismhost SDK. One portableaozora.wasmthat any Extism host SDK loads — see below. -
Anything other than HTML (EPUB, LaTeX/PDF, DOCX, …) → the
aozora pandocpipe, regardless of host language.
The Extism template (the breadth strategy)
For the languages without a bespoke native binding, the answer is the
single aozora.wasm artifact loaded through that language’s Extism
host SDK. The steps are identical in every SDK — only the method names
change:
- Obtain
aozora.wasm(a GitHub release asset). - Load it with your host SDK’s plugin constructor (no WASI needed).
- Assert
schema_versionmatches the wire schema you compiled against. - Call an export with the source string:
to_html/serialize→ a bare string;diagnostics_json/nodes_json/pairs_json/container_pairs_json→ a{ schema_version, data }wire envelope.
- Parse the envelope
datawith types generated from the committed JSON Schema.
The reference host SDK (aozora-go) is exactly
this template instantiated in Go; every other Extism SDK follows the
same shape. The full export list and the language-agnostic walkthrough
live in the Extism chapter. Why a wasm plugin
for the tail rather than a native binding per language is
ADR-0006;
the short version is in
Choosing a binding → In-process vs host-runtime.
See also
- Choosing a binding — the decision table and the performance ordering.
- Extism host SDKs — the wasm exports and the per-language template.
- Go · Python · WASM · C ABI — the native / in-process bindings.
- Wire format — the JSON envelope every binding agrees on.