rsms / markdown-wasm

Very fast Markdown parser and HTML generator implemented in WebAssembly, based on md4c
https://rsms.me/markdown-wasm/
MIT License
1.51k stars 62 forks source link

Deno support? #6

Closed linux-china closed 3 years ago

linux-china commented 3 years ago

Any plan to add Deno support for markdown-wasm, and Deno developer can use this module to render Markdown quickly.

Now I have following Deno typescript code, such as demo.ts

import * as markdown from "https://raw.githubusercontent.com/rsms/markdown-wasm/master/dist/markdown.es.js";
await markdown.ready
console.log(markdown.parse("# hello\n*world*"))

I got the error with deno run demo.ts

Download https://raw.githubusercontent.com/rsms/markdown-wasm/master/dist/markdown.es.js
Check file:///Users/xxxx/demo.ts
error: Uncaught ReferenceError: document is not defined
    at https://raw.githubusercontent.com/rsms/markdown-wasm/master/dist/markdown.es.js:1:1908

Is it possible to produce a js file for Deno? such as markdown.deno.js, and the code alike following:

import {parse} from "https://denopkg.com/rsms/markdown-wasm/dist/markdown.deno.js";
console.log(parse("# hello\n*world*"))
linux-china commented 3 years ago

I find a way to support Deno. Add deno build in wasmc.js:

module({ ...m,
  name:   "markdown-bundle-es",
  out:    outdir + "/markdown.bundle.es.js",
  embed:  true,
  format: "es",
})

then add `var document = {};' at the beginning of markdown.deno.js.

I made a demo here https://github.com/linux-china/markdown-wasm

rsms commented 3 years ago

Thanks! Please remember to add the license for markdown-wasm and md4c in your repo at https://github.com/linux-china/markdown-wasm since it's public :–)

Q: Did you close this issue by accident or did you change your mind? If the latter, care to elaborate?