Socket
Socket
Sign inDemoInstall

remark

Package Overview
Dependencies
Maintainers
2
Versions
49
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

remark - npm Package Compare versions

Comparing version 14.0.1 to 14.0.2

4

package.json
{
"name": "remark",
"version": "14.0.1",
"description": "Markdown processor powered by plugins part of the unified collective",
"version": "14.0.2",
"description": "unified processor with support for parsing markdown input and serializing markdown as output",
"license": "MIT",

@@ -6,0 +6,0 @@ "keywords": [

@@ -11,24 +11,55 @@ # remark

[**unified**][unified] processor to parse and serialize markdown.
Built on [micromark][].
Powered by [plugins][].
Part of the [unified][] collective.
**[unified][]** processor with support for parsing markdown input and
serializing markdown as output.
* API by [**unified**][unified]
* Parses markdown to a syntax tree with [`remark-parse`][parse]
* [**mdast**][mdast] syntax tree
* [Plugins][] transform the tree
* Serializes syntax trees to markdown with [`remark-stringify`][stringify]
## Contents
Don’t need the parser?
Or compiler?
[That’s OK: use **unified** directly][unified-usage].
* [What is this?](#what-is-this)
* [When should I use this?](#when-should-i-use-this)
* [Install](#install)
* [Use](#use)
* [API](#api)
* [`remark()`](#remark-1)
* [Examples](#examples)
* [Example: checking markdown](#example-checking-markdown)
* [Example: passing options to `remark-stringify`](#example-passing-options-to-remark-stringify)
* [Syntax](#syntax)
* [Syntax tree](#syntax-tree)
* [Types](#types)
* [Compatibility](#compatibility)
* [Security](#security)
* [Contribute](#contribute)
* [Sponsor](#sponsor)
* [License](#license)
## What is this?
This package is a [unified][] processor with support for parsing markdown input
and serializing markdown as output by using unified with
[`remark-parse`][remark-parse] and [`remark-stringify`][remark-stringify].
**unified** is a project that transforms content with abstract syntax trees
(ASTs).
**remark** adds support for markdown to unified.
**mdast** is the markdown AST that remark uses.
Please see [the monorepo readme][remark] for what the remark ecosystem is.
## When should I use this?
You can use this package when you want to use unified, have markdown as input,
and want markdown as output.
This package is a shortcut for
`unified().use(remarkParse).use(remarkStringify)`.
When the input isn’t markdown (meaning you don’t need `remark-parse`) or the
output is not markdown (you don’t need `remark-stringify`), it’s recommended to
use unified directly.
When you want to inspect and format markdown files in a project on the command
line, you can use [`remark-cli`][remark-cli].
## 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](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c).
In Node.js (version 12.20+, 14.14+, or 16.0+), install with [npm][]:
[npm][]:
```sh

@@ -38,52 +69,85 @@ npm install remark

## Use
In Deno with [Skypack][]:
[See **unified** for more examples »][unified]
```js
import {remark} from 'https://cdn.skypack.dev/remark@14?dts'
```
###### Common example
In browsers with [Skypack][]:
This example lints markdown and turns it into HTML.
```html
<script type="module">
import {remark} from 'https://cdn.skypack.dev/remark@14?min'
</script>
```
## Use
Say we have the following module `example.js`:
```js
import {reporter} from 'vfile-reporter'
import {remark} from 'remark'
import remarkPresetLintRecommended from 'remark-preset-lint-recommended'
import remarkHtml from 'remark-html'
import remarkGfm from 'remark-gfm'
import remarkToc from 'remark-toc'
remark()
.use(remarkPresetLintRecommended)
.use(remarkHtml)
.process('## Hello world!')
.then((file) => {
console.error(reporter(file))
console.log(String(file))
})
main()
async function main() {
const file = await remark()
.use(remarkGfm)
.use(remarkToc)
.process('# Hi\n\n## Table of contents\n\n## Hello\n\n*Some* ~more~ _things_.')
console.error(String(file))
}
```
Yields:
Running that with `node example.js` yields:
```txt
1:1 warning Missing newline character at end of file final-newline remark-lint
```markdown
# Hi
⚠ 1 warning
```
## Table of contents
```html
<h2>Hello world!</h2>
* [Hello](#hello)
## Hello
*Some* ~~more~~ *things*.
```
###### Settings through data
## API
This example prettifies markdown and configures [`remark-stringify`][stringify]
through [data][].
This package exports the following identifier: `remark`.
There is no default export.
### `remark()`
Create a new (unfrozen) unified processor that already uses `remark-parse` and
`remark-stringify` and you can add more plugins to.
See [`unified`][unified] for more information.
## Examples
### Example: checking markdown
The following example checks that markdown code style is consistent and follows
some best practices:
```js
import {reporter} from 'vfile-reporter'
import {remark} from 'remark'
import remarkPresetLintConsistent from 'remark-preset-lint-consistent'
import remarkPresetLintRecommended from 'remark-preset-lint-recommended'
remark()
.data('settings', {emphasis: '*', strong: '*'})
.process('_Emphasis_ and __importance__')
.then((file) => {
console.log(String(file))
})
main()
async function main() {
const file = await remark()
.use(remarkPresetLintConsistent)
.use(remarkPresetLintRecommended)
.process('1) Hello, _Jupiter_ and *Neptune*!')
console.error(reporter(file))
}
```

@@ -93,10 +157,17 @@

```markdown
*Emphasis* and **importance**
```txt
1:1 warning Missing newline character at end of file final-newline remark-lint
1:1-1:35 warning Marker style should be `.` ordered-list-marker-style remark-lint
1:4 warning Incorrect list-item indent: add 1 space list-item-indent remark-lint
1:25-1:34 warning Emphasis should use `_` as a marker emphasis-marker remark-lint
⚠ 4 warnings
```
###### Settings through a preset
### Example: passing options to `remark-stringify`
This example prettifies markdown and configures [`remark-parse`][parse] and
[`remark-stringify`][stringify] through a [preset][].
When you use `remark-stringify` manually you can pass options to `use`.
Because `remark-stringify` is already used in `remark`, that’s not possible.
To define options for `remark-stringify`, you can instead pass options to
`data`:

@@ -106,8 +177,11 @@ ```js

remark()
.use({settings: {emphasis: '*', strong: '*'}})
.process('_Emphasis_ and __importance__')
.then((file) => {
console.log(String(file))
})
main()
async function main() {
const file = await remark()
.data('settings', {bullet: '*', setext: true, listItemIndent: 'one'})
.process('# Moons of Neptune\n\n- Naiad\n- Thalassa\n- Despine\n- …')
console.log(String(file))
}
```

@@ -118,18 +192,38 @@

```markdown
*Emphasis* and **importance**
Moons of Neptune
================
* Naiad
* Thalassa
* Despine
* …
```
## API
## Syntax
[See **unified** for API docs »][unified]
Markdown is parsed and serialized according to CommonMark.
Other plugins can add support for syntax extensions.
This package exports the following identifier: `remark`.
There is no default export.
## Syntax tree
The syntax tree format used in remark is [mdast][].
## Types
This package is fully typed with [TypeScript][].
There are no extra exported types.
## Compatibility
Projects maintained by the unified collective are compatible with all maintained
versions of Node.js.
As of now, that is Node.js 12.20+, 14.14+, and 16.0+.
Our projects sometimes work with older versions, but this is not guaranteed.
## Security
As markdown is sometimes used for HTML, and improper use of HTML can open you up
to a [cross-site scripting (XSS)][xss] attack, use of remark can also be unsafe.
When going to HTML, use remark in combination with the [**rehype**][rehype]
ecosystem, and use [`rehype-sanitize`][sanitize] to make the tree safe.
As markdown can be turned into HTML and improper use of HTML can open you up to
[cross-site scripting (XSS)][xss] attacks, use of remark can be unsafe.
When going to HTML, you will likely combine remark with **[rehype][]**, in which
case you should use [`rehype-sanitize`][rehype-sanitize].

@@ -139,2 +233,4 @@ Use of remark plugins could also open you up to other attacks.

For info on how to submit a report, see our [security policy][security].
## Contribute

@@ -145,7 +241,4 @@

See [`support.md`][support] for ways to get help.
Ideas for new plugins and tools can be posted in [`remarkjs/ideas`][ideas].
Join us in [Discussions][chat] to chat with the community and contributors.
A curated list of awesome remark resources can be found in [**awesome
remark**][awesome].
This project has a [code of conduct][coc].

@@ -163,11 +256,19 @@ By interacting with this repository, organization, or community you agree to

<tr valign="middle">
<td width="20%" align="center" colspan="2">
<a href="https://www.gatsbyjs.org">Gatsby</a> 🥇<br><br>
<td width="20%" align="center" rowspan="2" colspan="2">
<a href="https://vercel.com">Vercel</a><br><br>
<a href="https://vercel.com"><img src="https://avatars1.githubusercontent.com/u/14985020?s=256&v=4" width="128"></a>
</td>
<td width="20%" align="center" rowspan="2" colspan="2">
<a href="https://motif.land">Motif</a><br><br>
<a href="https://motif.land"><img src="https://avatars1.githubusercontent.com/u/74457950?s=256&v=4" width="128"></a>
</td>
<td width="20%" align="center" rowspan="2" colspan="2">
<a href="https://www.hashicorp.com">HashiCorp</a><br><br>
<a href="https://www.hashicorp.com"><img src="https://avatars1.githubusercontent.com/u/761456?s=256&v=4" width="128"></a>
</td>
<td width="20%" align="center" rowspan="2" colspan="2">
<a href="https://www.gatsbyjs.org">Gatsby</a><br><br>
<a href="https://www.gatsbyjs.org"><img src="https://avatars1.githubusercontent.com/u/12551863?s=256&v=4" width="128"></a>
</td>
<td width="20%" align="center" colspan="2">
<a href="https://vercel.com">Vercel</a> 🥇<br><br>
<a href="https://vercel.com"><img src="https://avatars1.githubusercontent.com/u/14985020?s=256&v=4" width="128"></a>
</td>
<td width="20%" align="center" colspan="2">
<td width="20%" align="center" rowspan="2" colspan="2">
<a href="https://www.netlify.com">Netlify</a><br><br>

@@ -177,5 +278,9 @@ <!--OC has a sharper image-->

</td>
</tr>
<tr valign="middle">
</tr>
<tr valign="middle">
<td width="10%" align="center">
<a href="https://www.holloway.com">Holloway</a><br><br>
<a href="https://www.holloway.com"><img src="https://avatars1.githubusercontent.com/u/35904294?s=128&v=4" width="64"></a>
<a href="https://www.coinbase.com">Coinbase</a><br><br>
<a href="https://www.coinbase.com"><img src="https://avatars1.githubusercontent.com/u/1885080?s=256&v=4" width="64"></a>
</td>

@@ -187,2 +292,6 @@ <td width="10%" align="center">

<td width="10%" align="center">
<a href="https://expo.io">Expo</a><br><br>
<a href="https://expo.io"><img src="https://avatars1.githubusercontent.com/u/12504344?s=128&v=4" width="64"></a>
</td>
<td width="10%" align="center">
<a href="https://boosthub.io">Boost Hub</a><br><br>

@@ -192,5 +301,10 @@ <a href="https://boosthub.io"><img src="https://images.opencollective.com/boosthub/6318083/logo/128.png" width="64"></a>

<td width="10%" align="center">
<a href="https://expo.io">Expo</a><br><br>
<a href="https://expo.io"><img src="https://avatars1.githubusercontent.com/u/12504344?s=128&v=4" width="64"></a>
<a href="https://www.holloway.com">Holloway</a><br><br>
<a href="https://www.holloway.com"><img src="https://avatars1.githubusercontent.com/u/35904294?s=128&v=4" width="64"></a>
</td>
<td width="10%"></td>
<td width="10%"></td>
<td width="10%"></td>
<td width="10%"></td>
<td width="10%"></td>
</tr>

@@ -238,14 +352,12 @@ <tr valign="middle">

[security]: https://github.com/remarkjs/.github/blob/main/security.md
[health]: https://github.com/remarkjs/.github
[contributing]: https://github.com/remarkjs/.github/blob/HEAD/contributing.md
[contributing]: https://github.com/remarkjs/.github/blob/main/contributing.md
[support]: https://github.com/remarkjs/.github/blob/HEAD/support.md
[support]: https://github.com/remarkjs/.github/blob/main/support.md
[coc]: https://github.com/remarkjs/.github/blob/HEAD/code-of-conduct.md
[coc]: https://github.com/remarkjs/.github/blob/main/code-of-conduct.md
[ideas]: https://github.com/remarkjs/ideas
[awesome]: https://github.com/remarkjs/awesome-remark
[license]: https://github.com/remarkjs/remark/blob/main/license

@@ -257,2 +369,4 @@

[skypack]: https://www.skypack.dev
[unified]: https://github.com/unifiedjs/unified

@@ -262,20 +376,16 @@

[parse]: https://github.com/remarkjs/remark/blob/main/packages/remark-parse
[xss]: https://en.wikipedia.org/wiki/Cross-site_scripting
[stringify]: https://github.com/remarkjs/remark/blob/main/packages/remark-stringify
[typescript]: https://www.typescriptlang.org
[plugins]: https://github.com/remarkjs/remark/blob/main/doc/plugins.md
[rehype]: https://github.com/rehypejs/rehype
[unified-usage]: https://github.com/unifiedjs/unified#usage
[remark]: https://github.com/remarkjs/remark
[preset]: https://github.com/unifiedjs/unified#preset
[rehype-sanitize]: https://github.com/rehypejs/rehype-sanitize
[data]: https://github.com/unifiedjs/unified#processordatakey-value
[remark-parse]: ../remark-parse
[xss]: https://en.wikipedia.org/wiki/Cross-site_scripting
[remark-stringify]: ../remark-stringify
[rehype]: https://github.com/rehypejs/rehype
[sanitize]: https://github.com/rehypejs/rehype-sanitize
[micromark]: https://github.com/micromark/micromark
[remark-cli]: ../remark-cli
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