Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace renderers w/ components, remove HTML parser from core #563

Merged
merged 6 commits into from Apr 12, 2021

Conversation

wooorm
Copy link
Member

@wooorm wooorm commented Apr 9, 2021

  • Replace renderers w/ components
  • Replace allowNode w/ allowElement, which is now given a hast element (as the first parameter)
  • Replace allowedTypes w/ allowedElements
  • Replace disallowedTypes w/ disallowedElements
  • Change signature of linkTarget and transformLinkUri, which are now given hast children (as the second parameter)
  • Change signature of transformImageUri, which is now given the alt string as the second parameter (instead of the fourth)
  • Replace plugins w/ remarkPlugins (backwards compatible change)
  • Add rehypePlugins
  • Change includeNodeIndex to includeElementIndex: it still sets an index, but that value now represents the number of preceding elements, it also sets a siblingCount (instead of parentChildCount) with the number of sibling elements in the parent
  • The columnAlignment prop is no longer given to table elements: it’s available as style on th and td elements instead
  • The spread prop is no longer given to list elements: it’s already handled

Remove buggy HTML parsers from core

  • If you want HTML, add rehype-raw to rehypePlugins and it’ll work without bugs!
  • Remove allowDangerousHtml (previously called escapeHtml) option: pass rehype-raw to allow HTML instead
  • Remove with-html.js, plugins/html-parser.js entries from library
  • Remove naïve HTML parser too: either use rehype-raw to properly support HTML, or don’t allow it at all

Closes GH-549.

The following issues are solved as rehype is now available:

Closes GH-522.
Closes GH-465.
Closes GH-427.
Closes GH-384.
Closes GH-356.

The following issues are solved as a proper HTML parser (rehype-raw) is now available:

Closes GH-562.
Closes GH-460.
Closes GH-454.
Closes GH-452.
Closes GH-433.
Closes GH-386.
Closes GH-385.
Closes GH-345.
Closes GH-320.
Closes GH-302.
Closes GH-267.
Closes GH-259.

The following issues are solved as docs are improved:

Closes GH-251.

* Replace `renderers` w/ `components`
* Replace `allowNode` w/ `allowElement`, which is now given a hast
  element (as the first parameter)
* Replace `allowedTypes` w/ `allowedElements`
* Replace `disallowedTypes` w/ `disallowedElements`
* Change signature of `linkTarget` and `transformLinkUri`, which are now
  given hast children (as the second parameter)
* Change signature of `transformImageUri`, which is now given the `alt`
  string as the second parameter (instead of the fourth)
* Replace `plugins` w/ `remarkPlugins` (backwards compatible change)
* Add `rehypePlugins`
* Change `includeNodeIndex` to `includeElementIndex`: it still sets an
  `index`, but that value now represents the number of preceding elements,
  it also sets a `siblingCount` (instead of `parentChildCount`) with
  the number of sibling elements in the parent
* The `columnAlignment` prop is no longer given to table elements:
  it’s available as `style` on `th` and `td` elements instead
* The `spread` prop is no longer given to list elements: it’s already
  handled
* If you want HTML, add [`rehype-raw`](https://github.com/rehypejs/rehype-raw)
  to `rehypePlugins` and it’ll work without bugs!
* Remove `allowDangerousHtml` (previously called `escapeHtml`) option:
  pass `rehype-raw` to allow HTML instead
* Remove `with-html.js`, `plugins/html-parser.js` entries from library
* Remove naïve HTML parser too:
  either use `rehype-raw` to properly support HTML, or don’t allow it at all
@wooorm wooorm added 🗄 area/interface This affects the public interface 🧑 semver/major This is a change 🙆 yes/confirmed This is confirmed and ready to be worked on 🦋 type/enhancement This is great to have labels Apr 9, 2021
@wooorm wooorm self-assigned this Apr 9, 2021
Copy link
Member

@ChristianMurphy ChristianMurphy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @wooorm!

src/react-markdown.js Outdated Show resolved Hide resolved
src/react-markdown.js Show resolved Hide resolved
src/react-markdown.js Outdated Show resolved Hide resolved
src/react-markdown.js Show resolved Hide resolved
src/rehype-filter.js Outdated Show resolved Hide resolved
src/ast-to-react.js Show resolved Hide resolved
src/ast-to-react.js Show resolved Hide resolved
src/ast-to-react.js Outdated Show resolved Hide resolved
Co-authored-by: Christian Murphy <christian.murphy.42@gmail.com>
@codecov-io

This comment has been minimized.

@wooorm wooorm mentioned this pull request Apr 11, 2021
package.json Outdated Show resolved Hide resolved
src/rehype-filter.js Show resolved Hide resolved
@0bx
Copy link

0bx commented May 14, 2021

Hi,

Previously renderers supported root property, which is no longer available in components. I've used this renderer to create custom table of contents element. I'd appreciate, if you could tell me how this could be achieved with the new API.

@wooorm
Copy link
Member Author

wooorm commented May 14, 2021

Something like remark-toc can be used to inject a table of contents on the markdown side. Alternatively, use mdast-util-toc, which is somewhat deeper and can generate just a ToC.
Also rehype-toc might be of interest

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment