Socket
Book a DemoInstallSign in
Socket

marked-lexer-loader

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

marked-lexer-loader

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

latest
Source
npmnpm
Version
2.0.0
Version published
Maintainers
1
Created
Source

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.

Keywords

Webpack

FAQs

Package last updated on 27 Jan 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts