Skip to main content

rusty_markdown

Deno bindings for pulldown-cmark, a CommonMark-compliant Markdown parser made in Rust, compiled to WebAssembly.

Example

import { html } from "https://deno.land/x/rusty_markdown@v0.3.0/mod.ts";

console.log(html("Hello **World**!"));
// "<p>Hello <strong>World</strong>!</p>\n"

console.log(html("Hello ~~Friends~~ **World**!", { strikethrough: true }));
// "<p>Hello <del>Friends</del> <strong>World</strong>!</p>\n"

console.log(parse("Foo *Bar*"));
// [
//   {
//     type: "startTag",
//     tag: "paragraph",
//   },
//   {
//     type: "text",
//     content: "Foo ",
//   },
//   {
//     type: "startTag",
//     tag: "emphasis",
//   },
//   {
//     type: "text",
//     content: "Bar",
//   },
//   {
//     type: "endTag",
//     tag: "emphasis",
//   },
//   {
//     type: "endTag",
//     tag: "paragraph",
//   },
// ],

Repo Structure

The files in the wasm directory are generated by build.ts, and contain the webassembly code, compressed and encoded into base64, alongside boilerplate js generated by wasm-bindgen for interacting with it. If you want to build it yourself, you will need to make sure you have wasm-bindgen-cli installed, and you are using the same version as the one in Cargo.toml.