Conversation
Add WebAssembly/JS bindings for TXM, mirroring the existing bindings/py/ pattern. Exposes a single render(input) -> string function via wasm-bindgen. - bindings/wasm/src/lib.rs: wasm_bindgen wrapper around txm::render - bindings/wasm/Cargo.toml: standalone workspace, path-dep on txm - bindings/wasm/README.md: Node.js usage + build instructions - .gitignore: add pkg/ for wasm-pack output No changes to the core crate. default-features = false keeps fancy/ratatui out of the wasm build.
wasm-pack build + node smoke test on push/PR to main.
DuskyElf
requested changes
Jul 14, 2026
| node -e " | ||
| const { render } = require('./bindings/wasm/pkg'); | ||
| const out = render('E = mc^2'); | ||
| if (!out.includes('mc')) { console.error(out); process.exit(1); } |
Collaborator
There was a problem hiding this comment.
why are the tests in the CI and not part of the wasm package ?
Author
There was a problem hiding this comment.
sorry, too much vibe coding - agent couldn't access .github/workflows
There was a problem hiding this comment.
Pull request overview
Adds a new bindings/wasm/ crate to expose TXM rendering via WebAssembly/JavaScript using wasm-bindgen, following the existing standalone-workspace + path-dependency pattern used by bindings/py/.
Changes:
- Introduces
txm-wasmcrate with a singlerender(&str) -> Result<String, JsValue>export calling intotxm::render. - Adds Node-focused build and usage documentation for the wasm package.
- Adds a GitHub Actions workflow to build the wasm bindings and run a minimal Node smoke test.
Reviewed changes
Copilot reviewed 4 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| bindings/wasm/src/lib.rs | Adds the wasm-bindgen wrapper API over txm::render. |
| bindings/wasm/README.md | Documents building with wasm-pack and Node usage examples. |
| bindings/wasm/Cargo.toml | Defines the txm-wasm crate and its path dependency on txm with default-features = false. |
| bindings/wasm/Cargo.lock | Locks dependencies for the standalone wasm workspace. |
| .gitignore | Ignores wasm-pack build output directory. |
| .github/workflows/wasm.yml | Adds CI build + Node smoke test for wasm bindings. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+14
to
+16
| - uses: actions-rust-lang/setup-rust-toolchain@v1.17.0 | ||
| with: | ||
| targets: wasm32-unknown-unknown |
| /// Render a LaTeX math expression to Unicode art (one newline-separated row per line). | ||
| #[wasm_bindgen] | ||
| pub fn render(input: &str) -> Result<String, JsValue> { | ||
| libtxm::render(input).map_err(|e| JsValue::from_str(&e.0)) |
- lib.rs: return JsError instead of JsValue (proper JS Error w/ stack traces) - lib.rs: add #[test] module (basic, integral, fraction, error cases) - wasm.yml: fix 'targets:' -> 'target:' (action input key) - wasm.yml: replace inline node smoke test with 'cargo test'
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds WebAssembly / JavaScript bindings for TXM, mirroring the existing
bindings/py/pattern. Exposes a single function:Why
WASM bindings let TXM be used from Node.js, browsers, and any JS runtime — useful for terminal UIs, editors, and tools that want inline LaTeX math rendering without a subprocess.
Files
bindings/wasm/src/lib.rs— 7-linewasm_bindgenwrapper aroundtxm::renderbindings/wasm/Cargo.toml— standalone[workspace], path-dep ontxmwithdefault-features = false(keepsfancy/ratatuiout of the wasm build)bindings/wasm/README.md— Node.js build + usage instructionsDesign decisions
bindings/py/— same standalone-workspace + path-dep pattern, samerender->Result<String, Error>API shapedefault-features = false— thefancy(yansi) andratatuifeatures aren't useful in wasm; we only need the plain-text render pathVerified locally
Suggested CI (couldn't push — fork token lacks
workflowscope)If you'd like CI for the wasm build, here's a ready-to-add
.github/workflows/wasm.yml:Happy to adjust naming (
txm-wasmmirrorstxm-py), targets, or structure to match your preferences.