KABBOUCHI / pulldown-cmark-js

A JavaScript WebAssembly wrapper for the `pulldown-cmark` rust library.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

pulldown-cmark JS-WASM Wrapper

A JavaScript WebAssembly wrapper for the pulldown-cmark library.

๐Ÿš€ Usage

Basic:

import { parse } from "pulldown-cmark";

parse("# Hello world!");

With Manual Initialization:

if your bundler does not support WebAssembly (WASM) out of the box, use the init function to manually initialize the WASM module.

import init, { parse } from "pulldown-cmark/init";

await init()

parse("# Hello world!");

๐Ÿ”ง Configuration

Vite

Enable WASM in Vite by importing and configuring the required plugins.

import wasm from "vite-plugin-wasm";
import topLevelAwait from "vite-plugin-top-level-await";
import { defineConfig } from "vite";

export default defineConfig({
  plugins: [wasm(), topLevelAwait()],
});

Webpack:

Enable WASM in Webpack by adjusting the experiments configuration.

module.exports = {
  //... (other config properties)
  experiments: {
    asyncWebAssembly: true,
    layers: true,
    topLevelAwait: true,
  },
};

About

A JavaScript WebAssembly wrapper for the `pulldown-cmark` rust library.

License:MIT License


Languages

Language:TypeScript 41.0%Language:Rust 37.7%Language:HTML 21.4%