Socket
Socket
Sign inDemoInstall

micromark-extension-mdx-jsx

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

micromark-extension-mdx-jsx - npm Package Compare versions

Comparing version 1.0.5 to 2.0.0

2

dev/lib/factory-tag.d.ts

@@ -72,3 +72,3 @@ /**

code: import('micromark-util-types').Code
) => void | import('micromark-util-types').State
) => import('micromark-util-types').State | undefined
export type Acorn = import('micromark-factory-mdx-expression').Acorn

@@ -75,0 +75,0 @@ export type AcornOptions =

@@ -11,3 +11,4 @@ /**

import {start as idStart, cont as idCont} from 'estree-util-is-identifier-name'
import {ok as assert} from 'devlop'
import {cont as idCont, start as idStart} from 'estree-util-is-identifier-name'
import {factoryMdxExpression} from 'micromark-factory-mdx-expression'

@@ -20,8 +21,7 @@ import {

} from 'micromark-util-character'
import {codes} from 'micromark-util-symbol/codes.js'
import {constants} from 'micromark-util-symbol/constants.js'
import {types} from 'micromark-util-symbol/types.js'
import {ok as assert} from 'uvu/assert'
import {codes, constants, types} from 'micromark-util-symbol'
import {VFileMessage} from 'vfile-message'
const trouble = 'https://github.com/micromark/micromark-extension-mdx-jsx'
/**

@@ -1050,7 +1050,10 @@ * @this {TokenizeContext}

if (!allowLazy && self.parser.lazy[self.now().line]) {
throw new VFileMessage(
const error = new VFileMessage(
'Unexpected lazy line in container, expected line to be prefixed with `>` when in a block quote, whitespace when in a list, etc',
self.now(),
'micromark-extension-mdx-jsx:unexpected-eof'
'micromark-extension-mdx-jsx:unexpected-lazy'
)
error.url =
trouble + '#unexpected-lazy-line-in-container-expected-line-to-be'
throw error
}

@@ -1069,3 +1072,3 @@

function crash(code, at, expect) {
throw new VFileMessage(
const error = new VFileMessage(
'Unexpected ' +

@@ -1089,2 +1092,8 @@ (code === codes.eof

)
error.url =
trouble +
(code === codes.eof
? '#unexpected-end-of-file-at-expected-expect'
: '#unexpected-character-at-expected-expect')
throw error
}

@@ -1091,0 +1100,0 @@ }

@@ -6,14 +6,8 @@ /**

* Acorn parser to use (optional).
* @param {AcornOptions | undefined} acornOptions
* Configuration for acorn.
* @param {boolean | undefined} addResult
* Whether to add `estree` fields to tokens with results from acorn.
* @param {Options} options
* Configuration.
* @returns {Construct}
* Construct.
*/
export function jsxFlow(
acorn: Acorn | undefined,
acornOptions: AcornOptions | undefined,
addResult: boolean | undefined
): Construct
export function jsxFlow(acorn: Acorn | undefined, options: Options): Construct
export type Acorn = import('micromark-factory-mdx-expression').Acorn

@@ -26,1 +20,14 @@ export type AcornOptions =

export type Tokenizer = import('micromark-util-types').Tokenizer
/**
* Configuration.
*/
export type Options = {
/**
* Acorn options.
*/
acornOptions: AcornOptions | undefined
/**
* Whether to add `estree` fields to tokens with results from acorn.
*/
addResult: boolean | undefined
}

@@ -10,7 +10,15 @@ /**

/**
* @typedef Options
* Configuration.
* @property {AcornOptions | undefined} acornOptions
* Acorn options.
* @property {boolean | undefined} addResult
* Whether to add `estree` fields to tokens with results from acorn.
*/
import {ok as assert} from 'devlop'
import {markdownLineEnding, markdownSpace} from 'micromark-util-character'
import {factorySpace} from 'micromark-factory-space'
import {codes} from 'micromark-util-symbol/codes.js'
import {types} from 'micromark-util-symbol/types.js'
import {ok as assert} from 'uvu/assert'
import {codes, types} from 'micromark-util-symbol'
import {factoryTag} from './factory-tag.js'

@@ -23,10 +31,8 @@

