xu-cheng / katex-rs

Rust bindings to KaTeX
https://docs.rs/katex
Apache License 2.0
110 stars 11 forks source link

failed to build to webassembly #2

Closed TorosFanny closed 4 years ago

TorosFanny commented 4 years ago

When compiling code simply like this

fn main() {
  let formula1 = katex::render("E = mc^2").unwrap();

  let opts = katex::Opts::builder().display_mode(true).build().unwrap();
  let formula2 = katex::render_with_opts("E = mc^2", opts).unwrap();
}

with command

cargo web build

Then it reports:

note: rust-lld: error: unknown file type: quickjs.nolto.o
xu-cheng commented 4 years ago

This library is primarily to be used for server side rendering. It utilizes quickjs, which is a JS interpreter written in C. Currently, it does not support webassembly target.

It is possible to build in webassembly with this patch and emscripten.

However, if your use case is running KaTeX inside browser. A better solution would be to call KaTeX JS directly through wasm-bindgen.