react-markdown
Advanced tools
Comparing version 9.0.0 to 9.0.1
@@ -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 '' | ||
} |
{ | ||
"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 @@ |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
45413
12
423
0
886
+ Addedmicromark-util-subtokenize@2.0.2(transitive)
- Removedmicromark-util-sanitize-uri@^2.0.0
- Removedmicromark-util-subtokenize@2.0.3(transitive)