* Acorn parser to use (optional).
* @param {AcornOptions | undefined} acornOptions
* Configuration for acorn.
* @param {boolean | undefined} addResult
* Whether to add `estree` fields to tokens with results from acorn.
* @param {Options} options
* Configuration.
* @returns {Construct}
* Construct.
*/
export function jsxFlow(acorn, acornOptions, addResult) {
export function jsxFlow(acorn, options) {
return {tokenize: tokenizeJsxFlow, concrete: true}

@@ -84,4 +90,4 @@

acorn,
acornOptions,
addResult,
options.acornOptions,
options.addResult,
false,

@@ -88,0 +94,0 @@ 'mdxJsxFlowTag',

@@ -6,14 +6,8 @@ /**

* Acorn parser to use (optional).
* @param {AcornOptions | undefined} acornOptions
* Configuration for acorn.
* @param {boolean | undefined} addResult
* Whether to add `estree` fields to tokens with results from acorn.
* @param {Options} options
* Configuration.
* @returns {Construct}
* Construct.
*/
export function jsxText(
acorn: Acorn | undefined,
acornOptions: AcornOptions | undefined,
addResult: boolean | undefined
): Construct
export function jsxText(acorn: Acorn | undefined, options: Options): Construct
export type Acorn = import('micromark-factory-mdx-expression').Acorn

@@ -25,1 +19,14 @@ export type AcornOptions =

export type Tokenizer = import('micromark-util-types').Tokenizer
/**
* Configuration.
*/
export type Options = {
/**
* Acorn options.
*/
acornOptions: AcornOptions | undefined
/**
* Whether to add `estree` fields to tokens with results from acorn.
*/
addResult: boolean | undefined
}

@@ -9,2 +9,11 @@ /**

/**
* @typedef Options
* Configuration.
* @property {AcornOptions | undefined} acornOptions
* Acorn options.
* @property {boolean | undefined} addResult
* Whether to add `estree` fields to tokens with results from acorn.
*/
import {factoryTag} from './factory-tag.js'

@@ -17,10 +26,8 @@

* Acorn parser to use (optional).
* @param {AcornOptions | undefined} acornOptions
* Configuration for acorn.
* @param {boolean | undefined} addResult
* Whether to add `estree` fields to tokens with results from acorn.
* @param {Options} options
* Configuration.
* @returns {Construct}
* Construct.
*/
export function jsxText(acorn, acornOptions, addResult) {
export function jsxText(acorn, options) {
return {tokenize: tokenizeJsxText}

@@ -46,4 +53,4 @@

acorn,
acornOptions,
addResult,
options.acornOptions,
options.addResult,
true,

@@ -50,0 +57,0 @@ 'mdxJsxTextTag',

@@ -25,11 +25,10 @@ /**

* Configuration for acorn (default: `{ecmaVersion: 2020, locations: true,
* sourceType: 'module'}`).
*
* All fields except `locations` can be set.
* sourceType: 'module'}`); all fields except `locations` can be set.
*/
acornOptions?: AcornOptions | null | undefined
/**
* Whether to add `estree` fields to tokens with results from acorn.
* Whether to add `estree` fields to tokens with results from acorn
* (default: `false`).
*/
addResult?: boolean | null | undefined
}

@@ -14,10 +14,9 @@ /**

* Configuration for acorn (default: `{ecmaVersion: 2020, locations: true,
* sourceType: 'module'}`).
*
* All fields except `locations` can be set.
* sourceType: 'module'}`); all fields except `locations` can be set.
* @property {boolean | null | undefined} [addResult=false]
* Whether to add `estree` fields to tokens with results from acorn.
* Whether to add `estree` fields to tokens with results from acorn
* (default: `false`).
*/
import {codes} from 'micromark-util-symbol/codes.js'
import {codes} from 'micromark-util-symbol'
import {jsxText} from './jsx-text.js'

@@ -59,16 +58,14 @@ import {jsxFlow} from './jsx-flow.js'

flow: {
[codes.lessThan]: jsxFlow(
acorn || undefined,
[codes.lessThan]: jsxFlow(acorn || undefined, {
acornOptions,
settings.addResult || false
)
addResult: settings.addResult || undefined
})
},
text: {
[codes.lessThan]: jsxText(
acorn || undefined,
[codes.lessThan]: jsxText(acorn || undefined, {
acornOptions,
settings.addResult || false
)
addResult: settings.addResult || undefined
})
}
}
}

@@ -72,3 +72,3 @@ /**

code: import('micromark-util-types').Code
) => void | import('micromark-util-types').State
) => import('micromark-util-types').State | undefined
export type Acorn = import('micromark-factory-mdx-expression').Acorn

@@ -75,0 +75,0 @@ export type AcornOptions =

@@ -11,3 +11,3 @@ /**

import {start as idStart, cont as idCont} from 'estree-util-is-identifier-name'
import {cont as idCont, start as idStart} from 'estree-util-is-identifier-name'
import {factoryMdxExpression} from 'micromark-factory-mdx-expression'

@@ -21,2 +21,3 @@ import {

import {VFileMessage} from 'vfile-message'
const trouble = 'https://github.com/micromark/micromark-extension-mdx-jsx'

@@ -1013,7 +1014,10 @@ /**

if (!allowLazy && self.parser.lazy[self.now().line]) {
throw new VFileMessage(
const error = new VFileMessage(
'Unexpected lazy line in container, expected line to be prefixed with `>` when in a block quote, whitespace when in a list, etc',
self.now(),
'micromark-extension-mdx-jsx:unexpected-eof'
'micromark-extension-mdx-jsx:unexpected-lazy'
)
error.url =
trouble + '#unexpected-lazy-line-in-container-expected-line-to-be'
throw error
}

@@ -1031,3 +1035,3 @@ return esWhitespaceStart(code)

function crash(code, at, expect) {
throw new VFileMessage(
const error = new VFileMessage(
'Unexpected ' +

@@ -1049,2 +1053,8 @@ (code === null

)
error.url =
trouble +
(code === null
? '#unexpected-end-of-file-at-expected-expect'
: '#unexpected-character-at-expected-expect')
throw error
}

@@ -1051,0 +1061,0 @@ }

@@ -6,14 +6,8 @@ /**

* Acorn parser to use (optional).
* @param {AcornOptions | undefined} acornOptions
* Configuration for acorn.
* @param {boolean | undefined} addResult
* Whether to add `estree` fields to tokens with results from acorn.
* @param {Options} options
* Configuration.
* @returns {Construct}
* Construct.
*/
export function jsxFlow(
acorn: Acorn | undefined,
acornOptions: AcornOptions | undefined,
addResult: boolean | undefined
): Construct
export function jsxFlow(acorn: Acorn | undefined, options: Options): Construct
export type Acorn = import('micromark-factory-mdx-expression').Acorn

@@ -26,1 +20,14 @@ export type AcornOptions =

export type Tokenizer = import('micromark-util-types').Tokenizer
/**
* Configuration.
*/
export type Options = {
/**
* Acorn options.
*/
acornOptions: AcornOptions | undefined
/**
* Whether to add `estree` fields to tokens with results from acorn.
*/
addResult: boolean | undefined
}

@@ -10,2 +10,11 @@ /**

/**
* @typedef Options
* Configuration.
* @property {AcornOptions | undefined} acornOptions
* Acorn options.
* @property {boolean | undefined} addResult
* Whether to add `estree` fields to tokens with results from acorn.
*/
import {markdownLineEnding, markdownSpace} from 'micromark-util-character'

@@ -20,10 +29,8 @@ import {factorySpace} from 'micromark-factory-space'

* Acorn parser to use (optional).
* @param {AcornOptions | undefined} acornOptions
* Configuration for acorn.
* @param {boolean | undefined} addResult
* Whether to add `estree` fields to tokens with results from acorn.
* @param {Options} options
* Configuration.
* @returns {Construct}
* Construct.
*/
export function jsxFlow(acorn, acornOptions, addResult) {
export function jsxFlow(acorn, options) {
return {

@@ -83,4 +90,4 @@ tokenize: tokenizeJsxFlow,

acorn,
acornOptions,
addResult,
options.acornOptions,
options.addResult,
false,

@@ -87,0 +94,0 @@ 'mdxJsxFlowTag',

@@ -6,14 +6,8 @@ /**

* Acorn parser to use (optional).
* @param {AcornOptions | undefined} acornOptions
* Configuration for acorn.
* @param {boolean | undefined} addResult
* Whether to add `estree` fields to tokens with results from acorn.
* @param {Options} options
* Configuration.
* @returns {Construct}
* Construct.
*/
export function jsxText(
acorn: Acorn | undefined,
acornOptions: AcornOptions | undefined,
addResult: boolean | undefined
): Construct
export function jsxText(acorn: Acorn | undefined, options: Options): Construct
export type Acorn = import('micromark-factory-mdx-expression').Acorn

@@ -25,1 +19,14 @@ export type AcornOptions =

export type Tokenizer = import('micromark-util-types').Tokenizer
/**
* Configuration.
*/
export type Options = {
/**
* Acorn options.
*/
acornOptions: AcornOptions | undefined
/**
* Whether to add `estree` fields to tokens with results from acorn.
*/
addResult: boolean | undefined
}

@@ -9,2 +9,11 @@ /**

/**
* @typedef Options
* Configuration.
* @property {AcornOptions | undefined} acornOptions
* Acorn options.
* @property {boolean | undefined} addResult
* Whether to add `estree` fields to tokens with results from acorn.
*/
import {factoryTag} from './factory-tag.js'

@@ -17,10 +26,8 @@

* Acorn parser to use (optional).
* @param {AcornOptions | undefined} acornOptions
* Configuration for acorn.
* @param {boolean | undefined} addResult
* Whether to add `estree` fields to tokens with results from acorn.
* @param {Options} options
* Configuration.
* @returns {Construct}
* Construct.
*/
export function jsxText(acorn, acornOptions, addResult) {
export function jsxText(acorn, options) {
return {

@@ -48,4 +55,4 @@ tokenize: tokenizeJsxText

acorn,
acornOptions,
addResult,
options.acornOptions,
options.addResult,
true,

@@ -52,0 +59,0 @@ 'mdxJsxTextTag',

@@ -25,11 +25,10 @@ /**

* Configuration for acorn (default: `{ecmaVersion: 2020, locations: true,
* sourceType: 'module'}`).
*
* All fields except `locations` can be set.
* sourceType: 'module'}`); all fields except `locations` can be set.
*/
acornOptions?: AcornOptions | null | undefined
/**
* Whether to add `estree` fields to tokens with results from acorn.
* Whether to add `estree` fields to tokens with results from acorn
* (default: `false`).
*/
addResult?: boolean | null | undefined
}

@@ -14,7 +14,6 @@ /**

* Configuration for acorn (default: `{ecmaVersion: 2020, locations: true,
* sourceType: 'module'}`).
*
* All fields except `locations` can be set.
* sourceType: 'module'}`); all fields except `locations` can be set.
* @property {boolean | null | undefined} [addResult=false]
* Whether to add `estree` fields to tokens with results from acorn.
* Whether to add `estree` fields to tokens with results from acorn
* (default: `false`).
*/

@@ -60,16 +59,14 @@

flow: {
[60]: jsxFlow(
acorn || undefined,
[60]: jsxFlow(acorn || undefined, {
acornOptions,
settings.addResult || false
)
addResult: settings.addResult || undefined
})
},
text: {
[60]: jsxText(
acorn || undefined,
[60]: jsxText(acorn || undefined, {
acornOptions,
settings.addResult || false
)
addResult: settings.addResult || undefined
})
}
}
}
{
"name": "micromark-extension-mdx-jsx",
"version": "1.0.5",
"version": "2.0.0",
"description": "micromark extension to support MDX or MDX.js JSX",

@@ -31,4 +31,6 @@ "license": "MIT",

"type": "module",
"main": "index.js",
"types": "index.d.ts",
"exports": {
"development": "./dev/index.js",
"default": "./index.js"
},
"files": [

@@ -40,17 +42,13 @@ "dev/",

],
"exports": {
"development": "./dev/index.js",
"default": "./index.js"
},
"dependencies": {
"@types/acorn": "^4.0.0",
"@types/estree": "^1.0.0",
"devlop": "^1.0.0",
"estree-util-is-identifier-name": "^2.0.0",
"micromark-factory-mdx-expression": "^1.0.0",
"micromark-factory-space": "^1.0.0",
"micromark-util-character": "^1.0.0",
"micromark-util-symbol": "^1.0.0",
"micromark-util-types": "^1.0.0",
"uvu": "^0.5.0",
"vfile-message": "^3.0.0"
"micromark-factory-mdx-expression": "^2.0.0",
"micromark-factory-space": "^2.0.0",
"micromark-util-character": "^2.0.0",
"micromark-util-symbol": "^2.0.0",
"micromark-util-types": "^2.0.0",
"vfile-message": "^4.0.0"
},

@@ -64,7 +62,7 @@ "devDependencies": {

"acorn-jsx": "^5.0.0",
"c8": "^7.0.0",
"c8": "^8.0.0",
"estree-util-visit": "^1.0.0",
"mdast-zone": "^5.0.0",
"micromark": "^3.0.0",
"micromark-build": "^1.0.0",
"micromark": "^4.0.0",
"micromark-build": "^2.0.0",
"prettier": "^2.0.0",

@@ -88,19 +86,12 @@ "remark-cli": "^11.0.0",

"prettier": {
"tabWidth": 2,
"useTabs": false,
"singleQuote": true,
"bracketSpacing": false,
"semi": false,
"trailingComma": "none"
"singleQuote": true,
"tabWidth": 2,
"trailingComma": "none",
"useTabs": false
},
"xo": {
"prettier": true,
"rules": {
"n/file-extension-in-import": "off",
"unicorn/no-this-assignment": "off"
}
},
"remarkConfig": {
"plugins": [
"preset-wooorm",
"remark-preset-wooorm",
"./script/grammar.js"

@@ -112,5 +103,11 @@ ]

"detail": true,
"strict": true,
"ignoreCatch": true
"ignoreCatch": true,
"strict": true
},
"xo": {
"prettier": true,
"rules": {
"unicorn/no-this-assignment": "off"
}
}
}

@@ -27,2 +27,3 @@ # micromark-extension-mdx-jsx

* [Unexpected character $at, expected $expect](#unexpected-character-at-expected-expect)
* [Unexpected lazy line in container, expected line to be…](#unexpected-lazy-line-in-container-expected-line-to-be)
* [Tokens](#tokens)

@@ -75,3 +76,3 @@ * [Types](#types)

```js
import {mdxJsx} from 'https://esm.sh/micromark-extension-mdx-jsx@1'
import {mdxJsx} from 'https://esm.sh/micromark-extension-mdx-jsx@2'
```

@@ -83,3 +84,3 @@

<script type="module">
import {mdxJsx} from 'https://esm.sh/micromark-extension-mdx-jsx@1?bundle'
import {mdxJsx} from 'https://esm.sh/micromark-extension-mdx-jsx@2?bundle'
</script>

@@ -161,3 +162,3 @@ ```

```jsx
```mdx-invalid
<hi/*comment!*//>

@@ -170,3 +171,3 @@ <hello// comment!

```jsx
```mdx
<hi/>

@@ -187,3 +188,3 @@ <hello

```jsx
```mdx-invalid
<welcome name=<>Venus</> />

@@ -195,3 +196,3 @@ <welcome name=<span>Pluto</span> />

```jsx
```mdx
<welcome name='Mars' />

@@ -309,3 +310,3 @@ <welcome name={<span>Jupiter</span>} />

```markdown
```mdx-invalid
<

@@ -332,3 +333,3 @@ </

```markdown
```mdx-invalid
<.>

@@ -345,2 +346,13 @@ </.>

### Unexpected lazy line in container, expected line to be…
This error occurs if a `<` was seen in a container which then has lazy content
(source: `micromark-extension-mdx-jsx`, rule id: `unexpected-lazy`).
For example:
```mdx-invalid
> <a
b>
```
## Tokens

@@ -424,9 +436,12 @@

Projects maintained by the unified collective are compatible with all maintained
Projects maintained by the unified collective are compatible with maintained
versions of Node.js.
As of now, that is Node.js 16+.
Our projects sometimes work with older versions, but this is not guaranteed.
These extensions work with `micromark` version 3+.
When we cut a new major release, we drop support for unmaintained versions of
Node.
This means we try to keep the current release line,
`micromark-extension-mdx-jsx@^2`, compatible with Node.js 16.
This package works with `micromark` version `3` and later.
## Security

@@ -473,5 +488,5 @@

[size-badge]: https://img.shields.io/bundlephobia/minzip/micromark-extension-mdx-jsx.svg
[size-badge]: https://img.shields.io/badge/dynamic/json?label=minzipped%20size&query=$.size.compressedSize&url=https://deno.bundlejs.com/?q=micromark-extension-mdx-jsx
[size]: https://bundlephobia.com/result?p=micromark-extension-mdx-jsx
[size]: https://bundlejs.com/?q=micromark-extension-mdx-jsx

@@ -496,7 +511,7 @@ [sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg

[contributing]: https://github.com/micromark/.github/blob/HEAD/contributing.md
[contributing]: https://github.com/micromark/.github/blob/main/contributing.md
[support]: https://github.com/micromark/.github/blob/HEAD/support.md
[support]: https://github.com/micromark/.github/blob/main/support.md
[coc]: https://github.com/micromark/.github/blob/HEAD/code-of-conduct.md
[coc]: https://github.com/micromark/.github/blob/main/code-of-conduct.md

@@ -503,0 +518,0 @@ [esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc