Skip to content

v0.2.0

Latest
Compare
Choose a tag to compare
@ije ije released this 21 Feb 18:51
· 24 commits to main since this release

md4w now provides two webassembly binary files:

  • md4w-fast.wasm: Faster but larger binary file. (270KB gzipped)
  • md4w-small.wasm: Smaller but slower binary file. (27KB gzipped)

By default, md4w uses the md4w-fast.wasm binary from file system, uses the md4w-small.wasm binary from CDN. You can also specify the wasm file by adding the wasmMode option.

import { init } from "md4w";

init("fast"); // or "small"

Other changes:

  • Add mdToJSON function to parse markdown to JSON (#4)
    const traverse = (node) => {
      // text node
      if (typeof node === "string") {
        console.log(node);
        return;
      }
    
      // element type
      console.log(node.type);
    
      // element attributes (may be undefined)
      console.log(node.props);
    
      // element children (may be undefined)
      node.children?.forEach(traverse);
    };
    
    const tree = mdToJSON("Stay _foolish_, stay **hungry**!");
    traverse(tree);
  • Fix html/url escaping
  • Fix code block highlighting by lines