This package has been deprecated

Author message:

Renamed to @mapbox/babel-plugin-transform-jsxtreme-markdown

@mapbox/babel-plugin-transform-md-react

0.1.0 • Public • Published

babel-plugin-transform-md-react

Build Status

🚧 🚧 EXPERIMENTAL! WORK IN PROGRESS! 🚧 🚧

Transform Markdown interpolated with JS expressions and JSX elements into pure JSX, at compile time.

Uses md-react-transformer to compile the interpolated Markdown.

Usage

Transforms a special [tagged template literal] (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#Tagged_template_literals).

require or import 'babel-plugin-transform-md-react/md', or whatever you've specified as packageName in your Babel options. Then use that value as a template literal tag, marking the template literals you'd like to be compiled at run time.

// Input
const md = require('babel-plugin-transform-md-react/md');
const foo = md`
  # Title
  This is **bold.**
  Here is a [link](/some/url).
`;

// Output
'use strict';

var foo = <div>
  <h1>Title</h1>
  <p>This is <strong>bold.</strong>
    Here is a <a href="/some/url">link</a>.</p>
</div>;

Because this plugin uses md-react-transformer, you can also interpolate JS expressions and JSX elements within special delimiters. Read more about this in the md-react-transformer docs.

// Input
const md = require('babel-plugin-transform-md-react/md');
const text = md`
  This is a paragraph {# <span className="foo"> #} with a **markdown** span inside {# </span> #}
  {# <div style={{ margin: 70 }}> #}
    And here is a *paragraph* inside a div.
    [Link](/some/url)
  {# </div> #}
`;

// Output
'use strict';

var text = <div>
  <p>This is a paragraph <span className="foo"> with a <strong>markdown</strong> span inside </span></p>
  <div style={{ margin: 70 }}>
    And here is a <em>paragraph</em> inside a div.
    <a href="/some/url">Link</a>
  </div>
</div>;

Options

You can pass any of the options available to mdReactTransformer.mdToJsx.

Additional options:

  • packageName ?string - Default: 'babel-plugin-transform-md-react/md'. The name of the package that you will require or import to use this thing.

Package Sidebar

Install

npm i @mapbox/babel-plugin-transform-md-react

Weekly Downloads

0

Version

0.1.0

License

MIT

Last publish

Collaborators

  • mbx-npm-ci-production
  • mbx-npm-ci-staging
  • mbx-npm-advanced-actions-production
  • mbx-npm-advanced-actions-staging
  • mbx-npm-09-production
  • mbx-npm-08-production
  • mbx-npm-07-production
  • mbx-npm-06-production
  • mbx-npm-05-production
  • mbx-npm-04-production
  • mbx-npm-03-production
  • mbx-npm-02-production
  • mbx-npm-01-production
  • mbx-npm-02-staging
  • mapbox-npm-01
  • mapbox-npm-02
  • mapbox-npm-07
  • mapbox-npm-03
  • mapbox-npm-04
  • mapbox-npm-09
  • mapbox-npm-05
  • mapbox-npm-06
  • mapbox-npm-08
  • mapbox-npm-advanced-actions
  • mapbox-npm-ci
  • mapbox-npm
  • mapbox-admin
  • mapbox-machine-user