daisy / daisy/MathCAT

Add Javascript interface for MathCAT

Open
#157 5 comments 0 reactions 1 assignee Claimed by @ttpyorre View on GitHub
good first issue integrations
Dominant language
Rust
Stars
114
Forks
85
Avg merge
1d 11h
Merged PRs (30d)
42

Description

Currently, MathCATDemo uses a webassembly rust build and wraps stuff around that using whatever interface to it needs. It would be much better to make the interface explicit and then build the demo on that in Javascript.

This would parallel what is done for C, Python, etc.

This should be a relatively easy project. The basics are that for every MathCAT interface function, a Javascript callable function should be defined. This is done via

For example
```
pub fn set_mathml(mathml_str: String) -> Result
```
probably wants to have some code like:
```
#[wasm_bindgen]
pub fn setMathML(mathml: &str) -> Result {
return libmathcat::set_mathml(mathml);
}
```
Note that Javascript convention seems to be camelCase whereas rust convention is snake_case. Hence the exposed function is called `setMathML` and that is what Javascript should call.

Near the top of the file there needs to be
```
use wasm_bindgen::prelude::*;
use libmathcat::*;
```

From the little I've read, it seems that the `Result` return is magically handled by wasm-bindgen and the JavaScript code and if there is an error, standard JS exception handling works.

A good reference is [The wasm-bindgen Guide](https://rustwasm.github.io/docs/wasm-bindgen/). Among other things, it mentions using how to use webpack to package it all up.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.