
Research
Security News
Malicious PyPI Package Exploits Deezer API for Coordinated Music Piracy
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
remark-react
Advanced tools
remark plugin to transform Markdown to React.
Why?
Using innerHTML
and dangerouslySetInnerHTML
in React is a
common cause of XSS attacks: user input can include script tags and other
kinds of active content that reaches across domains and harms security.
remark-react
builds a DOM in React, using React.createElement: this
means that you can display parsed and formatted Markdown content in an
application without using dangerouslySetInnerHTML
.
⚠️ This package essentially packs
remark-rehype
andrehype-react
, and although it does support some customisation, it isn’t very pluggable. It’s probably better to useremark-rehype
andrehype-react
directly to benefit from the rehype ecosystem.
npm:
npm install remark-react
import React from 'react'
import ReactDOM from 'react-dom'
import unified from 'unified'
import parse from 'remark-parse'
import remark2react from 'remark-react'
class App extends React.Component {
constructor() {
super()
this.state = { text: '# hello world' }
this.onChange = this.onChange.bind(this)
}
onChange(e) {
this.setState({ text: e.target.value })
}
render() {
return (
<div>
<textarea value={this.state.text} onChange={this.onChange} />
<div id="preview">
{
unified()
.use(parse)
.use(remark2react)
.processSync(this.state.text).contents
}
</div>
</div>
)
}
}
ReactDOM.render(<App />, document.getElementById('root'))
remark().use(react[, options])
Transform Markdown to React.
options
options.toHast
Configure how to transform mdast to hast (object
,
default: {}
).
Passed to mdast-util-to-hast
.
Note that toHast.allowDangerousHTML
does not work: it’s not possible to
inject raw HTML with this plugin (as it’s mean to prevent having to use
dangerouslySetInnerHTML
).
options.sanitize
Sanitation schema to use (object
or boolean
, default: undefined
).
Passed to hast-util-sanitize
.
The default schema, if none or true
is passed, adheres to GitHub’s sanitation
rules.
Setting this to false
is just as bad as using
dangerouslySetInnerHTML
.
options.prefix
React key (default: h-
).
options.createElement
How to create elements or components (Function
).
Default: require('react').createElement
options.fragment
Create fragments instead of an outer <div>
if available (Function
, default:
require('react').Fragment
).
options.remarkReactComponents
Override default elements (such as <a>
, <p>
, etc) by defining an object
comprised of element: Component
key-value pairs (Object
, default:
undefined
).
For example, to output <MyLink>
components instead of <a>
, and
<MyParagraph>
instead of <p>
:
remarkReactComponents: {
a: MyLink,
p: MyParagraph
}
See how to integrate with other remark plugins in the Integrations section
of remark-html
.
See contributing.md
in remarkjs/.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, organisation, or community you agree to abide by its terms.
MIT © Titus Wormer, modified by Tom MacWright and Mapbox.
FAQs
Deprecated: this package is no longer maintained. Please use `remark-rehype` to move from remark (markdown) to rehype (HTML) and then replace `remark-react` with [`rehype-react`][rehype-react].
The npm package remark-react receives a total of 9,349 weekly downloads. As such, remark-react popularity was classified as popular.
We found that remark-react demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.
Security News
Newly introduced telemetry in devenv 1.4 sparked a backlash over privacy concerns, leading to the removal of its AI-powered feature after strong community pushback.