0.1.4 • Published 8 years ago

markdown-ast-loader v0.1.4

Weekly downloads
3
License
MIT
Repository
github
Last release
8 years ago

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
    }
  ]
}