remark-mdx
remark plugin to add support for mdx
Last updated 4 years ago by johno .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install remark-mdx 
SYNC missed versions from official npm registry.

remark-mdx

Build Downloads Size Sponsors Backers Chat

remark plugin to support MDX (Markdown 💛 JSX).

This isn’t useful on its own, you’ll probably want to do combine it with other plugins or do tree traversal yourself to compile to things!

It’s used in MDXjs.

Install

npm:

npm install remark-mdx

Use

Say we have the following file, example.md:

# Hello, {data.to}

<Body>
{message}
</Body>

Best, {data.from}

And our script, example.js, looks as follows:

var vfile = require('to-vfile')
var report = require('vfile-reporter')
var unified = require('unified')
var parse = require('remark-parse')
var stringify = require('remark-stringify')
var mdx = require('remark-mdx')

unified()
  .use(parse, {position: false})
  .use(stringify)
  .use(mdx)
  .use(debug)
  .process(vfile.readSync('example.md'), function (err, file) {
    if (err) throw err
    console.log(String(file))
  })

function debug() {
  return console.dir
}

Now, running node example yields:

{
  type: 'root',
  children: [
    {
      type: 'heading',
      depth: 1,
      children: [
        {type: 'text', value: 'Hello, '},
        {type: 'mdxSpanExpression', value: 'data.to'}
      ]
    },
    {
      type: 'mdxBlockElement',
      name: 'Body',
      attributes: [],
      children: [{type: 'mdxBlockExpression', value: 'message'}]
    },
    {
      type: 'paragraph',
      children: [
        {type: 'text', value: 'Best, '},
        {type: 'mdxSpanExpression', value: 'data.from'}
      ]
    }
  ]
}
# Hello, {data.to}

<Body>
  {
    message
  }
</Body>

Best, {data.from}

API

remark().use(mdx[, options])

Plugin to add support for MDX.

Security

Use of remark-mdx does not involve rehype (hast) or user content so there are no openings for cross-site scripting (XSS) attacks.

Related

Contribute

See the Support and Contributing guidelines on the MDX website for ways to (get) help.

This project has a code of conduct. By interacting with this repository, organization, or community you agree to abide by its terms.

License

MIT © Titus Wormer

Current Tags

  • 2.0.0-ci.50                                ...           ci (3 years ago)
  • 3.1.0                                ...           latest (a month ago)
  • 2.0.0-rc.2                                ...           next (3 years ago)

