aleclarson / markdown-ast

Tiny markdown parser
MIT License
40 stars 2 forks source link

Incremental parsing #1

Open aleclarson opened 5 years ago

aleclarson commented 5 years ago

Nodes intentionally lack location properties, so they can be mutated, moved, and/or removed with minimal effort. Sometimes, this lack of information makes any code modifications harder to carry out. Transform phases would be much easier with "incremental parsing".

const md = require('markdown-ast')
const parser = md.generator(input)

// The `next` method returns null when EOF is hit.
while (parser.next()) {
  // The `next` method updates `node` and `offset`
  const {node, offset} = parser
}