-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow AlpineJS syntax extensions in Markdown (#3554)
* Allow AlpineJS syntax extensions in Markdown * Remove unwanted MDX ESM import/export support
- Loading branch information
1 parent
073bab5
commit c549f16
Showing
6 changed files
with
554 additions
and
398 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@astrojs/markdown-remark': patch | ||
--- | ||
|
||
Allow AlpineJS syntax extensions in Markdown |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Note: The code in this file is based on `micromark-extension-mdxjs` | ||
// and was adapted to use our fork `@astrojs/micromark-extension-mdx-jsx` | ||
// instead of `micromark-extension-mdx-jsx` to allow some extended syntax. | ||
// See `@astrojs/micromark-extension-mdx-jsx` on NPM for more details. | ||
// Also, support for ESM imports & exports in Markdown content was removed. | ||
|
||
import { Parser } from 'acorn'; | ||
import acornJsx from 'acorn-jsx'; | ||
import { combineExtensions } from 'micromark-util-combine-extensions'; | ||
import { mdxExpression } from 'micromark-extension-mdx-expression'; | ||
import { mdxJsx } from '@astrojs/micromark-extension-mdx-jsx'; | ||
import { mdxMd } from 'micromark-extension-mdx-md'; | ||
import type { Options } from 'micromark-extension-mdx-expression'; | ||
import type { Extension } from 'micromark-util-types'; | ||
|
||
export function mdxjs(options: Options): Extension { | ||
const settings: any = Object.assign( | ||
{ | ||
acorn: Parser.extend(acornJsx()), | ||
acornOptions: { ecmaVersion: 2020, sourceType: 'module' }, | ||
addResult: true | ||
}, | ||
options | ||
); | ||
|
||
return combineExtensions([ | ||
mdxExpression(settings), | ||
mdxJsx(settings), | ||
mdxMd | ||
]); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.