rehype plugin to enhance alerts
npm install rehype-github-alert[![Build][build-badge]][build]
[![Coverage][coverage-badge]][coverage]
[![Downloads][downloads-badge]][downloads]
[![Size][size-badge]][size]
[![Sponsors][sponsors-badge]][collective]
[![Backers][backers-badge]][collective]
[![Chat][chat-badge]][chat]
[rehype][] plugin to support alerts like on GitHub.
* What is this?
* When should I use this?
* Install
* Use
* API
* rehypeGithubAlert()
* Bugs
* Authoring
* HTML
* CSS
* Syntax
* Types
* Compatibility
* Security
* Related
* Contribute
* Notice
* License
This plugin enhances turns the format that github.com uses for alerts
into actual alerts.
It turns blockquotes that start with a specific paragraph (such as [!note])
into divs with a particular class:
> \[!note]
>
> This is a note!
This plugin is part of a monorepo [rehype-github][monorepo].
See its readme for more info.
You can use this plugin when you want to match how github.com works.
For your own pipelines,
similar to github.com,
I would recommend using directives instead.
See [remark-directive][remark-directive] for more info.
This package is [ESM only][esm].
In Node.js (version 16+),
install with [npm][]:
``sh`
npm install rehype-github-alert
In Deno with [esm.sh][esmsh]:
`js`
import rehypeGithubAlert from 'https://esm.sh/rehype-github-alert@1'
In browsers with [esm.sh][esmsh]:
`html`
Say our module example.js looks as follows:
`js
import rehypeGithubAlert from 'rehype-github-alert'
import rehypeParse from 'rehype-parse'
import rehypeStringify from 'rehype-stringify'
import {unified} from 'unified'
const file = await unified()
.use(rehypeParse, {fragment: true})
.use(rehypeGithubAlert)
.use(rehypeStringify)
.process('
')[!note]
hi
console.log(String(file))
`
…now running node example.js yields:
` Note hihtml`
This package exports no identifiers.
The default export is
[rehypeGithubAlert][api-rehype-github-alert].
Plugin to enhance alerts.
###### Parameters
There are no parameters.
###### Returns
Transform ((tree: Root, file: VFile) => Promise).
There are just many oddities with how this all works.
If you can,
I would recommend using [remark-directive][remark-directive] instead.
For a combination of the two,
see
[remark-github-admonitions-to-directives][remark-github-admonitions-etc].
You do not need to use screaming uppercase:
[!note] is fine!
The markup for that github.com adds is:
` Note hihtml`
Each different label (such as tip) is turned into a different classtip
( turns into markdown-alert-tip).tip
They each also get a different icon ( gets octicon-light-bulb).
For different HTML,
see
[rehype-github-alerts][rehype-github-alerts].
See [github-markdown-css][github-markdown-css] for the CSS that GitHub uses..markdown-alert
Relevant styles are under and .octicon.
No syntax is applicable.
This package is fully typed with [TypeScript][].
It exports no additional types.
Projects maintained by the unified collective are compatible with all maintained
versions of Node.js.
As of now,
that is Node.js 16+.
Our projects sometimes work with older versions,
but this is not guaranteed.
This plugin works with rehype-parse version 3+,rehype-stringify version 3+,rehype version 5+,unified
and version 6+.
This package is safe.
* remark-gfm
— support GFM in remark
See [contributing.md in rehypejs/.github][contributing] for ways to getsupport.md`][support] for ways to get help.
started.
See [
This project has a [code of conduct][coc].
By interacting with this repository,
organization,
or community you agree to abide by its terms.
This project is not affiliated with GitHub.
[MIT][license] © [Titus Wormer][author]
[build-badge]: https://github.com/rehypejs/rehype-github/workflows/main/badge.svg
[build]: https://github.com/rehypejs/rehype-github/actions
[coverage-badge]: https://img.shields.io/codecov/c/github/rehypejs/rehype-github.svg
[coverage]: https://codecov.io/github/rehypejs/rehype-github
[downloads-badge]: https://img.shields.io/npm/dm/rehype-github-alert.svg
[downloads]: https://www.npmjs.com/package/rehype-github-alert
[size-badge]: https://img.shields.io/bundlephobia/minzip/rehype-github-alert.svg
[size]: https://bundlephobia.com/result?p=rehype-github-alert
[sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg
[backers-badge]: https://opencollective.com/unified/backers/badge.svg
[collective]: https://opencollective.com/unified
[chat-badge]: https://img.shields.io/badge/chat-discussions-success.svg
[chat]: https://github.com/rehypejs/rehype/discussions
[npm]: https://docs.npmjs.com/cli/install
[esmsh]: https://esm.sh
[license]: ../../license
[author]: https://wooorm.com
[contributing]: https://github.com/rehypejs/.github/blob/main/contributing.md
[support]: https://github.com/rehypejs/.github/blob/main/support.md
[coc]: https://github.com/rehypejs/.github/blob/main/code-of-conduct.md
[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
[typescript]: https://www.typescriptlang.org
[monorepo]: https://github.com/rehypejs/rehype-github
[github-markdown-css]: https://github.com/sindresorhus/github-markdown-css
[rehype-github-alerts]: https://github.com/chrisweb/rehype-github-alerts
[rehype]: https://github.com/rehypjs/rehype
[remark-directive]: https://github.com/remarkjs/remark-directive
[remark-github-admonitions-etc]: https://github.com/incentro-ecx/remark-github-admonitions-to-directives
[api-rehype-github-alert]: #rehypegithubalert