JSPM

  • Created
  • Published
  • Downloads 815
  • Score
    100M100P100Q122046F
  • License MIT

Transforms MDAST to MDXAST

Package Exports

  • @mdx-js/mdxast

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@mdx-js/mdxast) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

@mdx-js/mdxast

Transforms MDAST to MDXAST.

Installation

npm i -S @mdx-js/mdxast

Usage

const unified = require('unified')
const remark = require('remark-parse')
const inspect = require('unist-util-inspect')
const toMDXAST = require('@mdx-js/mdxast')

const MDX = `
import { Foo } from 'bar'

# Hello, world!

<Foo />
`

const tree = unified()
  .use(remark)
  .parse(MDX)

const mdxast = toMDXAST(options)(tree)

console.log(inspect(mdxast))

Output

root[3] (1:1-7:1, 0-53)
├─ import: "import { Foo } from 'bar'" (2:1-2:26, 1-26)
├─ heading[1] (4:1-4:16, 28-43) [depth=1]
│  └─ text: "Hello, world!" (4:3-4:16, 30-43)
└─ jsx: "<Foo />" (6:1-6:8, 45-52)