Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

remark-vdom

Package Overview
Dependencies
Maintainers
2
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

remark-vdom - npm Package Compare versions

Comparing version 11.0.0 to 11.0.1

8

package.json
{
"name": "remark-vdom",
"version": "11.0.0",
"description": "remark plugin to compile Markdown to VDOM",
"version": "11.0.1",
"description": "Legacy remark plugin to compile markdown to VDOM — please use something like React instead",
"license": "MIT",

@@ -55,3 +55,3 @@ "keywords": [

"remark-cli": "^10.0.0",
"remark-preset-wooorm": "^8.0.0",
"remark-preset-wooorm": "^9.0.0",
"rimraf": "^3.0.0",

@@ -62,3 +62,3 @@ "tape": "^5.0.0",

"vdom-to-html": "^2.0.0",
"xo": "^0.43.0"
"xo": "^0.46.0"
},

@@ -65,0 +65,0 @@ "scripts": {

# remark-vdom
[![Build][build-badge]][build]
[![Coverage][coverage-badge]][coverage]
[![Downloads][downloads-badge]][downloads]
[![Size][size-badge]][size]
[![Sponsors][sponsors-badge]][collective]
[![Backers][backers-badge]][collective]
[![Chat][chat-badge]][chat]
**Stability: Legacy**.
This package is no longer recommended for use.
It’s still covered by semantic-versioning guarantees and not yet deprecated, but
use of this package should be avoided.
Please use an alternative to vdom such as React (through `remark-rehype` and
`rehype-react`).
[**remark**][remark] plugin to compile Markdown to [Virtual DOM][vdom].
Legacy [documentation for this package][docs] is still available in Git.
* [x] Inherently safe and sanitized: there is no way to pass raw HTML through
* [x] Supports footnotes, todo lists
* [x] Support VNode [keys][key]
* [x] Custom components overwriting default elements (`MyLink` instead of
`<a>`)
## Note!
This plugin is ready for the new parser in remark
([`micromark`](https://github.com/micromark/micromark),
see [`remarkjs/remark#536`](https://github.com/remarkjs/remark/pull/536)).
No change is needed: it works exactly the same now as it did before!
## 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.
[npm][]:
```sh
npm install remark-vdom
```
## Use
Say we have the following file, `example.js`:
```js
import {unified} from 'unified'
import remarkParse from 'remark-parse'
import remarkVdom from 'remark-vdom'
unified()
.use(remarkParse)
.use(remarkVdom)
.process('Some _emphasis_, **importance**, and `code`.')
.then((file) => {
console.dir(file.result, {depth: null})
})
```
Now, running `node example` yields:
```js
VirtualNode {
tagName: 'DIV',
properties: { key: undefined },
children: [
VirtualNode {
tagName: 'P',
properties: { key: undefined },
children: [
VirtualText { text: 'Some ' },
VirtualNode {
tagName: 'EM',
properties: { key: undefined },
children: [ VirtualText { text: 'emphasis' } ],
key: 'h-3',
namespace: null,
count: 1,
hasWidgets: false,
hasThunks: false,
hooks: undefined,
descendantHooks: false
},
VirtualText { text: ', ' },
VirtualNode {
tagName: 'STRONG',
properties: { key: undefined },
children: [ VirtualText { text: 'importance' } ],
key: 'h-4',
namespace: null,
count: 1,
hasWidgets: false,
hasThunks: false,
hooks: undefined,
descendantHooks: false
},
VirtualText { text: ', and ' },
VirtualNode {
tagName: 'CODE',
properties: { key: undefined },
children: [ VirtualText { text: 'code' } ],
key: 'h-5',
namespace: null,
count: 1,
hasWidgets: false,
hasThunks: false,
hooks: undefined,
descendantHooks: false
},
VirtualText { text: '.' }
],
key: 'h-2',
namespace: null,
count: 10,
hasWidgets: false,
hasThunks: false,
hooks: undefined,
descendantHooks: false
}
],
key: 'h-1',
namespace: null,
count: 11,
hasWidgets: false,
hasThunks: false,
hooks: undefined,
descendantHooks: false
}
```
## API
This package exports no identifiers.
The default export is `remarkVdom`.
### `unified().use(remarkVdom[, options])`
Compile Markdown to [Virtual DOM][vdom].
> ℹ️ In [`unified@9.0.0`][unified-9], the result of `.process` changed from
> ~~`file.contents`~~ to `file.result`.
##### `options`
###### `options.sanitize`
How to sanitize the output (`Object` or `boolean`, default: `null`).
Sanitation is done by [`hast-util-sanitize`][sanitize], except when `false` is
given.
If an object is passed in, it’s given as a schema to `sanitize`.
By default, input is sanitized according to [GitHub’s sanitation rules][github].
Embedded HTML is **always** stripped.
For example, by default `className`s are stripped.
To keep them in, use something like:
```js
var merge = require('deepmerge')
var gh = require('hast-util-sanitize/lib/github')
var schema = merge(gh, {attributes: {'*': ['className']}})
var vtree = remark()
.use(vdom, {sanitize: schema})
.processSync(/* ... */)
```
###### `options.prefix`
Optimization [hint][key] (`string`, default: `h-`).
###### `options.h`
Hyperscript to use (`Function`, default: `require('virtual-dom/h')`).
###### `options.components`
Map of tag names to custom components (`Object.<Function>`, optional).
That component is invoked with `tagName`, `props`, and `children`.
It can return any VDOM compatible value (such as `VNode`, `VText`, `Widget`).
For example:
```js
var components = {code: code}
function code(tagName, props, children) {
// Ensure a default programming language is set.
if (!props.className) {
props.className = 'language-js'
}
return h(tagName, props, children)
}
```
## Integrations
Integrates with the same tools as [`remark-html`][remark-html].
## Security
Use of `remark-vdom` is *safe* by default, but changing the `sanitize` option
can open you up to a [cross-site scripting (XSS)][xss] attack if the tree is
unsafe.
## Related
* [`remark-rehype`](https://github.com/remarkjs/remark-rehype)
— Properly transform to an HTML virtual DOM (hast)
* [`rehype-react`](https://github.com/rhysd/rehype-react)
— Transform hast to React
* [`remark-react`](https://github.com/mapbox/remark-react)
— Compile markdown to React
* [`remark-man`](https://github.com/remarkjs/remark-man)
— Compile to man pages
* [`remark-html`][remark-html]
— Compile to HTML
## Contribute
See [`contributing.md`][contributing] in [`remarkjs/.github`][health] for ways
to get started.
See [`support.md`][support] for ways to get help.
This project has a [code of conduct][coc].
By interacting with this repository, organization, or community you agree to
abide by its terms.
## License

@@ -232,38 +18,2 @@

[build-badge]: https://github.com/remarkjs/remark-vdom/workflows/main/badge.svg
[build]: https://github.com/remarkjs/remark-vdom/actions
[coverage-badge]: https://img.shields.io/codecov/c/github/remarkjs/remark-vdom.svg
[coverage]: https://codecov.io/github/remarkjs/remark-vdom
[downloads-badge]: https://img.shields.io/npm/dm/remark-vdom.svg
[downloads]: https://www.npmjs.com/package/remark-vdom
[size-badge]: https://img.shields.io/bundlephobia/minzip/remark-vdom.svg
[size]: https://bundlephobia.com/result?p=remark-vdom
[sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg
[backers-badge]: https://opencollective.com/unified/backers/badge.svg
[collective]: https://opencollective.com/unified
[chat-badge]: https://img.shields.io/badge/chat-discussions-success.svg
[chat]: https://github.com/remarkjs/remark/discussions
[npm]: https://docs.npmjs.com/cli/install
[health]: https://github.com/remarkjs/.github
[contributing]: https://github.com/remarkjs/.github/blob/HEAD/contributing.md
[support]: https://github.com/remarkjs/.github/blob/HEAD/support.md
[coc]: https://github.com/remarkjs/.github/blob/HEAD/code-of-conduct.md
[license]: license

@@ -273,16 +23,2 @@

[remark]: https://github.com/remarkjs/remark
[remark-html]: https://github.com/remarkjs/remark-html
[sanitize]: https://github.com/syntax-tree/hast-util-sanitize
[github]: https://github.com/syntax-tree/hast-util-sanitize#schema
[vdom]: https://github.com/Matt-Esch/virtual-dom
[key]: https://github.com/Matt-Esch/virtual-dom/tree/HEAD/virtual-hyperscript#key
[xss]: https://en.wikipedia.org/wiki/Cross-site_scripting
[unified-9]: https://github.com/unifiedjs/unified/releases/tag/9.0.0
[docs]: https://github.com/remarkjs/remark-vdom/tree/9355fde
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