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

react-markdown

Package Overview
Dependencies
Maintainers
2
Versions
92
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-markdown - npm Package Compare versions

Comparing version 9.0.0 to 9.0.1

30

lib/index.js

@@ -87,3 +87,2 @@ // Register `Raw` in tree:

import {urlAttributes} from 'html-url-attributes'
import {sanitizeUri} from 'micromark-util-sanitize-uri'
// @ts-expect-error: untyped.

@@ -97,3 +96,2 @@ import {Fragment, jsx, jsxs} from 'react/jsx-runtime'

const own = {}.hasOwnProperty
const changelog =

@@ -256,3 +254,6 @@ 'https://github.com/remarkjs/react-markdown/blob/main/changelog.md'

for (key in urlAttributes) {
if (own.call(urlAttributes, key) && own.call(node.properties, key)) {
if (
Object.hasOwn(urlAttributes, key) &&
Object.hasOwn(node.properties, key)
) {
const value = node.properties[key]

@@ -301,3 +302,24 @@ const test = urlAttributes[key]

export function defaultUrlTransform(value) {
return sanitizeUri(value, safeProtocol)
// Same as:
// <https://github.com/micromark/micromark/blob/929275e/packages/micromark-util-sanitize-uri/dev/index.js#L34>
// But without the `encode` part.
const colon = value.indexOf(':')
const questionMark = value.indexOf('?')
const numberSign = value.indexOf('#')
const slash = value.indexOf('/')
if (
// If there is no protocol, it’s relative.
colon < 0 ||
// If the first colon is after a `?`, `#`, or `/`, it’s not a protocol.
(slash > -1 && colon > slash) ||
(questionMark > -1 && colon > questionMark) ||
(numberSign > -1 && colon > numberSign) ||
// It is a protocol, it should be allowed.
safeProtocol.test(value.slice(0, colon))
) {
return value
}
return ''
}

3

package.json
{
"name": "react-markdown",
"version": "9.0.0",
"version": "9.0.1",
"description": "React component to render markdown",

@@ -84,3 +84,2 @@ "license": "MIT",

"mdast-util-to-hast": "^13.0.0",
"micromark-util-sanitize-uri": "^2.0.0",
"remark-parse": "^11.0.0",

@@ -87,0 +86,0 @@ "remark-rehype": "^11.0.0",

@@ -120,3 +120,3 @@ <!--

import React from 'react'
import ReactDom from 'react-dom'
import {createRoot} from 'react-dom/client'
import Markdown from 'react-markdown'

@@ -126,3 +126,3 @@

ReactDom.render(<Markdown>{markdown}</Markdown>, document.body)
createRoot(document.body).render(<Markdown>{markdown}</Markdown>)
```

@@ -141,9 +141,9 @@

Here is an example that shows passing the markdown as a string and how
to use a plugin ([`remark-gfm`][remark-gfm], which adds support for
footnotes, strikethrough, tables, tasklists and URLs directly):
Here is an example that shows how to use a plugin ([`remark-gfm`][remark-gfm],
which adds support for footnotes, strikethrough, tables, tasklists and URLs
directly):
```jsx
import React from 'react'
import ReactDom from 'react-dom'
import {createRoot} from 'react-dom/client'
import Markdown from 'react-markdown'

@@ -154,5 +154,4 @@ import remarkGfm from 'remark-gfm'

ReactDom.render(
<Markdown remarkPlugins={[remarkGfm]}>{markdown}</Markdown>,
document.body
createRoot(document.body).render(
<Markdown remarkPlugins={[remarkGfm]}>{markdown}</Markdown>
)

@@ -315,3 +314,3 @@ ```

import React from 'react'
import ReactDom from 'react-dom'
import {createRoot} from 'react-dom/client'
import Markdown from 'react-markdown'

@@ -334,5 +333,4 @@ import remarkGfm from 'remark-gfm'

ReactDom.render(
<Markdown remarkPlugins={[remarkGfm]}>{markdown}</Markdown>,
document.body
createRoot(document.body).render(
<Markdown remarkPlugins={[remarkGfm]}>{markdown}</Markdown>
)

@@ -388,3 +386,3 @@ ```

import React from 'react'
import ReactDom from 'react-dom'
import {createRoot} from 'react-dom/client'
import Markdown from 'react-markdown'

@@ -395,7 +393,6 @@ import remarkGfm from 'remark-gfm'

ReactDom.render(
createRoot(document.body).render(
<Markdown remarkPlugins={[[remarkGfm, {singleTilde: false}]]}>
{markdown}
</Markdown>,
document.body
</Markdown>
)

@@ -427,3 +424,3 @@ ```

import React from 'react'
import ReactDom from 'react-dom'
import {createRoot} from 'react-dom/client'
import Markdown from 'react-markdown'

@@ -441,3 +438,3 @@ import {Prism as SyntaxHighlighter} from 'react-syntax-highlighter'

ReactDom.render(
createRoot(document.body).render(
<Markdown

@@ -452,6 +449,6 @@ children={markdown}

{...rest}
PreTag="div"
children={String(children).replace(/\n$/, '')}
language={match[1]}
style={dark}
language={match[1]}
PreTag="div"
/>

@@ -465,4 +462,3 @@ ) : (

}}
/>,
document.body
/>
)

@@ -493,3 +489,3 @@ ```

import React from 'react'
import ReactDom from 'react-dom'
import {createRoot} from 'react-dom/client'
import Markdown from 'react-markdown'

@@ -502,7 +498,6 @@ import rehypeKatex from 'rehype-katex'

ReactDom.render(
createRoot(document.body).render(
<Markdown remarkPlugins={[remarkMath]} rehypePlugins={[rehypeKatex]}>
{markdown}
</Markdown>,
document.body
</Markdown>
)

@@ -619,3 +614,3 @@ ```

import React from 'react'
import ReactDom from 'react-dom'
import {createRoot} from 'react-dom/client'
import Markdown from 'react-markdown'

@@ -630,5 +625,4 @@ import rehypeRaw from 'rehype-raw'

ReactDom.render(
<Markdown rehypePlugins={[rehypeRaw]}>{markdown}</Markdown>,
document.body
createRoot(document.body).render(
<Markdown rehypePlugins={[rehypeRaw]}>{markdown}</Markdown>
)

@@ -704,3 +698,3 @@ ```

// Pass the value as an expresion as an only child:
<Markdown>{markdown}</Markdown>
const result = <Markdown>{markdown}</Markdown>
```

@@ -707,0 +701,0 @@

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