Rust Markdown Convertor which is complied to wasm(WebAssembly) can be used in both back-end and front-end(powered by wasm-bindgen).
Will use Wasm-pack to complie that.
wasm-pack build --target web --out-name index
After complie you can use this wasm library in your code.
- Step 1: import libiray
import init, { convert } from '../pkg/index.js';
- Step 2: Init, wasm-bindgen will load the files
await init();
- Step 3: call
convert
function
const markdown = `
# H1 Title
`;
const result = convert(markdown);