126 Versions

  • 3.1.0                                ...           a month ago
  • 3.0.1                                ...           9 months ago
  • 3.0.0                                ...           a year ago
  • 2.3.0                                ...           2 years ago
  • 2.2.1                                ...           2 years ago
  • 2.2.0                                ...           2 years ago
  • 2.1.5                                ...           2 years ago
  • 2.1.4                                ...           2 years ago
  • 2.1.3                                ...           2 years ago
  • 2.1.2                                ...           2 years ago
  • 2.1.1                                ...           3 years ago
  • 2.1.0                                ...           3 years ago
  • 2.0.0                                ...           3 years ago
  • 2.0.0-rc.2                                ...           3 years ago
  • 2.0.0-rc.1                                ...           3 years ago
  • 2.0.0-ci.50                                ...           3 years ago
  • 2.0.0-ci.43                                ...           3 years ago
  • 2.0.0-ci.42                                ...           3 years ago
  • 2.0.0-ci.40                                ...           3 years ago
  • 2.0.0-ci.39                                ...           3 years ago
  • 2.0.0-ci.35                                ...           3 years ago
  • 2.0.0-ci.18                                ...           3 years ago
  • 2.0.0-ci.4                                ...           4 years ago
  • 2.0.0-next.9                                ...           4 years ago
  • 1.6.22                                ...           4 years ago
  • 1.6.21                                ...           4 years ago
  • 1.6.20                                ...           4 years ago
  • 1.6.19                                ...           4 years ago
  • 2.0.0-next.8                                ...           4 years ago
  • 1.6.18                                ...           4 years ago
  • 1.6.17                                ...           4 years ago
  • 2.0.0-next.7                                ...           4 years ago
  • 1.6.16                                ...           4 years ago
  • 1.6.15                                ...           4 years ago
  • 2.0.0-next.6                                ...           4 years ago
  • 2.0.0-next.5                                ...           4 years ago
  • 1.6.14                                ...           4 years ago
  • 2.0.0-next.4                                ...           4 years ago
  • 1.6.13-ci.1                                ...           4 years ago
  • 1.6.13                                ...           4 years ago
  • 1.6.12-ci.2                                ...           4 years ago
  • 1.6.12                                ...           4 years ago
  • 2.0.0-next.3                                ...           4 years ago
  • 1.6.11                                ...           4 years ago
  • 1.6.10                                ...           4 years ago
  • 1.6.9                                ...           4 years ago
  • 1.6.8                                ...           4 years ago
  • 1.6.8-ci.4                                ...           4 years ago
  • 1.6.7                                ...           4 years ago
  • 1.6.7-ci.4                                ...           4 years ago
  • 1.6.6                                ...           4 years ago
  • 1.6.5                                ...           4 years ago
  • 2.0.0-next.1                                ...           4 years ago
  • 1.6.4                                ...           4 years ago
  • 2.0.0-next.0                                ...           4 years ago
  • 1.6.3                                ...           4 years ago
  • 1.6.2                                ...           4 years ago
  • 1.6.1                                ...           5 years ago
  • 1.6.0                                ...           5 years ago
  • 1.5.9                                ...           5 years ago
  • 1.5.9-ci.5                                ...           5 years ago
  • 1.5.8                                ...           5 years ago
  • 1.5.8-ci.13                                ...           5 years ago
  • 1.5.8-alpha.0                                ...           5 years ago
  • 1.5.7                                ...           5 years ago
  • 1.5.7-alpha.0                                ...           5 years ago
  • 1.5.6                                ...           5 years ago
  • 1.5.6-alpha.0                                ...           5 years ago
  • 1.5.6-ci.0                                ...           5 years ago
  • 1.5.5                                ...           5 years ago
  • 1.5.4                                ...           5 years ago
  • 1.5.3                                ...           5 years ago
  • 1.5.2                                ...           5 years ago
  • 1.5.1                                ...           5 years ago
  • 1.5.0                                ...           5 years ago
  • 1.4.5                                ...           5 years ago
  • 1.4.4                                ...           5 years ago
  • 1.4.3                                ...           5 years ago
  • 1.4.2                                ...           5 years ago
  • 1.4.1                                ...           5 years ago
  • 1.4.0                                ...           5 years ago
  • 1.3.2                                ...           5 years ago
  • 1.3.1                                ...           5 years ago
  • 1.3.0                                ...           5 years ago
  • 1.2.2                                ...           5 years ago
  • 1.2.1                                ...           5 years ago
  • 1.1.6                                ...           5 years ago
  • 1.1.5                                ...           5 years ago
  • 1.1.4                                ...           5 years ago
  • 1.1.2                                ...           5 years ago
  • 1.1.1                                ...           5 years ago
  • 1.1.0                                ...           5 years ago
  • 1.0.26                                ...           5 years ago
  • 1.0.25                                ...           5 years ago
  • 1.0.23                                ...           5 years ago
  • 1.0.22                                ...           5 years ago
  • 1.0.21                                ...           5 years ago
  • 1.0.20                                ...           5 years ago
  • 1.0.18                                ...           6 years ago
  • 1.0.15                                ...           6 years ago
  • 1.0.14                                ...           6 years ago
  • 1.0.8                                ...           6 years ago
  • 1.0.2                                ...           6 years ago
  • 1.0.1                                ...           6 years ago
  • 1.0.0-rc.4                                ...           6 years ago
  • 1.0.0-rc.3                                ...           6 years ago
  • 1.0.0-rc.2                                ...           6 years ago
  • 1.0.0-rc.0                                ...           6 years ago
  • 1.0.0-alpha.13                                ...           6 years ago
  • 1.0.0-alpha.11                                ...           6 years ago
  • 1.0.0-alpha.10                                ...           6 years ago
  • 1.0.0-alpha.8                                ...           6 years ago
  • 1.0.0-alpha.6                                ...           6 years ago
  • 1.0.0-alpha.5                                ...           6 years ago
  • 1.0.0-alpha.2                                ...           6 years ago
  • 1.0.0-alpha.1                                ...           6 years ago
  • 0.20.3                                ...           6 years ago
  • 1.0.0-alpha.0                                ...           6 years ago
  • 0.18.2                                ...           6 years ago
  • 0.18.0                                ...           6 years ago
  • 0.17.5                                ...           6 years ago
  • 0.17.4                                ...           6 years ago
  • 0.17.3                                ...           6 years ago
  • 0.17.2                                ...           6 years ago
  • 0.17.1                                ...           6 years ago
  • 0.17.0                                ...           6 years ago
Downloads
Total 1
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 1
Dev Dependencies (10)

© 2010 - cnpmjs.org x YWFE | Home | YWFE