Skip to content
This repository was archived by the owner on Oct 8, 2020. It is now read-only.

andrewbranch/marked-lexer-loader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

module: {
  rules: [{
    test: /\.md$/,
    use: {
      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

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

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.

About

A Webpack loader that uses marked to lex Markdown input and exports the lexer output.

Resources

Stars

Watchers

Forks

Packages

No packages published