remark-mdx
Advanced tools
Comparing version 2.0.0-next.8 to 2.0.0-next.9
52
index.js
'use strict' | ||
var parse = require('./lib/parse') | ||
var serialize = require('./lib/serialize') | ||
let syntaxMdx = require('micromark-extension-mdx') | ||
let syntaxMdxjs = require('micromark-extension-mdxjs') | ||
let fromMarkdown = require('mdast-util-mdx/from-markdown') | ||
let toMarkdown = require('mdast-util-mdx/to-markdown') | ||
let warningIssued | ||
module.exports = mdx | ||
// I think this is needed for webpack? 😔 | ||
mdx.default = mdx | ||
function mdx(options) { | ||
let settings = options || {} | ||
let syntax = settings.js === false ? syntaxMdx : syntaxMdxjs | ||
let data = this.data() | ||
function mdx() { | ||
var parser = this.Parser | ||
var compiler = this.Compiler | ||
if (isRemarkParser(parser)) { | ||
parse(parser) | ||
/* istanbul ignore next - old remark. */ | ||
if ( | ||
!warningIssued && | ||
((this.Parser && | ||
this.Parser.prototype && | ||
this.Parser.prototype.blockTokenizers) || | ||
(this.Compiler && | ||
this.Compiler.prototype && | ||
this.Compiler.prototype.visitors)) | ||
) { | ||
warningIssued = true | ||
console.warn( | ||
'[remark-mdx] Warning: please upgrade to remark 13 to use this plugin' | ||
) | ||
} | ||
if (isRemarkCompiler(compiler)) { | ||
serialize(compiler) | ||
add('micromarkExtensions', syntax(options)) | ||
add('fromMarkdownExtensions', fromMarkdown) | ||
add('toMarkdownExtensions', toMarkdown) | ||
function add(field, value) { | ||
/* istanbul ignore if - other extensions. */ | ||
if (data[field]) data[field].push(value) | ||
else data[field] = [value] | ||
} | ||
} | ||
function isRemarkParser(parser) { | ||
return Boolean(parser && parser.prototype && parser.prototype.blockTokenizers) | ||
} | ||
function isRemarkCompiler(compiler) { | ||
return Boolean(compiler && compiler.prototype && compiler.prototype.visitors) | ||
} |
{ | ||
"name": "remark-mdx", | ||
"version": "2.0.0-next.8", | ||
"version": "2.0.0-next.9", | ||
"description": "remark plugin to add support for mdx", | ||
@@ -20,3 +20,2 @@ "repository": "https://github.com/mdx-js/mdx/tree/master/packages/remark-mdx", | ||
"index.js", | ||
"lib/", | ||
"types/index.d.ts" | ||
@@ -37,21 +36,16 @@ ], | ||
"scripts": { | ||
"format": "remark . -qfo && prettier --write \"**/*.js\" && xo --fix", | ||
"test": "npm run format && npm run test-coverage", | ||
"test-api": "node test", | ||
"test-coverage": "nyc --reporter lcov tape test/index.js", | ||
"test-types": "dtslint types" | ||
"test-types": "dtslint types", | ||
"test": "yarn format && yarn test-coverage && yarn test-types" | ||
}, | ||
"dependencies": { | ||
"parse-entities": "^2.0.0", | ||
"remark-stringify": "^8.1.0", | ||
"stringify-entities": "^3.0.1", | ||
"strip-indent": "^3.0.0", | ||
"unist-util-stringify-position": "^2.0.3" | ||
"mdast-util-mdx": "^0.1.1", | ||
"micromark-extension-mdx": "^0.2.0", | ||
"micromark-extension-mdxjs": "^0.3.0" | ||
}, | ||
"devDependencies": { | ||
"nyc": "^15.1.0", | ||
"prettier": "^2.0.5", | ||
"remark-cli": "^8.0.0", | ||
"remark-parse": "^8.0.2", | ||
"remark-preset-wooorm": "^7.0.0", | ||
"remark-parse": "^9.0.0", | ||
"remark-stringify": "^9.0.1", | ||
"tape": "^5.0.1", | ||
@@ -61,3 +55,4 @@ "to-vfile": "^6.1.0", | ||
"unist-builder": "^2.0.3", | ||
"xo": "^0.32.1" | ||
"unist-util-remove-position": "^3.0.0", | ||
"unist-util-visit": "^2.0.0" | ||
}, | ||
@@ -70,27 +65,3 @@ "nyc": { | ||
}, | ||
"prettier": { | ||
"tabWidth": 2, | ||
"useTabs": false, | ||
"singleQuote": true, | ||
"bracketSpacing": false, | ||
"semi": false, | ||
"trailingComma": "none" | ||
}, | ||
"remarkConfig": { | ||
"plugins": [ | ||
"preset-wooorm" | ||
] | ||
}, | ||
"xo": { | ||
"prettier": true, | ||
"esnext": false, | ||
"rules": { | ||
"unicorn/no-fn-reference-in-iterator": "off", | ||
"unicorn/no-hex-escape": "off", | ||
"unicorn/escape-case": "off", | ||
"no-self-compare": "off", | ||
"no-lonely-if": "off" | ||
} | ||
}, | ||
"gitHead": "e194fc1a61715549be10d56055ea4ad25533fcb1" | ||
"gitHead": "6fc71ff94c671582b4185a98f87dcdb1d18c831b" | ||
} |
@@ -75,10 +75,10 @@ # remark-mdx | ||
{type: 'text', value: 'Hello, '}, | ||
{type: 'mdxSpanExpression', value: 'data.to'} | ||
{type: 'mdxTextExpression', value: 'data.to'} | ||
] | ||
}, | ||
{ | ||
type: 'mdxBlockElement', | ||
type: 'mdxJsxFlowElement', | ||
name: 'Body', | ||
attributes: [], | ||
children: [{type: 'mdxBlockExpression', value: 'message'}] | ||
children: [{type: 'mdxFlowExpression', value: 'message'}] | ||
}, | ||
@@ -89,3 +89,3 @@ { | ||
{type: 'text', value: 'Best, '}, | ||
{type: 'mdxSpanExpression', value: 'data.from'} | ||
{type: 'mdxTextExpression', value: 'data.from'} | ||
] | ||
@@ -165,5 +165,5 @@ } | ||
[chat-badge]: https://img.shields.io/badge/chat-spectrum-7b16ff.svg | ||
[chat-badge]: https://img.shields.io/badge/chat-discussions-success.svg | ||
[chat]: https://spectrum.chat/unified/remark | ||
[chat]: https://github.com/mdx-js/mdx/discussions | ||
@@ -170,0 +170,0 @@ [npm]: https://docs.npmjs.com/cli/install |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3
9
8137
5
42
1
+ Addedmdast-util-mdx@^0.1.1
+ Addedacorn@8.12.1(transitive)
+ Addedacorn-jsx@5.3.2(transitive)
+ Addeddebug@4.3.7(transitive)
+ Addedestree-util-is-identifier-name@1.1.0(transitive)
+ Addedmdast-util-mdx@0.1.1(transitive)
+ Addedmdast-util-mdx-expression@0.1.1(transitive)
+ Addedmdast-util-mdx-jsx@0.1.4(transitive)
+ Addedmdast-util-mdxjs-esm@0.1.1(transitive)
+ Addedmdast-util-to-markdown@0.6.5(transitive)
+ Addedmdast-util-to-string@2.0.0(transitive)
+ Addedmicromark@2.11.4(transitive)
+ Addedmicromark-extension-mdx@0.2.1(transitive)
+ Addedmicromark-extension-mdx-expression@0.3.2(transitive)
+ Addedmicromark-extension-mdx-jsx@0.3.3(transitive)
+ Addedmicromark-extension-mdx-md@0.1.1(transitive)
+ Addedmicromark-extension-mdxjs@0.3.0(transitive)
+ Addedmicromark-extension-mdxjs-esm@0.3.1(transitive)
+ Addedms@2.1.3(transitive)
+ Addedunist-util-remove-position@3.0.0(transitive)
+ Addedvfile-message@2.0.4(transitive)
+ Addedzwitch@1.0.5(transitive)
- Removedparse-entities@^2.0.0
- Removedremark-stringify@^8.1.0
- Removedstringify-entities@^3.0.1
- Removedstrip-indent@^3.0.0
- Removedunist-util-stringify-position@^2.0.3
- Removedccount@1.1.0(transitive)
- Removedinherits@2.0.4(transitive)
- Removedis-alphanumeric@1.0.0(transitive)
- Removedis-whitespace-character@1.0.4(transitive)
- Removedmarkdown-escapes@1.0.4(transitive)
- Removedmarkdown-table@2.0.0(transitive)
- Removedmdast-util-compact@2.0.1(transitive)
- Removedremark-stringify@8.1.1(transitive)
- Removedstate-toggle@1.0.3(transitive)
- Removedunherit@1.1.3(transitive)