diff --git a/lib/react-markdown.js b/lib/react-markdown.js index 48ba44e3..58ef8169 100644 --- a/lib/react-markdown.js +++ b/lib/react-markdown.js @@ -13,6 +13,7 @@ * @property {PluggableList} [plugins=[]] **deprecated**: use `remarkPlugins` instead * @property {PluggableList} [remarkPlugins=[]] * @property {PluggableList} [rehypePlugins=[]] + * @property {import('remark-rehype').Options} [remarkRehypeOptions={}] * * @typedef LayoutOptions * @property {string} [className] @@ -87,7 +88,10 @@ export function ReactMarkdown(options) { .use(remarkParse) // TODO: deprecate `plugins` in v8.0.0. .use(options.remarkPlugins || options.plugins || []) - .use(remarkRehype, {allowDangerousHtml: true}) + .use(remarkRehype, { + ...options.remarkRehypeOptions, + allowDangerousHtml: true + }) .use(options.rehypePlugins || []) .use(rehypeFilter, options) diff --git a/package.json b/package.json index 67bce621..811d17af 100644 --- a/package.json +++ b/package.json @@ -87,7 +87,7 @@ "property-information": "^6.0.0", "react-is": "^17.0.0", "remark-parse": "^10.0.0", - "remark-rehype": "^9.0.0", + "remark-rehype": "^10.0.0", "space-separated-tokens": "^2.0.0", "style-to-object": "^0.3.0", "unified": "^10.0.0", diff --git a/readme.md b/readme.md index 926e9369..9cf21150 100644 --- a/readme.md +++ b/readme.md @@ -175,6 +175,8 @@ The default export is `ReactMarkdown`. list of [remark plugins][remark-plugins] to use * `rehypePlugins` (`Array`, default: `[]`)\ list of [rehype plugins][rehype-plugins] to use +* `remarkRehypeOptions` (`Object?`, default: `undefined`)\ + options to pass through to [`remark-rehype`][remark-rehype] * `className` (`string?`)\ wrap the markdown in a `div` with this class name * `skipHtml` (`boolean`, default: `false`)\ @@ -733,6 +735,8 @@ abide by its terms. [rehype-plugins]: https://github.com/rehypejs/rehype/blob/main/doc/plugins.md#list-of-plugins +[remark-rehype]: https://github.com/remarkjs/remark-rehype + [awesome-remark]: https://github.com/remarkjs/awesome-remark [awesome-rehype]: https://github.com/rehypejs/awesome-rehype diff --git a/test/test.jsx b/test/test.jsx index 384c0aa1..2b823a0d 100644 --- a/test/test.jsx +++ b/test/test.jsx @@ -874,6 +874,25 @@ test('should render image references', () => { ) }) +test('should render footnote with custom options', () => { + const input = [ + 'This is a statement[^1] with a citation.', + '', + '[^1]: This is a footnote for the citation.' + ].join('\n') + + assert.equal( + asHtml( + + ), + '

This is a statement1 with a citation.

\n

Footnotes

\n
    \n
  1. \n

    This is a footnote for the citation.

    \n
  2. \n
\n
' + ) +}) + test('should support definitions with funky keys', () => { const input = '[][__proto__] and [][constructor]\n\n[__proto__]: a\n[constructor]: b'