markdown-ast-loader

0.1.4 • Public • Published

A webpack loader for Markdown files with optional front matter - that returns the markdown's AST.

Installation

npm install markdown-ast-loader

Usage

{
  module: {
    loaders: {
      {test: /\.md$/, loader: 'markdown-ast-loader'},
    ]
  }
}

The result of importing a markdown file will be a JavaScript object with properties from the front matter (as parsed by [js-yaml-front-matter]) and a ast property containing the markdown AST.

For example

---
name: Mongo the Monkey
contact:
email: monkeysdontuseemail@hzdg.com
---

I LIKE TO EAT BANANAS
=====================

* Fat bananas
* Skinny bananas
* Whatever

Renders to

{
  "name": "Mongo the Monkey",
  "contact": null,
  "email": "monkeysdontuseemail@hzdg.com",
  "ast": [
    {
      "type": "heading",
      "text": [
        "I LIKE TO EAT BANANAS"
      ],
      "level": 1,
      "raw": "I LIKE TO EAT BANANAS"
    },
    {
      "type": "list",
      "body": [
        {
          "type": "listitem",
          "text": [
            "Fat bananas"
          ]
        },
        {
          "type": "listitem",
          "text": [
            "Skinny bananas"
          ]
        },
        {
          "type": "listitem",
          "text": [
            "Whatever"
          ]
        }
      ],
      "ordered": false
    }
  ]
}

Package Sidebar

Install

npm i markdown-ast-loader

Weekly Downloads

1

Version

0.1.4

License

MIT

Last publish

Collaborators

  • jrhicks