Gathering detailed insights and metrics for micromark-extension-mdx-jsx
Gathering detailed insights and metrics for micromark-extension-mdx-jsx
Gathering detailed insights and metrics for micromark-extension-mdx-jsx
Gathering detailed insights and metrics for micromark-extension-mdx-jsx
micromark-extension-mdxjs
micromark extension to support MDX.js
micromark-extension-mdx
micromark extension to support MDX (agnostic to JavaScript)
@astrojs/micromark-extension-mdx-jsx
Less strict version of micromark-extension-mdx-jsx.
@hellomouse/micromark-extension-mdx-jsx
micromark extension to support MDX or MDX.js JSX
micromark extension to support MDX or MDX.js JSX
npm install micromark-extension-mdx-jsx
Typescript
Module System
Node Version
NPM Version
98.3
Supply Chain
99.6
Quality
77.7
Maintenance
100
Vulnerability
100
License
JavaScript (100%)
Total Downloads
193,210,330
Last Day
124,885
Last Week
2,289,692
Last Month
9,857,403
Last Year
92,394,590
MIT License
9 Stars
112 Commits
4 Forks
6 Watchers
1 Branches
11 Contributors
Updated on Mar 24, 2025
Minified
Minified + Gzipped
Latest Version
3.0.2
Package Id
micromark-extension-mdx-jsx@3.0.2
Unpacked Size
108.11 kB
Size
16.45 kB
File Count
31
NPM Version
11.2.0
Node Version
23.9.0
Published on
Mar 24, 2025
Cumulative downloads
Total Downloads
Last Day
-11%
124,885
Compared to previous day
Last Week
-7.2%
2,289,692
Compared to previous week
Last Month
2.8%
9,857,403
Compared to previous month
Last Year
68.1%
92,394,590
Compared to previous year
10
micromark extension to support MDX JSX
(<Component />
).
This package contains an extension that adds support for the JSX syntax enabled
by MDX to micromark
.
These extensions are used inside MDX.
It mostly matches how JSX works in most places that support it
(TypeScript, Babel, esbuild, SWC, etc).
This package can be made aware or unaware of JavaScript syntax. When unaware, expressions could include Rust or variables or whatnot.
This project is useful when you want to support JSX in markdown.
You can use this extension when you are working with
micromark
.
To support all MDX features,
use micromark-extension-mdxjs
instead.
When you need a syntax tree,
combine this package with mdast-util-mdx-jsx
.
All these packages are used in remark-mdx
,
which focusses on making it easier to transform content by abstracting these
internals away.
When you are using mdx-js/mdx
,
all of this is already included.
This package is ESM only. In Node.js (version 16+), install with npm:
1npm install micromark-extension-mdx-jsx
In Deno with esm.sh
:
1import {mdxJsx} from 'https://esm.sh/micromark-extension-mdx-jsx@2'
In browsers with esm.sh
:
1<script type="module"> 2 import {mdxJsx} from 'https://esm.sh/micromark-extension-mdx-jsx@2?bundle' 3</script>
1import {micromark} from 'micromark' 2import {mdxJsx} from 'micromark-extension-mdx-jsx' 3 4const output = micromark('a <b c d="e" /> f', {extensions: [mdxJsx()]}) 5 6console.log(output)
Yields:
1<p>a f</p>
…which is useless:
go to a syntax tree with
mdast-util-from-markdown
and
mdast-util-mdx-jsx
instead.
This package exports the identifier mdxJsx
.
There is no default export.
The export map supports the development
condition.
Run node --conditions development module.js
to get instrumented dev code.
Without this condition,
production code is loaded.
mdxJsx(options?)
Create an extension for micromark
to enable MDX JSX syntax.
options
(Options
, optional)
— configurationExtension for micromark
that can be passed in extensions
to enable MDX
JSX syntax (Extension
).
Options
Configuration (TypeScript type).
acorn
(Acorn
, optional)
— acorn parser to useacornOptions
(AcornOptions
,
default:
{ecmaVersion: 2024, locations: true, sourceType: 'module'}
)
— configuration for acorn;
all fields except locations
can be setaddResult
(boolean
, default: false
)
— whether to add estree
fields to tokens with results from acornWhen authoring markdown with JSX, keep in mind that MDX is a whitespace sensitive and line-based language, while JavaScript is insensitive to whitespace. This affects how markdown and JSX interleave with eachother in MDX. For more info on how it works, see § Interleaving on the MDX site.
JavaScript comments in JSX are not supported.
Incorrect:
1<hi/*comment!*//> 2<hello// comment! 3/>
Correct:
1<hi/> 2<hello 3/>
A PR that adds support for them would be accepted.
JSX elements or JSX fragments as attribute values are not supported. The reason for this change is that it would be confusing whether markdown would work.
Incorrect:
1<welcome name=<>Venus</> /> 2<welcome name=<span>Pluto</span> />
Correct:
1<welcome name='Mars' /> 2<welcome name={<span>Jupiter</span>} />
>
) and right curly brace (}
)JSX does not allow U+003E GREATER THAN (>
) or U+007D RIGHT CURLY BRACE
(}
) literally in text,
they need to be encoded as character references
(or expressions).
There is no good reason for this (some JSX parsers agree with us and don’t
crash either).
Therefore,
in MDX,
U+003E GREATER THAN (>
) and U+007D RIGHT CURLY BRACE (}
) are fine literally
and don’t need to be encoded.
JSX forms with the following BNF:
mdx_jsx_flow ::= mdx_jsx *space_or_tab [mdx_jsx *space_or_tab]
mdx_jsx_text ::= mdx_jsx
; constraint: markdown whitespace (`space_or_tab | eol`) is NOT
; allowed directly after `<` in order to allow `1 < 3` in markdown.
mdx_jsx ::=
'<' [closing]
[*whitespace name [attributes_after_identifier] [closing]]
*whitespace '>'
attributes_after_identifier ::=
1*whitespace (attributes_boolean | attributes_value) |
*whitespace attributes_expression |
attributes_after_value ::=
*whitespace (attributes_boolean | attributes_expression | attributes_value)
attributes_boolean ::= key [attributes_after_identifier]
; Note: in gnostic mode the value of the expression must instead be a single valid ES spread
; expression
attributes_expression ::= expression [attributes_after_value]
attributes_value ::= key initializer [attributes_after_value]
closing ::= *whitespace '/'
name ::= identifier [local | members]
key ::= identifier [local]
local ::= *whitespace ':' *whitespace identifier
members ::= member *member
member ::= *whitespace '.' *whitespace identifier
identifier ::= identifier_start *identifier_part
initializer ::= *whitespace '=' *whitespace value
value ::= double_quoted | single_quoted | expression
; Note: in gnostic mode the value must instead be a single valid ES expression
expression ::= '{' *(expression_text | expression) '}'
double_quoted ::= '"' *double_quoted_text '"'
single_quoted ::= "'" *single_quoted_text "'"
whitespace ::= es_whitespace
double_quoted_text ::= char - '"'
single_quoted_text ::= char - "'"
expression_text ::= char - '{' - '}'
identifier_start ::= es_identifier_start
identifier_part ::= es_identifier_part | '-'
space_or_tab ::= '\t' | ' '
eol ::= '\n' | '\r' | '\r\n'
; ECMAScript
; See “IdentifierStart”: <https://tc39.es/ecma262/#prod-IdentifierStart>
es_identifier_start ::= ?
; See “IdentifierPart”: <https://tc39.es/ecma262/#prod-IdentifierPart>
es_identifier_part ::= ?
; See “Whitespace”: <https://tc39.es/ecma262/#prod-WhiteSpace>
es_whitespace ::= ?
As the flow construct occurs in flow, like all flow constructs, it must be followed by an eol (line ending) or eof (end of file).
The grammar for JSX in markdown is much stricter than that of HTML in markdown. The primary benefit of this is that tags are parsed into tokens, and thus can be processed. Another, arguable, benefit of this is that it comes with syntax errors: if an author types something that is nonsensical, an error is thrown with information about where it happened, what occurred, and what was expected instead.
This extension supports expressions both aware and unaware to JavaScript (respectively gnostic and agnostic). Depending on whether acorn is passed, either valid JavaScript must be used in expressions, or arbitrary text (such as Rust code or so) can be used.
More on this can be found in
§ Syntax of micromark-extension-mdx-expression
.
In aware (gnostic) mode,
expressions are parsed with
micromark-extension-mdx-expression
,
which throws some more errors.
This error occurs for many different reasons if something was opened but not
closed
(source: micromark-extension-mdx-jsx
, rule id: unexpected-eof
).
Some examples are:
1< 2</ 3<a 4<a: 5<a. 6<a b 7<a b: 8<a b= 9<a b=" 10<a b=' 11<a b={ 12<a/
This error occurs for many different reasons if an unexpected character is seen
(source: micromark-extension-mdx-jsx
, rule id: unexpected-character
).
Some examples are:
1<.> 2</.> 3<a?> 4<a:+> 5<a./> 6<a b!> 7<a b:1> 8<a b=> 9<a/->
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:
1> <a 2b>
Many tokens are used:
mdxJsxFlowTag
for the whole JSX tag (<a>
)mdxJsxTextTag
^mdxJsxFlowTagMarker
for the tag markers (<
, >
)mdxJsxTextTagMarker
^mdxJsxFlowTagClosingMarker
for the /
marking a closing tag (</a>
)mdxJsxTextTagClosingMarker
^mdxJsxFlowTagSelfClosingMarker
for the /
marking a self-closing tag
(<a/>
)mdxJsxTextTagSelfClosingMarker
^mdxJsxFlowTagName
for the whole tag name (a:b
in <a:b>
)mdxJsxTextTagName
^mdxJsxFlowTagNamePrimary
for the first name (a
in <a:b>
)mdxJsxTextTagNamePrimary
^mdxJsxFlowTagNameMemberMarker
for the .
marking in members (<a.b>
)mdxJsxTextTagNameMemberMarker
^mdxJsxFlowTagNameMember
for member names (b
in <a:b>
)mdxJsxTextTagNameMember
^mdxJsxFlowTagNamePrefixMarker
for the :
between primary and local
(<a:b>
)mdxJsxTextTagNamePrefixMarker
^mdxJsxFlowTagNameLocal
for the local name (b
in <a:b>
)mdxJsxTextTagNameLocal
^mdxJsxFlowTagExpressionAttribute
for whole expression attributes
(<a {...b}>
)mdxJsxTextTagExpressionAttribute
^mdxJsxFlowTagExpressionAttributeMarker
for {
, }
in expression
attributesmdxJsxTextTagExpressionAttributeMarker
^mdxJsxFlowTagExpressionAttributeValue
for chunks of what’s inside
expression attributesmdxJsxTextTagExpressionAttributeValue
^mdxJsxFlowTagAttribute
for a whole normal attribute (<a b>
)mdxJsxTextTagAttribute
^mdxJsxFlowTagAttributeName
for the whole name of an attribute (b:c
in
<a b:c>
)mdxJsxTextTagAttributeName
^mdxJsxFlowTagAttributeNamePrimary
for the first name of an attribute (b
in <a b:c>
)mdxJsxTextTagAttributeNamePrimary
^mdxJsxFlowTagAttributeNamePrefixMarker
for the :
between primary and
local (<a b:c>
)mdxJsxTextTagAttributeNamePrefixMarker
^mdxJsxFlowTagAttributeNameLocal
for the local name of an attribute (c
in <a b:c>
)mdxJsxTextTagAttributeNameLocal
^mdxJsxFlowTagAttributeInitializerMarker
for the =
between an attribute
name and valuemdxJsxTextTagAttributeInitializerMarker
^mdxJsxFlowTagAttributeValueLiteral
for a string attribute value
(<a b="">
)mdxJsxTextTagAttributeValueLiteral
^mdxJsxFlowTagAttributeValueLiteralMarker
for the quotes around a string
attribute value ("
or '
)mdxJsxTextTagAttributeValueLiteralMarker
^mdxJsxFlowTagAttributeValueLiteralValue
for chunks of what’s inside
string attribute valuesmdxJsxTextTagAttributeValueLiteralValue
^mdxJsxFlowTagAttributeValueExpression
for an expression attribute value
(<a b={1}>
)mdxJsxTextTagAttributeValueExpression
^mdxJsxFlowTagAttributeValueExpressionMarker
for the {
and }
of
expression attribute valuesmdxJsxTextTagAttributeValueExpressionMarker
^mdxJsxFlowTagAttributeValueExpressionValue
for chunks of what’s inside
expression attribute valuesmdxJsxTextTagAttributeValueExpressionValue
^This package is fully typed with TypeScript.
It exports the additional type Options
.
Projects maintained by the unified collective are compatible with maintained versions of Node.js.
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.
This package is safe.
micromark-extension-mdxjs
— support all MDX syntaxmdast-util-mdx-jsx
— support MDX JSX in mdastremark-mdx
— support all MDX syntax in remarkSee contributing.md
in micromark/.github
for ways
to get started.
See support.md
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.
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
security policy file detected
Details
Reason
10 commit(s) and 1 issue activity found in the last 90 days -- score normalized to 9
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
Found 1/30 approved changesets -- score normalized to 0
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-06-09
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More