marked-lexer-loader

2.0.0 • Public • Published

marked-lexer-loader

Accepts Markdown as input, and outputs a module exporting the lexed Markdown using marked.

This loader does not render Markdown to HTML. There are already several loaders that do. This loader is intended to be used for processing Markdown as an AST.

Usage

markdown-lexer-loader emits raw JSON, so you need to use json-loader in front of it in order to use the output in a JavaScript module.

module: {
  rules: [{
    test: /\.md$/,
    use: [
      'json-loader',
      {
        loader: 'markdown-lexer-loader',
        options: {
          // All options are passed to marked, merging with marked’s defaults:
          // https://github.com/chjj/marked#options-1
        }
      }
    ]
  }]
}

options are merged with marked’s default options and passed to marked.lexer(source, options).

See additional documentation on using loaders.

Example output

To give a better idea of what this loader does, the Markdown snippet

# Hello, world
This is some Markdown

turns into

{"nodes":[{"type":"heading","depth":1,"text":"Hello, world"},{"type":"paragraph","text":"This is some Markdown"}],"links":{}}

Testing & contributing

Tests are run with Jest:

npm install
npm test

Contributions are welcome! New features or bug fixes must include tests. Try to match existing code style, or better yet, add ESLint or Prettier to this project.

Package Sidebar

Install

npm i marked-lexer-loader

Weekly Downloads

0

Version

2.0.0

License

MIT

Last publish

Collaborators

  • andrewbranch