Skip to content

web-alchemy/markdown-wasm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WebAssembly build of Rust lib pulldown-cmark for Node.js

Installation

npm install @web-alchemy/markdown-wasm

Usage example:

import { parse } from '@web-alchemy/markdown-wasm';

const markdownSource = `# title
  Some text
  
  ![some image alt](image.png)
`;

const html = parse(markdownSource);

console.log(html)
/*
<h1>title</h1>
  <p>Some text</p>
  <p><img src="image.png" alt="some image alt" /></p>
*/

Using non standard features

You can use additional (non CommonMark) features via Options. They work as bit masks.

import { parse, Flags } from '@web-alchemy/markdown-wasm';

const source = `# my todo list { #list-head-id .head-class }
- [x] check 1
- [x] check 2
- [ ] check 3
`;

const FLAGS = new Flags();
const flags = FLAGS.ENABLE_HEADING_ATTRIBUTES | FLAGS.ENABLE_TASKLISTS;
const html = parse(source, flags);
/*
<h1 id="list-head-id" class="head-class">my todo list</h1>
<ul>
  <li><input disabled="" type="checkbox" checked=""/>  check 1</li>
  <li><input disabled="" type="checkbox" checked=""/> check 2</li>
  <li><input disabled="" type="checkbox"/> check 3</li>
</ul>
*/

You can enable all feautures with FLAGS.ENABLE_ALL flag.

Benchmark

Results of benchmark (ops/s):

benchmark

Development

  • Install Node.js
  • Install dev dependencies - npm ci.
  • Modify source code in src folder and write tests in test folder.
  • Create build - node --run build. pkg folder should contains npm package files.
  • Run tests - node --run test.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published