micromark-extension-mdx-md
Advanced tools
Comparing version 1.0.0 to 1.0.1
12
index.js
/** | ||
* @type {import('micromark-util-types').Extension} | ||
* @typedef {import('micromark-util-types').Extension} Extension | ||
*/ | ||
// To do: next major: expose functions. | ||
/** | ||
* Extension for `micromark` that can be passed in `extensions` to disable | ||
* some CommonMark syntax (code (indented), autolinks, and HTML (flow and | ||
* text)) for MDX. | ||
* | ||
* @type {Extension} | ||
*/ | ||
export const mdxMd = { | ||
disable: {null: ['autolink', 'codeIndented', 'htmlFlow', 'htmlText']} | ||
} |
{ | ||
"name": "micromark-extension-mdx-md", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "micromark extension to turn some markdown features off for MDX", | ||
@@ -37,19 +37,20 @@ "license": "MIT", | ||
"devDependencies": { | ||
"@types/tape": "^4.0.0", | ||
"@types/node": "^20.0.0", | ||
"c8": "^7.0.0", | ||
"micromark": "^3.0.0", | ||
"prettier": "^2.0.0", | ||
"remark-cli": "^9.0.0", | ||
"remark-preset-wooorm": "^8.0.0", | ||
"rimraf": "^3.0.0", | ||
"tape": "^5.0.0", | ||
"remark-cli": "^11.0.0", | ||
"remark-preset-wooorm": "^9.0.0", | ||
"type-coverage": "^2.0.0", | ||
"typescript": "^4.0.0", | ||
"xo": "^0.40.0" | ||
"typescript": "^5.0.0", | ||
"xo": "^0.54.0" | ||
}, | ||
"scripts": { | ||
"build": "rimraf \"*.d.ts\" && tsc && type-coverage", | ||
"prepack": "npm run build && npm run format", | ||
"build": "tsc --build --clean && tsc --build && type-coverage", | ||
"format": "remark . -qfo && prettier . -w --loglevel warn && xo --fix", | ||
"test-api": "node --conditions development test.js", | ||
"test-coverage": "c8 --check-coverage --branches 100 --functions 100 --lines 100 --statements 100 --reporter lcov node --conditions development test.js", | ||
"test-api-prod": "node --conditions production test.js", | ||
"test-api-dev": "node --conditions development test.js", | ||
"test-api": "npm run test-api-dev && npm run test-api-prod", | ||
"test-coverage": "c8 --100 --reporter lcov npm run test-api", | ||
"test": "npm run build && npm run format && npm run test-coverage" | ||
@@ -70,5 +71,5 @@ }, | ||
"plugins": [ | ||
"preset-wooorm", | ||
"remark-preset-wooorm", | ||
[ | ||
"lint-maximum-heading-length", | ||
"remark-lint-maximum-heading-length", | ||
false | ||
@@ -75,0 +76,0 @@ ] |
165
readme.md
@@ -11,25 +11,42 @@ # micromark-extension-mdx-md | ||
**[micromark][]** extension to turn some markdown features off for MDX. | ||
[micromark][] extension to turn some markdown features off for [MDX][mdxjs]. | ||
This package provides the low-level modules for integrating with the micromark | ||
tokenizer but has no handling of compiling to HTML. | ||
## Contents | ||
* [What is this?](#what-is-this) | ||
* [When to use this](#when-to-use-this) | ||
* [Install](#install) | ||
* [Use](#use) | ||
* [API](#api) | ||
* [`mdxMd`](#mdxmd) | ||
* [Authoring](#authoring) | ||
* [Types](#types) | ||
* [Compatibility](#compatibility) | ||
* [Security](#security) | ||
* [Related](#related) | ||
* [Contribute](#contribute) | ||
* [License](#license) | ||
## What is this? | ||
This package contains an extension to turn off some markdown constructs when | ||
parsing. | ||
## When to use this | ||
This package is already included in [xdm][] and [`mdx-js/mdx` (next)][mdx-js]. | ||
This project is useful when you want to disable support for code (indented), | ||
autolinks, and HTML (flow and text) in markdown. | ||
You should probably use [`micromark-extension-mdx`][mdx] or | ||
[`micromark-extension-mdxjs`][mdxjs] instead, which combine this package with | ||
other MDX features. | ||
Alternatively, if you’re using [`micromark`][micromark] or | ||
[`mdast-util-from-markdown`][from-markdown] and you don’t want all of MDX, use | ||
this package. | ||
You can use this extension when you are working with [`micromark`][micromark]. | ||
To support all MDX features, use | ||
[`micromark-extension-mdxjs`][micromark-extension-mdxjs] instead. | ||
All these packages are used in [`remark-mdx`][remark-mdx], which focusses on | ||
making it easier to transform content by abstracting these internals away. | ||
## Install | ||
This package is [ESM only](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c): | ||
Node 12+ is needed to use it and it must be `import`ed instead of `require`d. | ||
This package is [ESM only][esm]. | ||
In Node.js (version 16+), install with [npm][]: | ||
[npm][]: | ||
```sh | ||
@@ -39,2 +56,16 @@ npm install micromark-extension-mdx-md | ||
In Deno with [`esm.sh`][esmsh]: | ||
```js | ||
import {mdxMd} from 'https://esm.sh/micromark-extension-mdx-md@1' | ||
``` | ||
In browsers with [`esm.sh`][esmsh]: | ||
```html | ||
<script type="module"> | ||
import {mdxMd} from 'https://esm.sh/micromark-extension-mdx-md@1?bundle' | ||
</script> | ||
``` | ||
## Use | ||
@@ -59,3 +90,3 @@ | ||
This package exports the following identifiers: `mdxMd`. | ||
This package exports the identifier [`mdxMd`][api-mdx-md]. | ||
There is no default export. | ||
@@ -65,15 +96,75 @@ | ||
An extension for micromark to turn some markdown features (HTML, autolinks, | ||
indented code) off (can be passed in `extensions`). | ||
Extension for `micromark` that can be passed in `extensions` to disable some | ||
CommonMark syntax (code (indented), autolinks, and HTML (flow and text)) for | ||
MDX ([`Extension`][micromark-extension]). | ||
## Authoring | ||
To improve authoring the new constructs MDX adds (JSX, expressions, and | ||
ESM), some markdown features are turned off by this extension. | ||
There are good alternatives. | ||
###### Code (indented) | ||
Use fenced code instead. | ||
Change the following markdown: | ||
```markdown | ||
console.log(1) | ||
``` | ||
…into: | ||
````markdown | ||
```js | ||
console.log(1) | ||
``` | ||
```` | ||
###### Autolinks | ||
Use links (with a resource or a reference) instead. | ||
Change the following markdown: | ||
```markdown | ||
<https://some-link-here.com> | ||
``` | ||
…into: | ||
```markdown | ||
[descriptive text](https://and-the-link-here.com) | ||
``` | ||
###### HTML (flow and text) | ||
Use JSX instead: change `<img>` into `<img />`. | ||
Not supporting HTML also means that HTML comments are not supported. | ||
Use a comment in an empty expression instead. | ||
Change `<!-- comment -->` into `{/* comment */}`. | ||
## Types | ||
This package is fully typed with [TypeScript][]. | ||
It exports no additional types. | ||
## Compatibility | ||
Projects maintained by the unified collective are compatible with all 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+. | ||
## Security | ||
This package is safe. | ||
## Related | ||
* [`micromark/micromark`][micromark] | ||
— the smallest commonmark-compliant markdown parser that exists | ||
* [`micromark/micromark-extension-mdx`][mdx] | ||
— micromark extension to support MDX | ||
* [`micromark/micromark-extension-mdxjs`][mdxjs] | ||
— micromark extension to support MDX.js | ||
* [`syntax-tree/mdast-util-mdx`][mdast-util-mdx] | ||
— mdast utility to support MDX (or MDX.js) | ||
* [`micromark-extension-mdxjs`][micromark-extension-mdxjs] | ||
— support all of MDX | ||
* [`remark-mdx`][remark-mdx] | ||
— support all of MDX in remark | ||
@@ -124,2 +215,4 @@ ## Contribute | ||
[esmsh]: https://esm.sh | ||
[license]: license | ||
@@ -129,20 +222,22 @@ | ||
[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 | ||
[micromark]: https://github.com/micromark/micromark | ||
[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c | ||
[xdm]: https://github.com/wooorm/xdm | ||
[typescript]: https://www.typescriptlang.org | ||
[mdx-js]: https://github.com/mdx-js/mdx | ||
[mdxjs]: https://mdxjs.com | ||
[mdx]: https://github.com/micromark/micromark-extension-mdx | ||
[micromark]: https://github.com/micromark/micromark | ||
[mdxjs]: https://github.com/micromark/micromark-extension-mdxjs | ||
[micromark-extension]: https://github.com/micromark/micromark#syntaxextension | ||
[mdast-util-mdx]: https://github.com/syntax-tree/mdast-util-mdx | ||
[micromark-extension-mdxjs]: https://github.com/micromark/micromark-extension-mdxjs | ||
[from-markdown]: https://github.com/syntax-tree/mdast-util-from-markdown | ||
[remark-mdx]: https://mdxjs.com/packages/remark-mdx/ | ||
[api-mdx-md]: #mdxmd |
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
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
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
Found 1 instance in 1 package
9576
9
18
238
0